Skip to content

Commit 3c890f3

Browse files
Refactor CI auditing
This changes how we audit (for vulns and deprecations) in CI from a reusable workflow to two self-contained workflows. I believe this makes the setup a bit more explicit (when each happens) at the cost of some duplication (which is counteracted by the removal of conditional logic) and potential audit failures if there are build failures (because there is no longer a `needs:` relation between the build job and audit jobs, tho at the same time only one of the audit jobs should actually be blocked by the build job).
1 parent 0725180 commit 3c890f3

File tree

4 files changed

+92
-35
lines changed

4 files changed

+92
-35
lines changed

.github/workflows/audit-dev.yml

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Audit
2+
on:
3+
pull_request:
4+
paths:
5+
- .github/workflows/audit-dev.yml
6+
- .grype.yml
7+
- .ndmrc
8+
- .syft.yml
9+
- .tool-versions
10+
- Containerfile
11+
- package-lock.json
12+
push:
13+
branches:
14+
- main
15+
schedule:
16+
- cron: 0 3 * * *
17+
workflow_dispatch: ~
18+
19+
permissions: read-all
20+
21+
jobs:
22+
deprecations:
23+
name: Deprecations
24+
runs-on: ubuntu-24.04
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
28+
with:
29+
persist-credentials: false
30+
- name: Install Node.js
31+
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
32+
with:
33+
cache: npm
34+
node-version-file: .nvmrc
35+
- name: Audit all deprecation warnings
36+
run: make audit-deprecations-npm
37+
image:
38+
name: Image
39+
runs-on: ubuntu-24.04
40+
strategy:
41+
fail-fast: false
42+
matrix:
43+
ref: ${{ fromJSON(inputs.refs) }}
44+
steps:
45+
- name: Checkout repository
46+
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
47+
id: checkout
48+
with:
49+
persist-credentials: false
50+
ref: ${{ matrix.ref }}
51+
- name: Install tooling
52+
uses: asdf-vm/actions/install@4f8f7939dd917fc656bb7c3575969a5988c28364 # v3.0.0
53+
run: echo "${GRYPERC}" | tee .grype.yml
54+
- name: Audit dependencies in container image
55+
run: make audit-vulnerabilities-image
56+
- name: Upload SBOM and vulnerability scan
57+
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
58+
if: ${{ failure() || success() }}
59+
with:
60+
if-no-files-found: error
61+
name: container-scan-${{ steps.checkout.outputs.commit }}
62+
path: |
63+
sbom-syft.json
64+
vulns.json
65+
npm:
66+
name: npm
67+
runs-on: ubuntu-24.04
68+
steps:
69+
- name: Checkout repository
70+
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
71+
with:
72+
persist-credentials: false
73+
- name: Install Node.js
74+
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
75+
with:
76+
cache: npm
77+
node-version-file: .nvmrc
78+
- name: Audit all npm dependencies
79+
run: make audit-vulnerabilities-npm
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
name: Audit
1+
name: Audit (release)
22
on:
3-
workflow_call:
4-
inputs:
5-
refs:
6-
default: |-
7-
[""]
8-
required: false
9-
type: string
3+
schedule:
4+
- cron: 0 3 * * *
5+
workflow_dispatch: ~
106

117
permissions: read-all
128

@@ -17,47 +13,43 @@ jobs:
1713
strategy:
1814
fail-fast: false
1915
matrix:
20-
ref: ${{ fromJSON(inputs.refs) }}
16+
ref:
17+
- v0
2118
steps:
2219
- name: Checkout repository
2320
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
2421
with:
25-
persist-credentials: false
2622
ref: ${{ matrix.ref }}
23+
persist-credentials: false
2724
- name: Install Node.js
2825
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
2926
with:
3027
cache: npm
3128
node-version-file: .nvmrc
3229
- name: Insert custom configuration
33-
if: ${{ startsWith(matrix.ref, 'v') }}
3430
env:
3531
NDMRC: ${{ vars.NDMRC }}
3632
run: echo "${NDMRC}" | tee .ndmrc
37-
- name: Audit all deprecation warnings
38-
if: ${{ !startsWith(matrix.ref, 'v') }}
39-
run: make audit-deprecations-npm
4033
- name: Audit production deprecation warnings
41-
if: ${{ startsWith(matrix.ref, 'v') }}
4234
run: make audit-deprecations-npm ARGS="--omit=dev"
4335
image:
4436
name: Image
4537
runs-on: ubuntu-24.04
4638
strategy:
4739
fail-fast: false
4840
matrix:
49-
ref: ${{ fromJSON(inputs.refs) }}
41+
ref:
42+
- v0
5043
steps:
5144
- name: Checkout repository
5245
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
5346
id: checkout
5447
with:
55-
persist-credentials: false
5648
ref: ${{ matrix.ref }}
49+
persist-credentials: false
5750
- name: Install tooling
5851
uses: asdf-vm/actions/install@4f8f7939dd917fc656bb7c3575969a5988c28364 # v3.0.0
5952
- name: Insert custom configuration
60-
if: ${{ startsWith(matrix.ref, 'v') }}
6153
env:
6254
GRYPERC: ${{ vars.GRYPERC }}
6355
run: echo "${GRYPERC}" | tee .grype.yml
@@ -78,21 +70,18 @@ jobs:
7870
strategy:
7971
fail-fast: false
8072
matrix:
81-
ref: ${{ fromJSON(inputs.refs) }}
73+
ref:
74+
- v0
8275
steps:
8376
- name: Checkout repository
8477
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
8578
with:
86-
persist-credentials: false
8779
ref: ${{ matrix.ref }}
80+
persist-credentials: false
8881
- name: Install Node.js
8982
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
9083
with:
9184
cache: npm
9285
node-version-file: .nvmrc
93-
- name: Audit all npm dependencies
94-
if: ${{ !startsWith(matrix.ref, 'v') }}
95-
run: make audit-vulnerabilities-npm
9686
- name: Audit production npm dependencies
97-
if: ${{ startsWith(matrix.ref, 'v') }}
9887
run: make audit-vulnerabilities-npm ARGS="--omit dev"

.github/workflows/check.yml

-5
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@ on:
99
permissions: read-all
1010

1111
jobs:
12-
audit:
13-
name: Audit
14-
uses: ./.github/workflows/reusable-audit.yml
15-
needs:
16-
- build
1712
build:
1813
name: Build with ${{ matrix.engine }}
1914
runs-on: ubuntu-24.04

.github/workflows/nightly.yml

-6
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,6 @@ on:
77
permissions: read-all
88

99
jobs:
10-
audit:
11-
name: Audit
12-
uses: ./.github/workflows/reusable-audit.yml
13-
with:
14-
refs: |-
15-
["main", "v0"]
1610
tooling:
1711
name: Update tooling
1812
runs-on: ubuntu-24.04

0 commit comments

Comments
 (0)