-
-
Notifications
You must be signed in to change notification settings - Fork 1
216 lines (186 loc) · 6.76 KB
/
Copy pathcheck.yaml
File metadata and controls
216 lines (186 loc) · 6.76 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
name: Check
on:
push:
branches:
- main
- renovate/**
paths:
# "pnpm" group:
- '**.js'
- '**.ts'
- .editorconfig
- biome.json
- package.json
- pnpm-lock.ya?ml
- tsconfig.json
# "actionlint" group:
- .github/workflows/*.ya?ml
# "shellcheck" group:
- '**.sh'
- '**.bash'
- '**.mksh'
- '**.bats'
- '**.zsh'
- .githooks/*
pull_request:
branches:
- main
paths:
# "pnpm" group:
- '**.js'
- '**.ts'
- .editorconfig
- biome.json
- package.json
- pnpm-lock.ya?ml
- tsconfig.json
# "actionlint" group:
- .github/workflows/*.ya?ml
# "shellcheck" group:
- '**.sh'
- '**.bash'
- '**.mksh'
- '**.bats'
- '**.zsh'
- .githooks/*
workflow_dispatch:
workflow_call:
jobs:
check:
name: Check
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: ${{ github.event_name == 'push' && '0' || '1' }}
- name: Get changed files
id: changed-files
if: github.event_name != 'workflow_dispatch'
uses: tj-actions/changed-files@a284dc1814e3fd07f2e34267fc8f81227ed29fb8 # v45.0.9
with:
files_yaml: |
pnpm:
- '**/*.{js,ts}'
- .editorconfig
- biome.json
- package.json
- pnpm-lock.{yml,yaml}
- tsconfig.json
actionlint:
- .github/workflows/*.{yml,yaml}
shellcheck:
- '**/*.{sh,bash,mksh,bats,zsh}'
- .githooks/*
- name: Check GitHub Actions workflows using actionlint
if: |
github.event_name == 'workflow_dispatch' ||
steps.changed-files.outputs.actionlint_any_changed == 'true'
env:
# renovate: datasource=github-releases depName=rhysd/actionlint
ACTIONLINT_VERSION: v1.7.7
ACTIONLINT_ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.actionlint_all_changed_files }}
run: |
IFS=$' \n\t'; set -ux
if [[ "${GITHUB_EVENT_NAME}" == 'workflow_dispatch' ]]; then
# Get files using globs.
shopt -s nullglob globstar
files=(.github/workflows/*.{yml,yaml})
shopt -u nullglob globstar
# Check if files were found.
if [[ "${#files[@]}" -eq 0 ]]; then
: "No files found"
exit 1
fi
else
# Get files using changed files output.
files=()
for file in ${ACTIONLINT_ALL_CHANGED_FILES}; do
files+=("${file}")
done
fi
: "Files to lint: ${files[*]}"
# Download, extract and setup actionlint.
wget -q "https://github.com/rhysd/actionlint/releases/download/${ACTIONLINT_VERSION}/actionlint_${ACTIONLINT_VERSION#v}_linux_amd64.tar.gz" \
-O actionlint.tar.gz
tar -xzf actionlint.tar.gz
chmod +x actionlint
# Download and setup problem matcher for actionlint.
wget -q "https://raw.githubusercontent.com/rhysd/actionlint/${ACTIONLINT_VERSION}/.github/actionlint-matcher.json" \
-O actionlint-problem-matcher.json
echo "::add-matcher::actionlint-problem-matcher.json"
# Run actionlint.
./actionlint -verbose -color "${files[@]}"
- name: Check shell scripts and git hooks using shellcheck
if: |
github.event_name == 'workflow_dispatch' ||
steps.changed-files.outputs.shellcheck_any_changed == 'true'
env:
# renovate: datasource=github-releases depName=koalaman/shellcheck
SHELLCHECK_VERSION: v0.10.0
SHELLCHECK_ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.shellcheck_all_changed_files }}
# renovate: datasource=github-releases depName=lumaxis/shellcheck-problem-matchers
SHELLCHECK_PROBLEM_MATCHERS_VERSION: v2.1.0
run: |
IFS=$' \n\t'; set -ux
if [[ "${GITHUB_EVENT_NAME}" == 'workflow_dispatch' ]]; then
# Get files using globs.
shopt -s nullglob globstar
files=(**/*.{sh,bash,mksh,bats,zsh} .githooks/*)
shopt -u nullglob globstar
# Check if files were found.
if [[ "${#files[@]}" -eq 0 ]]; then
: "No files found"
exit 1
fi
else
# Get files using changed files output.
files=()
for file in ${SHELLCHECK_ALL_CHANGED_FILES}; do
files+=("${file}")
done
fi
: "Files to lint: ${files[*]}"
# Download, extract and setup shellcheck.
wget -q "https://github.com/koalaman/shellcheck/releases/download/${SHELLCHECK_VERSION}/shellcheck-${SHELLCHECK_VERSION}.linux.x86_64.tar.xz" \
-O shellcheck.tar.xz
tar -xf shellcheck.tar.xz
mv "shellcheck-${SHELLCHECK_VERSION}/shellcheck" shellcheck
chmod +x shellcheck
# Download and setup problem matcher for shellcheck.
wget -q "https://raw.githubusercontent.com/lumaxis/shellcheck-problem-matchers/${SHELLCHECK_PROBLEM_MATCHERS_VERSION}/.github/shellcheck-gcc.json" \
-O shellcheck-problem-matcher.json
echo "::add-matcher::shellcheck-problem-matcher.json"
# Run shellcheck.
./shellcheck --norc --enable=all --format=gcc --color=never "${files[@]}"
- name: Set up pnpm
if: |
github.event_name == 'workflow_dispatch' ||
steps.changed-files.outputs.pnpm_any_changed == 'true'
uses: pnpm/action-setup@a3252b78c470c02df07e9d59298aecedc3ccdd6d # v3.0.0
- name: Set up Node.js
if: |
github.event_name == 'workflow_dispatch' ||
steps.changed-files.outputs.pnpm_any_changed == 'true'
uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4.3.0
with:
node-version: 18
cache: pnpm
- name: Install dependencies using pnpm
if: |
github.event_name == 'workflow_dispatch' ||
steps.changed-files.outputs.pnpm_any_changed == 'true'
run: pnpm install
- name: Check JavaScript/TypeScript scripts using pnpm
if: |
github.event_name == 'workflow_dispatch' ||
steps.changed-files.outputs.pnpm_any_changed == 'true'
run: pnpm run check
- name: Test build using pnpm
if: |
github.event_name == 'workflow_dispatch' ||
steps.changed-files.outputs.pnpm_any_changed == 'true'
run: pnpm run build