-
Notifications
You must be signed in to change notification settings - Fork 0
65 lines (59 loc) · 1.82 KB
/
bash-ci.yml
File metadata and controls
65 lines (59 loc) · 1.82 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
name: bash-ci (reusable)
on:
workflow_call:
inputs:
shellcheck-paths:
description: 'Space-separated paths for shellcheck. Default: every tracked .sh file.'
required: false
type: string
default: ''
shellcheck-severity:
description: 'Shellcheck severity threshold (error|warning|info|style).'
required: false
type: string
default: 'warning'
test-command:
description: 'Optional test command (e.g. ./_tests/run_tests.sh). Empty = skip.'
required: false
type: string
default: ''
runs-on:
description: 'Runner image. Default ubuntu-latest.'
required: false
type: string
default: 'ubuntu-latest'
jobs:
bash-quality:
runs-on: ${{ inputs.runs-on }}
steps:
- uses: actions/checkout@v4
- name: Install CLI tools via mise (track-latest)
uses: jdx/mise-action@1648a7812b9aeae629881980618f079932869151 # v4.0.1
with:
cache: ${{ github.event_name != 'schedule' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Bash syntax check
shell: bash
run: |
set -e
targets="${{ inputs.shellcheck-paths }}"
if [[ -z "$targets" ]]; then
targets="$(git ls-files '*.sh' '*.bash')"
fi
for f in $targets; do
bash -n "$f"
done
- name: ShellCheck
shell: bash
run: |
set -e
targets="${{ inputs.shellcheck-paths }}"
if [[ -z "$targets" ]]; then
targets="$(git ls-files '*.sh' '*.bash')"
fi
shellcheck -S "${{ inputs.shellcheck-severity }}" $targets
- name: Test
if: ${{ inputs.test-command != '' }}
shell: bash
run: ${{ inputs.test-command }}