Skip to content

Commit f3acdf6

Browse files
ZvonimirZvonimir
authored andcommitted
Merge remote-tracking branch 'origin/v8/develop' into fix/approve-called-without-sufficient-TRAC
2 parents 761c17f + a09f3dc commit f3acdf6

1 file changed

Lines changed: 75 additions & 0 deletions

File tree

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Check Package Lock File
2+
3+
permissions:
4+
contents: read
5+
6+
concurrency:
7+
group: check-package-lock-${{ github.ref }}
8+
cancel-in-progress: true
9+
10+
on:
11+
push:
12+
branches:
13+
- main
14+
paths:
15+
- "package.json"
16+
- "package-lock.json"
17+
pull_request:
18+
branches:
19+
- "**"
20+
paths:
21+
- "package.json"
22+
- "package-lock.json"
23+
24+
jobs:
25+
verify-package-lock:
26+
name: Verify package-lock.json exists
27+
runs-on: ubuntu-latest
28+
timeout-minutes: 5
29+
30+
steps:
31+
- name: Checkout repository
32+
uses: actions/checkout@v4
33+
34+
- name: Check if package-lock.json exists
35+
run: |
36+
if [ ! -f "package-lock.json" ]; then
37+
echo "ERROR: package-lock.json file is missing from the repository"
38+
echo "This file is required to ensure consistent dependency versions across all environments"
39+
echo "Please ensure package-lock.json is committed with your changes"
40+
exit 1
41+
fi
42+
echo "SUCCESS: package-lock.json file is present"
43+
44+
- name: Verify package-lock.json is not empty
45+
run: |
46+
if [ ! -s "package-lock.json" ]; then
47+
echo "ERROR: package-lock.json file exists but is empty"
48+
echo "Please run 'npm install' to regenerate the lock file"
49+
exit 1
50+
fi
51+
echo "SUCCESS: package-lock.json file is valid and not empty"
52+
53+
- name: Setup Node.js
54+
uses: actions/setup-node@v4
55+
with:
56+
node-version: '20.x'
57+
58+
- name: Validate package-lock.json is valid and in sync
59+
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)