-
-
Notifications
You must be signed in to change notification settings - Fork 0
322 lines (274 loc) · 13.9 KB
/
lint.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
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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
# https://help.github.com/en/categories/automating-your-workflow-with-github-actions
name: "Lint"
on: # yamllint disable-line rule:truthy
# eslint-disable-next-line yml/no-empty-mapping-value
pull_request: # yamllint disable-line rule:empty-values
types: ["opened", "synchronize"]
merge_group: # yamllint disable-line rule:empty-values
concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: true
permissions:
contents: "read" # to fetch code (actions/checkout)
env:
NX_BRANCH: "${{ github.event.number }}"
NX_RUN_GROUP: "${{ github.run_id }}"
HEAD_REF: "${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref || github.ref_name }}"
HEAD_REPOSITORY: "${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name || github.repository }}"
jobs:
files-changed:
name: "Detect what files changed"
if: "github.repository == 'anolilab/semantic-release'"
runs-on: "ubuntu-22.04"
timeout-minutes: 3
# Map a step output to a job output
outputs:
frontend_lintable: "${{ steps.changes.outputs.frontend_lintable }}"
markdown_lintable: "${{ steps.changes.outputs.markdown_lintable }}"
yaml_lintable: "${{ steps.changes.outputs.yaml_lintable }}"
package_json_lintable: "${{ steps.changes.outputs.package_json_lintable }}"
steps:
- name: "Harden Runner"
uses: "step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6" # v2.8.1
with:
egress-policy: "audit"
- name: "Git checkout"
uses: "actions/checkout@d632683dd7b4114ad314bca15554477dd762a938" # v4.2.0
env:
GIT_COMMITTER_NAME: "GitHub Actions Shell"
GIT_AUTHOR_NAME: "GitHub Actions Shell"
EMAIL: "github-actions[bot]@users.noreply.github.com"
- name: "Check for file changes"
uses: "dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36" # v3.0.2
id: "changes"
with:
token: "${{ github.token }}"
filters: ".github/file-filters.yml"
eslint:
if: "needs.files-changed.outputs.frontend_lintable == 'true'"
needs: "files-changed"
name: "Lint (eslint)"
runs-on: "ubuntu-latest"
steps:
- name: "Harden Runner"
uses: "step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6" # v2.8.1
with:
egress-policy: "audit"
- name: "Git checkout ${{ env.HEAD_REPOSITORY }}:${{ env.HEAD_REF }}"
uses: "actions/checkout@d632683dd7b4114ad314bca15554477dd762a938" # v4.2.0
env:
GIT_COMMITTER_NAME: "GitHub Actions Shell"
GIT_AUTHOR_NAME: "GitHub Actions Shell"
EMAIL: "github-actions[bot]@users.noreply.github.com"
with:
# Number of commits to fetch. 0 indicates all history for all branches and tags.
# Pulls all commits (needed for NX)
fetch-depth: 0
- name: "Derive appropriate SHAs for base and head for `nx affected` commands"
id: "setSHAs"
uses: "nrwl/nx-set-shas@40f1175ceec169e68c9857c27aa7c5063692aa9a" # v4
- name: "Setup resources and environment"
id: "setup"
uses: "anolilab/workflows/step/setup@main"
with:
cache-prefix: "lint"
# Temporary solution until Nx solve this https://github.com/nrwl/nx/issues/22259
- name: "Get changed files"
id: "files"
uses: "tj-actions/changed-files@c65cd883420fd2eb864698a825fc4162dd94482c" # v44.5.7
with:
files_ignore_from_source_file: ".github/ignore-files-for-nx-affected.yml"
base_sha: "${{ steps.setSHAs.outputs.base }}"
separator: ","
- name: "Build"
run: "pnpm run build:affected:packages --files=${{ steps.files.outputs.all_changed_files }}"
- name: "lint eslint"
run: "pnpm run lint:affected:eslint --files=${{ steps.files.outputs.all_changed_files }}"
- name: "Prepare nx cache"
shell: "bash"
run: "tar -cf - .nx/cache | lz4 > /tmp/nx_cache.tar.lz4" # compress nx cache
package-json-lint:
if: "needs.files-changed.outputs.package_json_lintable == 'true'"
needs: "files-changed"
name: "Lint (package.json)"
runs-on: "ubuntu-latest"
steps:
- name: "Harden Runner"
uses: "step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6" # v2.8.1
with:
egress-policy: "audit"
- name: "Git checkout ${{ env.HEAD_REPOSITORY }}:${{ env.HEAD_REF }}"
uses: "actions/checkout@d632683dd7b4114ad314bca15554477dd762a938" # v4.2.0
env:
GIT_COMMITTER_NAME: "GitHub Actions Shell"
GIT_AUTHOR_NAME: "GitHub Actions Shell"
EMAIL: "github-actions[bot]@users.noreply.github.com"
with:
# Number of commits to fetch. 0 indicates all history for all branches and tags.
# Pulls all commits (needed for NX)
fetch-depth: 0
- name: "Derive appropriate SHAs for base and head for `nx affected` commands"
id: "setSHAs"
uses: "nrwl/nx-set-shas@40f1175ceec169e68c9857c27aa7c5063692aa9a" # v4
- name: "Setup resources and environment"
id: "setup"
uses: "anolilab/workflows/step/setup@main"
with:
cache-prefix: "lint"
# Temporary solution until Nx solve this https://github.com/nrwl/nx/issues/22259
- name: "Get changed files"
id: "files"
uses: "tj-actions/changed-files@c65cd883420fd2eb864698a825fc4162dd94482c" # v44.5.7
with:
files_ignore_from_source_file: ".github/ignore-files-for-nx-affected.yml"
base_sha: "${{ steps.setSHAs.outputs.base }}"
separator: ","
- name: "Build"
run: "pnpm run build:affected:packages --files=${{ steps.files.outputs.all_changed_files }}"
- name: "lint package.json"
run: "pnpm run lint:affected:package-json --files=${{ steps.files.outputs.all_changed_files }}"
- name: "Prepare nx cache"
shell: "bash"
run: "tar -cf - .nx/cache | lz4 > /tmp/nx_cache.tar.lz4" # compress nx cache
types-lint:
if: "needs.files-changed.outputs.frontend_lintable == 'true'"
needs: "files-changed"
name: "Lint (Typescript types)"
runs-on: "ubuntu-latest"
steps:
- name: "Harden Runner"
uses: "step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6" # v2.8.1
with:
egress-policy: "audit"
- name: "Git checkout ${{ env.HEAD_REPOSITORY }}:${{ env.HEAD_REF }}"
uses: "actions/checkout@d632683dd7b4114ad314bca15554477dd762a938" # v4.2.0
env:
GIT_COMMITTER_NAME: "GitHub Actions Shell"
GIT_AUTHOR_NAME: "GitHub Actions Shell"
EMAIL: "github-actions[bot]@users.noreply.github.com"
with:
# Number of commits to fetch. 0 indicates all history for all branches and tags.
# Pulls all commits (needed for NX)
fetch-depth: 0
- name: "Derive appropriate SHAs for base and head for `nx affected` commands"
id: "setSHAs"
uses: "nrwl/nx-set-shas@40f1175ceec169e68c9857c27aa7c5063692aa9a" # v4
- name: "Setup resources and environment"
id: "setup"
uses: "anolilab/workflows/step/setup@main"
with:
cache-prefix: "lint"
# Temporary solution until Nx solve this https://github.com/nrwl/nx/issues/22259
- name: "Get changed files"
id: "files"
uses: "tj-actions/changed-files@c65cd883420fd2eb864698a825fc4162dd94482c" # v44.5.7
with:
files_ignore_from_source_file: ".github/ignore-files-for-nx-affected.yml"
base_sha: "${{ steps.setSHAs.outputs.base }}"
separator: ","
- name: "Build"
run: "pnpm run build:affected:packages --files=${{ steps.files.outputs.all_changed_files }}"
- name: "lint typescript files"
run: "pnpm run lint:affected:types --files=${{ steps.files.outputs.all_changed_files }}"
- name: "Prepare nx cache"
shell: "bash"
run: "tar -cf - .nx/cache | lz4 > /tmp/nx_cache.tar.lz4" # compress nx cache
yaml-lint:
if: "needs.files-changed.outputs.yaml_lintable == 'true'"
needs: "files-changed"
name: "Lint (yaml)"
runs-on: "ubuntu-latest"
steps:
- name: "Harden Runner"
uses: "step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6" # v2.8.1
with:
egress-policy: "audit"
- name: "Git checkout ${{ env.HEAD_REPOSITORY }}:${{ env.HEAD_REF }}"
uses: "actions/checkout@d632683dd7b4114ad314bca15554477dd762a938" # v4.2.0
env:
GIT_COMMITTER_NAME: "GitHub Actions Shell"
GIT_AUTHOR_NAME: "GitHub Actions Shell"
EMAIL: "github-actions[bot]@users.noreply.github.com"
- name: "Lint YAML files"
uses: "ibiqlik/action-yamllint@2576378a8e339169678f9939646ee3ee325e845c" # v3.1.1
with:
config_file: ".yamllint.yaml"
file_or_dir: "."
strict: true
lint-workflows:
if: "needs.files-changed.outputs.yaml_lintable == 'true'"
needs: "files-changed"
runs-on: "ubuntu-latest"
steps:
- name: "Harden Runner"
uses: "step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6" # v2.8.1
with:
egress-policy: "audit"
- name: "Git checkout"
uses: "actions/checkout@d632683dd7b4114ad314bca15554477dd762a938" # v4.2.0
env:
GIT_COMMITTER_NAME: "GitHub Actions Shell"
GIT_AUTHOR_NAME: "GitHub Actions Shell"
EMAIL: "github-actions[bot]@users.noreply.github.com"
# From https://github.com/rhysd/actionlint/main/docs/usage.md#use-actionlint-on-github-actions
- name: "Lint github workflows"
run: |
bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
# The -ignore flag is used to ignore a specific error for a working solution in test.yml
./actionlint -color -shellcheck=""
markdown-lint:
if: "needs.files-changed.outputs.markdown_lintable == 'true'"
needs: "files-changed"
name: "Lint (markdown)"
runs-on: "ubuntu-latest"
steps:
- name: "Harden Runner"
uses: "step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6" # v2.8.1
with:
egress-policy: "audit"
- name: "Git checkout ${{ env.HEAD_REPOSITORY }}:${{ env.HEAD_REF }}"
uses: "actions/checkout@d632683dd7b4114ad314bca15554477dd762a938" # v4.2.0
env:
GIT_COMMITTER_NAME: "GitHub Actions Shell"
GIT_AUTHOR_NAME: "GitHub Actions Shell"
EMAIL: "github-actions[bot]@users.noreply.github.com"
- uses: "pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2" # v4.0.0
with:
run_install: false
- name: "Use Node.js 18.x"
uses: "actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6" # v4.0.4
with:
node-version: "18.x"
cache: "pnpm"
- name: "Verify the integrity of provenance attestations and registry signatures for installed dependencies"
run: "pnpm dlx audit-ci@^6 --config ./audit-ci.jsonc --report-type=summary"
- name: "Install packages"
run: "pnpm install --frozen-lockfile --prefer-offline"
env:
"PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD": 1
SKIP_CHECK: "true"
- name: "lint"
run: "pnpm run lint:text"
continue-on-error: true
- name: "skipping markdown lint for now"
run: "exit 0"
# This check runs once all dependant jobs have passed
# It symbolizes that all required Frontend checks have succesfully passed (Or skipped)
# This check is the only required GitHub check
test-required-check:
needs: ["files-changed", "eslint", "yaml-lint", "package-json-lint"] # TODO add "markdown-lint"
name: "Check Lint Run"
# This is necessary since a failed/skipped dependent job would cause this job to be skipped
if: "always()"
runs-on: "ubuntu-22.04"
steps:
# If any jobs we depend on fail, we will fail since this is a required check
# NOTE: A timeout is considered a failure
- name: "Harden Runner"
uses: "step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6" # v2.8.1
with:
egress-policy: "audit"
- name: "Check for failures"
if: "contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')"
run: |
echo "One of the dependent jobs have failed. You may need to re-run it." && exit 1