v9.9 #6739
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: shellcheck | |
on: [pull_request, push] | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
permissions: | |
contents: read | |
jobs: | |
shellcheck: | |
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.owner.login != github.event.pull_request.base.repo.owner.login | |
# https://github.com/actions/runner-images | |
runs-on: ubuntu-24.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup DietPi-Globals | |
run: | | |
sudo mkdir -p /boot/dietpi/func | |
sudo cp dietpi/func/dietpi-globals /boot/dietpi/func/ | |
sudo ./dietpi/func/dietpi-obtain_hw_model | |
echo -e 'G_HW_MEMORY_SIZE=1024\nG_HW_ONBOARD_WIFI=1' | sudo tee -a /boot/dietpi/.hw_model | |
- name: Download shellcheck | |
run: | | |
curl -sSfLo shellcheck.tar.xz "$(curl -sSfH 'Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' 'https://api.github.com/repos/koalaman/shellcheck/releases/latest' | mawk -F\" '/"browser_download_url.*\.linux\.x86_64\.tar\.xz"/{print $4;exit}')" | |
tar --wildcards --strip-components=1 -xf shellcheck.tar.xz '*/shellcheck' | |
rm shellcheck.tar.xz | |
- name: Run shellcheck | |
run: | | |
mapfile -t FILES < <(find . -not \( -path './.git' -prune \) -type f) # read all files to array | |
for i in "${!FILES[@]}" | |
do | |
[[ ${FILES[$i]##*/} =~ '.'[^.]*'sh'$ ]] && continue # file has shell extension | |
[[ $(mawk '/^#!.*sh([[:blank:]]|$)/;{exit}' "${FILES[$i]}") ]] && continue # file has shell shebang | |
unset -v "FILES[$i]" # else remove from array | |
done | |
./shellcheck -C -xo all "${FILES[@]}" | |
rm shellcheck | |
- name: Check for trailing spaces | |
if: always() | |
run: | | |
! grep -rn --exclude-dir='.git' -I '[[:blank:]]$' . | |
- name: Check for multiple newlines | |
if: always() | |
run: | | |
! grep -rzPo --exclude-dir='.git' --exclude='*.png' '(^|\n)\N*\n\n\n+\N*(\n|$)' . |