-
-
Notifications
You must be signed in to change notification settings - Fork 499
50 lines (50 loc) · 2.08 KB
/
shellcheck.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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|$)' .