pr-lint-scripts.yml 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. name: Lint on Scripts
  2. run-name: 'Shellcheck - PR #${{ github.event.pull_request.number }} ("${{ github.event.pull_request.title }}")'
  3. #
  4. # Run ShellCheck on all scripts and generate report as build artifact
  5. #
  6. on:
  7. workflow_dispatch:
  8. pull_request:
  9. types: [opened, reopened, synchronize]
  10. permissions:
  11. contents: read
  12. concurrency:
  13. group: pipeline-lint-${{github.event.pull_request.number}}
  14. cancel-in-progress: true
  15. jobs:
  16. Shellcheck:
  17. name: Shell script analysis
  18. runs-on: ubuntu-latest
  19. if: ${{ github.repository_owner == 'Armbian' }}
  20. steps:
  21. - name: Checkout repository
  22. uses: actions/checkout@v4
  23. with:
  24. fetch-depth: 2
  25. - name: Get changed files
  26. id: changed-files
  27. uses: tj-actions/changed-files@c34c1c13a740b06851baff92ab9a653d93ad6ce7 # v46.0.3
  28. - name: List all changed files
  29. run: |
  30. # Use framework internal mechanism for checking `lib` and `extensions` code only one file is passed,
  31. # and source's are followed, thus the whole project is "understood" by shellcheck.
  32. # For example, when checking individual files, one variable might be thought "unused" because it
  33. # is only used in another file, which does not happen when done properly.
  34. bash lib/tools/shellcheck.sh
  35. ret=0
  36. for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
  37. if [[ ! "${file}" =~ lib/|extensions/|.py|.service|.rules|.network|.netdev ]]; then
  38. if grep -qE "^#\!/.*bash" $file; then
  39. shellcheck --severity=error $file || ret=$?
  40. fi
  41. fi
  42. done
  43. exit $ret