Skip to content

Commit 910c508

Browse files
committed
ci: validate package-lock sync before dependency install
1 parent fa1a50b commit 910c508

File tree

4 files changed

+28
-1
lines changed

4 files changed

+28
-1
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
echo "Validating package-lock.json sync with package.json..."
5+
6+
log_file="$(mktemp)"
7+
8+
if npm ci --dry-run --ignore-scripts --no-audit --fund=false --loglevel=error >"$log_file" 2>&1; then
9+
echo "package-lock.json is in sync with package.json."
10+
rm -f "$log_file"
11+
exit 0
12+
fi
13+
14+
echo "::error::package-lock.json is out of sync with package.json. Run npm install locally and commit the updated package-lock.json."
15+
echo "npm ci --dry-run output (last 30 lines):"
16+
tail -n 30 "$log_file" || true
17+
rm -f "$log_file"
18+
exit 1

.github/workflows/lighthouse-ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ jobs:
2828
node-version: '20'
2929
cache: 'npm'
3030

31+
- name: Validate package-lock sync
32+
run: bash .github/scripts/validate-lockfile-sync.sh
33+
3134
- name: Install dependencies
3235
run: npm ci
3336

.github/workflows/pr-cypress-e2e.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ jobs:
2424
node-version: '20'
2525
cache: 'npm'
2626

27+
- name: Validate package-lock sync
28+
run: bash .github/scripts/validate-lockfile-sync.sh
29+
2730
- name: Run Cypress E2E Tests
2831
uses: cypress-io/github-action@v6
2932
with:
@@ -40,4 +43,4 @@ jobs:
4043
with:
4144
name: cypress-screenshots
4245
path: cypress/screenshots
43-
if-no-files-found: ignore
46+
if-no-files-found: ignore

.github/workflows/pr-jest-tests.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ jobs:
2626
with:
2727
node-version: '20'
2828

29+
- name: Validate package-lock sync
30+
run: bash .github/scripts/validate-lockfile-sync.sh
31+
2932
- name: Install Dependencies
3033
run: npm install
3134

0 commit comments

Comments
 (0)