Skip to content

Commit a09f3dc

Browse files
authored
Merge pull request #271 from OriginTrail/package-lock-check
update package-lock test
2 parents 99c513e + 4030151 commit a09f3dc

1 file changed

Lines changed: 25 additions & 3 deletions

File tree

.github/workflows/check-package-lock.yml

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,16 @@ concurrency:
1010
on:
1111
push:
1212
branches:
13-
- main # Run on push to main branch only
13+
- main
14+
paths:
15+
- "package.json"
16+
- "package-lock.json"
1417
pull_request:
1518
branches:
16-
- "**" # Run on PR to any branch
19+
- "**"
20+
paths:
21+
- "package.json"
22+
- "package-lock.json"
1723

1824
jobs:
1925
verify-package-lock:
@@ -47,7 +53,23 @@ jobs:
4753
- name: Setup Node.js
4854
uses: actions/setup-node@v4
4955
with:
50-
node-version: '16.x'
56+
node-version: '20.x'
5157

5258
- name: Validate package-lock.json is valid and in sync
5359
run: npm ci --dry-run --ignore-scripts
60+
61+
- name: Check package-lock.json is up to date with package.json
62+
if: github.event_name == 'pull_request'
63+
run: |
64+
# Regenerate the lock file from the current package.json without
65+
# installing node_modules, then check if it differs from what was committed.
66+
cp package-lock.json package-lock.json.bak
67+
npm install --package-lock-only --ignore-scripts
68+
69+
if ! diff -q package-lock.json package-lock.json.bak > /dev/null 2>&1; then
70+
echo "ERROR: package-lock.json is out of date with package.json"
71+
echo "Please run 'npm install' and commit the updated package-lock.json"
72+
exit 1
73+
fi
74+
75+
echo "SUCCESS: package-lock.json is up to date"

0 commit comments

Comments
 (0)