Skip to content

Commit 8784109

Browse files
committed
ci(workflows): [ci] workflow improvements
Signed-off-by: Lexus Drumgold <[email protected]>
1 parent 679e092 commit 8784109

File tree

2 files changed

+76
-97
lines changed

2 files changed

+76
-97
lines changed

.github/infrastructure.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ branches:
2828
- context: commitlint
2929
- context: dependabot-dedupe
3030
- context: format
31-
- context: gitguardian
3231
- context: lint
3332
- context: spelling
3433
- context: test (24)

.github/workflows/ci.yml

Lines changed: 76 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
# - https://docs.github.com/webhooks-and-events/webhooks/webhook-events-and-payloads#pull_request
1313
# - https://docs.github.com/webhooks-and-events/webhooks/webhook-events-and-payloads#push
1414
# - https://docs.github.com/webhooks-and-events/webhooks/webhook-events-and-payloads#workflow_dispatch
15-
# - https://github.com/GitGuardian/ggshield-action
1615
# - https://github.com/actions/cache
1716
# - https://github.com/actions/cache/discussions/650
1817
# - https://github.com/actions/checkout
@@ -21,8 +20,13 @@
2120
# - https://github.com/actions/upload-artifact
2221
# - https://github.com/andstor/file-existence-action
2322
# - https://github.com/codecov/codecov-action
23+
# - https://github.com/codecov/test-results-action
24+
# - https://github.com/dprint/check
2425
# - https://github.com/flex-development/grease
26+
# - https://github.com/flex-development/jq-action
27+
# - https://github.com/flex-development/manver-action
2528
# - https://github.com/hmarr/debug-action
29+
# - https://github.com/streetsidesoftware/cspell-action
2630
# - https://yarnpkg.com/cli/pack
2731

2832
---
@@ -54,7 +58,7 @@ jobs:
5458
runs-on: ubuntu-latest
5559
outputs:
5660
cache-key: ${{ steps.cache-key.outputs.result }}
57-
version: ${{ steps.version.outputs.result }}
61+
version: ${{ steps.version.outputs.build }}
5862
steps:
5963
- id: debug
6064
name: Print environment variables and event payload
@@ -75,24 +79,20 @@ jobs:
7579
- id: dependencies
7680
name: Install dependencies
7781
env:
78-
YARN_ENABLE_IMMUTABLE_INSTALLS: ${{ github.actor != 'dependabot[bot]' }}
82+
YARN_ENABLE_IMMUTABLE_INSTALLS: ${{ github.actor != vars.DEPENDABOT }}
7983
run: yarn
8084
- id: cache-key
8185
name: Get cache key
82-
run: echo "result=${{ runner.os }}-${{ github.run_id }}" >>$GITHUB_OUTPUT
86+
run: echo "result=${{ hashFiles('yarn.lock') }}" >>$GITHUB_OUTPUT
8387
- id: cache
8488
name: Cache dependencies
8589
uses: actions/[email protected]
8690
with:
8791
key: ${{ steps.cache-key.outputs.result }}
8892
path: ${{ env.CACHE_PATH }}
89-
- id: version-manifest
90-
name: Get manifest version
91-
run: echo "result=$(jq .version package.json -r)" >>$GITHUB_OUTPUT
9293
- id: version
93-
name: Get build version
94-
run: |
95-
echo "result=${{ startsWith(github.head_ref || github.ref_name, 'release/') && steps.version-manifest.outputs.result || format('{0}+{1}', steps.version-manifest.outputs.result, github.event.pull_request.head.sha || github.sha) }}" >>$GITHUB_OUTPUT
94+
name: Extract version metadata
95+
uses: flex-development/[email protected]
9696
commitlint:
9797
needs: preflight
9898
runs-on: ubuntu-latest
@@ -121,31 +121,8 @@ jobs:
121121
name: Check commitlint status
122122
if: github.run_number != '1'
123123
run: yarn commitlint --from $SHA~${{ github.event.pull_request.commits || 1 }} --to $SHA
124-
gitguardian:
125-
needs: commitlint
126-
runs-on: ubuntu-latest
127-
steps:
128-
- id: checkout
129-
name: Checkout
130-
uses: actions/[email protected]
131-
with:
132-
fetch-depth: 0
133-
- id: scan
134-
name: Scan commits with ggshield
135-
uses: GitGuardian/[email protected]
136-
env:
137-
GITGUARDIAN_API_KEY: ${{ secrets.GITGUARDIAN_API_KEY }}
138-
GITHUB_DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
139-
GITHUB_PULL_BASE_SHA: ${{ github.event.pull_request.base.sha }}
140-
GITHUB_PUSH_BASE_SHA: ${{ github.event.base }}
141-
GITHUB_PUSH_BEFORE_SHA: ${{ github.event.before }}
142-
with:
143-
args: --all-policies --format sarif --show-secrets --with-incident-details --verbose
144124
format:
145-
needs:
146-
- commitlint
147-
- gitguardian
148-
- preflight
125+
needs: preflight
149126
runs-on: ubuntu-latest
150127
steps:
151128
- id: checkout
@@ -167,14 +144,21 @@ jobs:
167144
with:
168145
key: ${{ needs.preflight.outputs.cache-key }}
169146
path: ${{ env.CACHE_PATH }}
170-
- id: format
171-
name: Check code formatting
172-
run: yarn check:format
147+
- id: version
148+
name: Get dprint version
149+
uses: flex-development/[email protected]
150+
with:
151+
data: package.json
152+
filter: .devDependencies.dprint
153+
- id: check
154+
name: Check formatting
155+
uses: dprint/[email protected]
156+
with:
157+
args: --config-discovery=false --incremental=false --log-level=info
158+
config-path: .dprint.jsonc
159+
dprint-version: ${{ steps.version.outputs.result }}
173160
lint:
174-
needs:
175-
- commitlint
176-
- gitguardian
177-
- preflight
161+
needs: preflight
178162
runs-on: ubuntu-latest
179163
steps:
180164
- id: checkout
@@ -196,46 +180,36 @@ jobs:
196180
with:
197181
key: ${{ needs.preflight.outputs.cache-key }}
198182
path: ${{ env.CACHE_PATH }}
183+
- id: remark
184+
name: Check markdown files
185+
run: yarn remark
199186
- id: lint
200-
name: Check lint status
187+
name: Check eslint files
201188
run: yarn check:lint
202189
spelling:
203-
needs:
204-
- commitlint
205-
- gitguardian
206-
- preflight
207190
runs-on: ubuntu-latest
208191
steps:
209192
- id: checkout
210193
name: Checkout ${{ env.REF_NAME }}
211194
uses: actions/[email protected]
212195
with:
196+
fetch-depth: ${{ github.event_name == 'pull_request' && 0 || 1 }}
213197
persist-credentials: false
214198
ref: ${{ env.REF }}
215-
- id: node
216-
name: Setup Node.js
217-
uses: actions/[email protected]
218-
with:
219-
cache: yarn
220-
cache-dependency-path: yarn.lock
221-
node-version-file: .nvmrc
222-
- id: cache
223-
name: Restore dependencies cache
224-
uses: actions/[email protected]
225-
with:
226-
key: ${{ needs.preflight.outputs.cache-key }}
227-
path: ${{ env.CACHE_PATH }}
228199
- id: spelling
229200
name: Check spelling
230-
run: yarn check:spelling
201+
uses: streetsidesoftware/[email protected]
202+
with:
203+
check_dot_files: true
204+
config: .cspell.json
205+
incremental_files_only: ${{ github.event_name != 'pull_request' }}
206+
inline: error
207+
root: ${{ github.workspace }}
208+
treat_flagged_words_as_errors: true
209+
verbose: true
231210
typescript:
232-
needs:
233-
- commitlint
234-
- gitguardian
235-
- preflight
211+
needs: preflight
236212
runs-on: ubuntu-latest
237-
env:
238-
VITEST_REPORT: ./.vitest-reports/typecheck.blob.json
239213
steps:
240214
- id: checkout
241215
name: Checkout ${{ env.REF_NAME }}
@@ -256,34 +230,28 @@ jobs:
256230
with:
257231
key: ${{ needs.preflight.outputs.cache-key }}
258232
path: ${{ env.CACHE_PATH }}
259-
- id: print-version
260-
name: Print TypeScript version
261-
run: jq .devDependencies.typescript package.json -r
262233
- id: typecheck
263234
name: Run typecheck
264235
run: yarn typecheck
265236
- id: report
266237
name: Upload report
267238
uses: actions/[email protected]
268239
with:
269-
name: ${{ format('typecheck-{0}.blob.json', env.SHA) }}
270-
path: ${{ env.VITEST_REPORT }}
240+
name: ${{ format('{0}.typecheck.blob.json', env.SHA) }}
241+
path: ./.vitest-reports/typecheck.blob.json
271242
test:
272-
needs:
273-
- commitlint
274-
- gitguardian
275-
- preflight
243+
needs: preflight
276244
runs-on: ubuntu-latest
277245
strategy:
278246
fail-fast: false
279247
matrix:
280248
node-version:
281249
- 24
282250
env:
251+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
283252
COVERAGE_SUMMARY: ./coverage/coverage-summary.json
284253
NODE_NO_WARNINGS: 1
285254
PCT: .total.branches.pct + .total.functions.pct + .total.lines.pct + .total.statements.pct
286-
VITEST_REPORT: ./.vitest-reports/test.blob.json
287255
steps:
288256
- id: checkout
289257
name: Checkout ${{ env.REF_NAME }}
@@ -307,50 +275,62 @@ jobs:
307275
path: ${{ env.CACHE_PATH }}
308276
- id: test
309277
name: Run tests
310-
env:
311-
TZ: ${{ vars.TZ }}
312-
run: |
313-
yarn test:cov --coverage.thresholds.100=false \
314-
&& echo "coverage=$(jq '${{ env.PCT }}' ${{ env.COVERAGE_SUMMARY }} -r)" >>$GITHUB_OUTPUT
278+
run: yarn test:cov --coverage.thresholds.100=false
279+
- id: coverage
280+
name: Get coverage points
281+
uses: flex-development/[email protected]
282+
with:
283+
data: ${{ env.COVERAGE_SUMMARY }}
284+
filter: "'${{ env.PCT }}'"
315285
- id: pct
316286
name: Print coverage points
317-
run: echo ${{ steps.test.outputs.coverage }}
287+
run: echo ${{ steps.coverage.outputs.result }}
318288
- id: report
319289
name: Upload report
320290
uses: actions/[email protected]
321291
with:
322-
name: ${{ format('test-node{0}-{1}.blob.json', matrix.node-version, env.SHA) }}
323-
path: ${{ env.VITEST_REPORT }}
292+
name: ${{ format('{0}.{1}.blob.json', env.SHA, matrix.node-version) }}
293+
path: ./.vitest-reports/test.blob.json
324294
- id: coverage-summary
325295
name: Upload coverage summary
326296
uses: actions/[email protected]
327297
with:
328-
name: ${{ format('coverage-node{0}-{1}.json', matrix.node-version, env.SHA) }}
298+
name: ${{ format('{0}.{1}.coverage.json', env.SHA, matrix.node-version) }}
329299
path: ${{ env.COVERAGE_SUMMARY }}
330-
- id: codecov
300+
- id: codecov-results
301+
if: ${{ !cancelled() }}
302+
name: Upload test results to Codecov
303+
uses: codecov/[email protected]
304+
with:
305+
disable_search: true
306+
env_vars: GITHUB_JOB,GITHUB_REF_TYPE
307+
fail_ci_if_error: true
308+
files: ./__tests__/reports/junit.xml
309+
flags: ${{ format('node{0}', matrix.node-version) }}
310+
name: ${{ format('{0}.node{1}', env.SHA, matrix.node-version) }}
311+
override_branch: ${{ env.REF_NAME }}
312+
verbose: true
313+
- id: codecov-coverage
331314
name: Upload coverage report to Codecov
332315
uses: codecov/[email protected]
333316
with:
317+
disable_file_fixes: true
318+
disable_search: true
334319
env_vars: GITHUB_JOB,GITHUB_REF_TYPE
335320
fail_ci_if_error: true
336321
files: ./coverage/lcov.info
337322
flags: ${{ format('node{0}', matrix.node-version) }}
338-
name: ${{ format('node{0}-{1}', matrix.node-version, env.SHA) }}
339-
override_branch: ${{ env.REF }}
340-
override_build: ${{ github.run_id }}
341-
override_commit: ${{ env.SHA }}
342-
token: ${{ secrets.CODECOV_TOKEN }}
323+
name: ${{ format('{0}.node{1}', env.SHA, matrix.node-version) }}
324+
override_branch: ${{ env.REF_NAME }}
343325
verbose: true
344-
working-directory: ${{ github.workspace }}
345326
- id: coverage-failure
346-
if: steps.test.outputs.coverage != '400'
347-
name: Coverage threshold failure (${{ steps.test.outputs.coverage }})
327+
if: fromJson(steps.coverage.outputs.result) != 400
328+
name: Coverage threshold failure (${{ steps.coverage.outputs.result }})
348329
run: yarn test:cov:reports
349330
artifacts:
350331
needs:
351332
- commitlint
352333
- format
353-
- gitguardian
354334
- lint
355335
- preflight
356336
- spelling
@@ -384,7 +364,7 @@ jobs:
384364
path: ${{ env.CACHE_PATH }}
385365
- id: local-binaries
386366
name: Add local binaries to $PATH
387-
run: echo "$GITHUB_WORKSPACE/$CACHE_PATH/.bin" >> $GITHUB_PATH
367+
run: echo "$GITHUB_WORKSPACE/node_modules/.bin" >> $GITHUB_PATH
388368
- id: changelog
389369
name: Changelog preview
390370
env:

0 commit comments

Comments
 (0)