Skip to content

Conversation

@samjewell
Copy link

@samjewell samjewell commented Nov 24, 2025

Warning ⚠️ - developed by a GenAI agent

I (Sam) didn't write this code, nor this PR description! But I did get here from experiencing the issue myself, on a datasource I've been working on where Renovate has been making PRs. Each of those PRs was passing CI when I merged them, and yet I found drift on my package-lock.json file today.

What this PR does

This PR updates the frontend action to use CI-appropriate package manager commands that automatically enforce lock file consistency.

Changes

Updates actions/internal/plugins/frontend/pm.sh to use CI-optimized install commands:

  • npm: npm ci instead of npm install
  • pnpm: pnpm install --frozen-lockfile
  • yarn: yarn install --frozen-lockfile

Why this is needed

Currently, CI runs standard install commands (npm install, etc.) which don't fail if lock files are out of sync with package.json. This can allow drift to slip through, causing:

  • Inconsistent builds across environments
  • Silent dependency changes that weren't reviewed
  • Surprises when developers run install locally and see unexpected changes

Benefits of this approach

  1. Faster installs: CI commands skip dependency resolution since lock files should already be resolved
  2. Automatic drift detection: These commands fail if lock files don't match package.json
  3. Cleaner installs: npm ci removes node_modules first for a fresh install
  4. CI best practice: Using commands explicitly designed for CI environments
  5. No separate drift check needed: The install itself enforces consistency

Testing

The CI-appropriate commands are well-established best practices:

  • npm ci has been the recommended CI command since npm 5.7.0 (2018)
  • --frozen-lockfile is the standard flag for pnpm and yarn in CI

This change should be backward compatible - existing plugins will see faster, stricter installs.

Draft Status

Opening as draft to gather feedback on this approach before merging.

Changes the frontend action to use CI-optimized commands that automatically
fail if lock files are out of sync with package.json:

- npm: Use 'npm ci' instead of 'npm install'
- pnpm: Use 'pnpm install --frozen-lockfile'
- yarn: Use 'yarn install --frozen-lockfile'

Benefits:
- Faster installs (skips dependency resolution)
- Stricter checks (fails on lock file drift automatically)
- Cleaner installs (npm ci removes node_modules first)
- CI best practice (using commands designed for CI)

This prevents silent dependency changes and ensures consistent builds
across all environments without requiring a separate drift check step.
@CLAassistant
Copy link

CLAassistant commented Nov 24, 2025

CLA assistant check
All committers have signed the CLA.

@samjewell
Copy link
Author

Gonna close this.

the drift was just in Metadata updates like "peer": true" or engine requirements , not a real incompatibility I think

@samjewell samjewell closed this Nov 24, 2025
@github-project-automation github-project-automation bot moved this from 🔬 In review to 🚀 Shipped in Plugins Platform / Grafana Community Nov 24, 2025
@samjewell samjewell deleted the add-npm-ci-for-lockfile-drift branch November 24, 2025 12:57
@samjewell
Copy link
Author

After discussion with @jackw we decided that this PR will be replaced by #204 when it merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🚀 Shipped

Development

Successfully merging this pull request may close these issues.

2 participants