From 4f58b92a31c0a32f04a24aac6180493802dc70e8 Mon Sep 17 00:00:00 2001 From: Colin Date: Fri, 23 Jan 2026 20:09:08 -0500 Subject: [PATCH] Fix lockfile-check: use temp dir to avoid node_modules race - Check mode now works in isolated temp directory - Removed dependency on test step (not needed) - No longer touches workspace node_modules --- .woodpecker.yml | 2 -- scripts/refresh-lockfile.sh | 19 +++++++++++-------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/.woodpecker.yml b/.woodpecker.yml index 7598ea7..d5dda1b 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -30,11 +30,9 @@ steps: lockfile-check: name: lockfile-check image: node:22-alpine - depends_on: [ "test" ] commands: - echo "nameserver 1.1.1.1" > /etc/resolv.conf - echo "nameserver 1.0.0.1" >> /etc/resolv.conf - - chmod +x scripts/refresh-lockfile.sh - sh scripts/refresh-lockfile.sh --check when: branch: main diff --git a/scripts/refresh-lockfile.sh b/scripts/refresh-lockfile.sh index ab661b5..5a48854 100755 --- a/scripts/refresh-lockfile.sh +++ b/scripts/refresh-lockfile.sh @@ -34,19 +34,22 @@ if [ -f package-lock.json ]; then OLD_HASH=$($HASH_CMD package-lock.json | cut -d' ' -f1) fi -# Clean and regenerate -rm -rf node_modules package-lock.json - if [ "$CHECK_MODE" = true ]; then - # CI mode: just generate lock file quickly - npm install --package-lock-only + # CI mode: generate fresh lock file in temp dir, compare hashes + TMPDIR=$(mktemp -d) + cp package.json "$TMPDIR/" + cd "$TMPDIR" + npm install --package-lock-only --ignore-scripts 2>/dev/null + NEW_HASH=$($HASH_CMD package-lock.json | cut -d' ' -f1) + cd - >/dev/null + rm -rf "$TMPDIR" else - # Local mode: full install + # Local mode: clean and regenerate with full install + rm -rf node_modules package-lock.json npm install + NEW_HASH=$($HASH_CMD package-lock.json | cut -d' ' -f1) fi -NEW_HASH=$($HASH_CMD package-lock.json | cut -d' ' -f1) - if [ "$OLD_HASH" = "$NEW_HASH" ]; then echo "✅ package-lock.json is up to date" exit 0