Skip to content

Commit 633ce80

Browse files
committed
Improve CI: use npm ci, cache npm deps, confirm npm run package was run
1 parent 937a467 commit 633ce80

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

.github/workflows/ci.yaml

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
name: CI
2+
23
on:
34
pull_request:
45
push:
@@ -7,6 +8,7 @@ on:
78
- 'v*'
89
env:
910
node_version: "20.x"
11+
FORCE_COLOR: 3
1012

1113
jobs:
1214
build: # make sure build/ci work properly
@@ -19,12 +21,17 @@ jobs:
1921
with:
2022
node-version: ${{ env.node_version }}
2123

22-
- name: npm install
23-
run: npm install
24+
- name: npm ci
25+
run: npm ci --prefer-offline
2426

25-
- name: npm run pack
27+
- name: npm run package
2628
run: npm run package
2729

30+
- name: Check for any changed files
31+
run: |
32+
[[ -z $(git status --untracked-files=no --porcelain) ]] || \
33+
(echo "::error title=npm run package::Files in the /dist directory shouldn't have changed. You forgot to run 'npm run package'." && exit 1)
34+
2835
audit:
2936
name: Audit
3037
runs-on: ubuntu-latest
@@ -36,6 +43,8 @@ jobs:
3643
with:
3744
node-version: ${{ env.node_version }}
3845

46+
# We don't need to install deps to audit them
47+
3948
- name: npm audit
4049
run: npm audit --audit-level=critical
4150

@@ -49,15 +58,16 @@ jobs:
4958
uses: actions/setup-node@v4
5059
with:
5160
node-version: ${{ env.node_version }}
61+
cache: npm
62+
cache-dependency-path: '**/package-lock.json'
5263

53-
- name: npm install
54-
run: npm install
64+
- name: npm ci
65+
run: npm ci --prefer-offline
5566

5667
- name: npm lint
5768
run: npm run lint
5869

59-
# When tests are added to the code uncomment
60-
# test-code:
70+
# test:
6171
# name: Test
6272
# runs-on: ubuntu-latest
6373
# steps:
@@ -67,9 +77,14 @@ jobs:
6777
# uses: actions/setup-node@v4
6878
# with:
6979
# node-version: ${{ env.node_version }}
80+
# cache: npm
81+
# cache-dependency-path: '**/package-lock.json'
7082
#
71-
# - name: npm install
72-
# run: npm install
83+
# - name: npm ci
84+
# run: npm ci --prefer-offline
7385
#
7486
# - name: npm test
7587
# run: npm test
88+
#
89+
# - name: Report test coverage to Codecov
90+
# uses: codecov/codecov-action@v3

0 commit comments

Comments
 (0)