Skip to content

Beta v8.23.1 (#6691) #4683

Beta v8.23.1 (#6691)

Beta v8.23.1 (#6691) #4683

Workflow file for this run

name: shellcheck
on: [pull_request, push]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
defaults:
run:
shell: sh
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-22.04
steps:
- name: Setup tmpfs
run: sudo mount -t tmpfs -o "noatime,lazytime,uid=$(id -u)" tmpfs "$GITHUB_WORKSPACE"
- 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 'G_HW_MEMORY_SIZE=1024\nG_HW_ONBOARD_WIFI=1' | sudo tee -a /boot/dietpi/.hw_model
- name: Download shellcheck
run: |
curl -sSfL "$(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}')" -o shellcheck.tar.xz
tar --wildcards --strip-components=1 -xf shellcheck.tar.xz '*/shellcheck'
rm shellcheck.tar.xz
- name: Run shellcheck
shell: bash
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[@]}"
- name: Check for trailing spaces
if: always()
run: |
rm shellcheck
! 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|$)' .