armbian-build/.github/workflows/lint-scripts-pr.yml
Igor Pečovnik 1fcdf63c4e
Look only for bash shebang (#4928)
* Look only for bash shebang

We have some Python scripts now so we need to move that out

* Extend script to cover ignored files and use internal tool for checking the rest

Signed-off-by: Igor <igor@armbian.com>

---------

Signed-off-by: Igor <igor@armbian.com>
2023-03-15 16:22:14 +01:00

57 lines
1.4 KiB
YAML

name: Lint On Scripts
#
# Run ShellCheck on all scripts and generates report as build artefact
#
on:
workflow_dispatch:
pull_request:
types: [opened, reopened, edited, synchronize]
permissions:
contents: read
jobs:
Shellcheck:
name: Shell script analysis
runs-on: ubuntu-latest
if: ${{ github.repository_owner == 'Armbian' }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 2
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v35
- name: List all changed files
run: |
# use framework internal mechanism for checking `lib` and `extensions` code only one file is passed,
# and source's are followed, thus the whole project is "understood" by shellcheck.
# For example, when checking individual files, one variable might be thought "unused" because it
# is only used in another file, which does not happen when done properly.
bash lib/tools/shellcheck.sh
ret=0
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
if [[ ! "${file}" =~ lib/|extensions/|.py|.service|.rules|.network|.netdev ]]; then
if grep -qE "^#\!/.*bash" $file; then
shellcheck --severity=error $file || ret=$?
fi
fi
done
exit $ret