Skip to content

chore(env): Cache node dependencies#5096

Merged
SoloJacobs merged 1 commit intoprometheus:mainfrom
SoloJacobs:cache-node_modules
Mar 26, 2026
Merged

chore(env): Cache node dependencies#5096
SoloJacobs merged 1 commit intoprometheus:mainfrom
SoloJacobs:cache-node_modules

Conversation

@SoloJacobs
Copy link
Copy Markdown
Contributor

@SoloJacobs SoloJacobs commented Mar 15, 2026

Stacks on top of #5092

Pull Request Checklist

Which user-facing changes does this PR introduce?

NONE

Summary by CodeRabbit

  • Chores
    • Improved CI: unified Node toolchain selection, added npm cache handling and caching for faster runs, switched frontend install to reproducible install (npm ci), included Node version file in workflow scope, and streamlined build/test steps to reduce pipeline runtime and flakiness.

@TheMeier TheMeier self-requested a review March 18, 2026 19:48
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 22, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3b5f95eb-a8d1-4366-82c2-9aea3622531d

📥 Commits

Reviewing files that changed from the base of the PR and between 8d994b2 and 6d08e07.

📒 Files selected for processing (3)
  • .github/workflows/ci.yml
  • .github/workflows/ui-ci.yml
  • .nvmrc
🚧 Files skipped from review as they are similar to previous changes (2)
  • .github/workflows/ui-ci.yml
  • .github/workflows/ci.yml

📝 Walkthrough

Walkthrough

GitHub Actions workflows updated to use the repository root .nvmrc for Node version selection and improve npm caching. .github/workflows/ci.yml adds Node setup and explicit npm cache steps for frontend and test jobs; .github/workflows/ui-ci.yml switches Node source to the root .nvmrc and uses npm ci.

Changes

Cohort / File(s) Summary
CI Workflow npm caching & Node setup
.github/workflows/ci.yml
Adds actions/setup-node in test_frontend using ./.nvmrc with cache: 'npm'; test job computes npm config get cache and caches that directory with an OS-aware key based on **/package-lock.json. Existing make/promci steps remain.
UI CI Node source & install change
.github/workflows/ui-ci.yml
Workflow trigger now includes .nvmrc; Node version file changed from ./ui/mantine-ui/.nvmrc to ./.nvmrc; cache dependency paths include .nvmrc; npm install replaced by npm ci; build/test steps unchanged.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 I hopped in to tweak the flow,
Root .nvmrc helps Nodelet grow,
Caches tucked in cozy nests,
npm ci trims build-time pests,
A rabbit cheers — pipelines go!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive The description includes signed-off commits confirmation and best practices commitment, but is incomplete. It lacks details about what changes were made and their purpose, only noting the PR stacks on a related PR. Add a detailed explanation of the changes made (Node caching setup in CI workflows) and why they are beneficial (faster builds, reduced CI overhead).
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and accurately summarizes the main change: adding Node dependency caching to CI workflows for improved build performance.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (4)
ui/app/Makefile (1)

14-15: Complete the local toolchain dependency wiring.

node_modules only tracks package-lock.json, so incremental local builds will not rerun npm ci when package.json changes, and dev-server does not ensure dependencies exist before invoking npx.

♻️ Suggested fix
-node_modules: package-lock.json
+node_modules: package.json package-lock.json
	npm ci
-dev-server:
+dev-server: node_modules
	npx elm reactor

Also applies to: 35-36

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ui/app/Makefile` around lines 14 - 15, The Makefile's node_modules target
only depends on package-lock.json so changes to package.json won't re-run npm ci
and the dev-server target can run npx without ensuring dependencies; update the
node_modules target to depend on both package.json and package-lock.json (and
any other manifest like package-lock.json) and make the dev-server target (or
its recipe) depend on node_modules so npm ci is executed before any npx
invocation; modify the targets referenced as node_modules and dev-server (also
update the duplicate block at the other occurrence around lines 35-36) to add
these dependencies and ensure npm ci runs when manifests change.
.github/workflows/ci.yml (1)

60-65: Avoid calling npm before the job has finished bootstrapping Node.

This adds a new dependency on npm before prometheus/promci and setup_environment run. If those are what provide Node in this container job, cache setup fails first. Caching ~/.npm directly keeps the step independent of toolchain initialization.

♻️ Suggested simplification
-      - id: cache-paths
-        run: echo "npm-cache=$(npm config get cache)" >> $GITHUB_OUTPUT
       - uses: actions/cache@v4
         with:
-          path: ${{ steps.cache-paths.outputs.npm-cache }}
+          path: ~/.npm
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/ci.yml around lines 60 - 65, The cache step currently runs
the step "cache-paths" which executes `npm config get cache` before Node is
guaranteed to be installed; remove the dependency on invoking `npm` early by
eliminating the "cache-paths" step and hardcoding the cache path (for example
`~/.npm` or `${{ env.HOME }}/.npm`) in the `actions/cache@v4` `path` input so
the cache step does not require Node/npm to be present and only references the
`actions/cache@v4` step/output.
template/Makefile (2)

4-6: Minor inconsistency: command uses ./inline-css but dependency lists inline-css.js.

The target depends on inline-css.js, but the command runs node ./inline-css without the extension. Node.js will resolve this correctly, but for consistency and clarity, consider using the full filename.

♻️ Suggested fix for consistency
 email.tmpl: email.html inline-css.js node_modules
 	`@echo` ">> inline css for html email template"
-	node ./inline-css
+	node ./inline-css.js
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@template/Makefile` around lines 4 - 6, The Makefile target email.tmpl is
inconsistent: its dependency lists inline-css.js but the recipe runs node
./inline-css; update the recipe to run node ./inline-css.js (or alternatively
change the dependency to match the executed name) so the filename is consistent;
edit the email.tmpl target's recipe in the Makefile to call node ./inline-css.js
to match the inline-css.js dependency.

1-6: Consider adding a clean target for node_modules.

The static analysis tool flags missing all, clean, and test targets. While all and test may not apply to this specialized sub-Makefile, a clean target to remove node_modules would be useful for local development and could complement the parent Makefile's clean targets.

♻️ Optional addition
.PHONY: clean

clean:
	rm -rf node_modules
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@template/Makefile` around lines 1 - 6, Add a PHONY clean target to the
Makefile that removes node_modules so local developers and parent Makefile clean
flows can purge installed deps; modify the file containing the node_modules and
email.tmpl targets to define .PHONY: clean and a clean rule that rm -rf
node_modules, ensuring the target name is exactly clean to match tooling
expectations and does not conflict with the existing node_modules or email.tmpl
targets.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/ci.yml:
- Around line 62-67: Replace the mutable reference "uses: actions/cache@v4" with
an immutable commit SHA for the actions/cache action (i.e., "uses:
actions/cache@<commit-sha>") so the workflow is SHA-pinned like the other
actions; update the exact line containing uses: actions/cache@v4 and keep the
existing inputs (path: ${{ steps.cache-paths.outputs.npm-cache }}, key: ${{
runner.os }}-node-${{ hashFiles('**/package-lock.json') }}, restore-keys)
unchanged.

In @.github/workflows/ui-ci.yml:
- Around line 25-27: The pull_request path filter for the UI CI workflow
currently only matches ui/** so changes to the repo root .nvmrc (referenced by
the node-version-file: './.nvmrc' setting) will not trigger the job; update the
workflow's pull_request.paths array to include '/.nvmrc' (or an equivalent
pattern that matches the repo-root .nvmrc) so that changes to that file will run
the UI CI job.

In `@ui/app/CONTRIBUTING.md`:
- Around line 11-15: Update the CONTRIBUTING.md snippet that currently instructs
contributors to run "npm ci" so it explicitly directs them to run that command
from the ui/app directory (either by adding a note saying run the install
command inside ui/app or by showing the command preceded by changing into
ui/app), modifying the code block and/or adjacent sentence in CONTRIBUTING.md to
remove ambiguity about the required working directory.

---

Nitpick comments:
In @.github/workflows/ci.yml:
- Around line 60-65: The cache step currently runs the step "cache-paths" which
executes `npm config get cache` before Node is guaranteed to be installed;
remove the dependency on invoking `npm` early by eliminating the "cache-paths"
step and hardcoding the cache path (for example `~/.npm` or `${{ env.HOME
}}/.npm`) in the `actions/cache@v4` `path` input so the cache step does not
require Node/npm to be present and only references the `actions/cache@v4`
step/output.

In `@template/Makefile`:
- Around line 4-6: The Makefile target email.tmpl is inconsistent: its
dependency lists inline-css.js but the recipe runs node ./inline-css; update the
recipe to run node ./inline-css.js (or alternatively change the dependency to
match the executed name) so the filename is consistent; edit the email.tmpl
target's recipe in the Makefile to call node ./inline-css.js to match the
inline-css.js dependency.
- Around line 1-6: Add a PHONY clean target to the Makefile that removes
node_modules so local developers and parent Makefile clean flows can purge
installed deps; modify the file containing the node_modules and email.tmpl
targets to define .PHONY: clean and a clean rule that rm -rf node_modules,
ensuring the target name is exactly clean to match tooling expectations and does
not conflict with the existing node_modules or email.tmpl targets.

In `@ui/app/Makefile`:
- Around line 14-15: The Makefile's node_modules target only depends on
package-lock.json so changes to package.json won't re-run npm ci and the
dev-server target can run npx without ensuring dependencies; update the
node_modules target to depend on both package.json and package-lock.json (and
any other manifest like package-lock.json) and make the dev-server target (or
its recipe) depend on node_modules so npm ci is executed before any npx
invocation; modify the targets referenced as node_modules and dev-server (also
update the duplicate block at the other occurrence around lines 35-36) to add
these dependencies and ensure npm ci runs when manifests change.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 33d6c776-0002-4af9-8eb7-461d3e091491

📥 Commits

Reviewing files that changed from the base of the PR and between 5f3188d and f913955.

⛔ Files ignored due to path filters (2)
  • template/package-lock.json is excluded by !**/package-lock.json
  • ui/app/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (12)
  • .github/workflows/ci.yml
  • .github/workflows/ui-ci.yml
  • .nvmrc
  • template/.gitignore
  • template/Dockerfile
  • template/Makefile
  • template/package.json
  • ui/Dockerfile
  • ui/app/.gitignore
  • ui/app/CONTRIBUTING.md
  • ui/app/Makefile
  • ui/app/package.json
💤 Files with no reviewable changes (2)
  • template/Dockerfile
  • ui/Dockerfile

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
template/Makefile (2)

1-6: Consider adding a clean target for completeness.

The static analysis tool flagged missing standard phony targets. While all and test may not be relevant here, a clean target would be helpful for removing generated artifacts and node_modules:

♻️ Optional: Add clean target
+.PHONY: clean
+
 node_modules: package-lock.json
 	npm ci

 email.tmpl: email.html inline-css.js node_modules
 	`@echo` ">> inline css for html email template"
 	node ./inline-css
+
+clean:
+	rm -rf node_modules email.tmpl
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@template/Makefile` around lines 1 - 6, Add a standard clean target to the
Makefile: declare .PHONY: clean and implement clean to remove generated
artifacts and dependencies (e.g., delete node_modules and the generated email
template(s) produced by the email.tmpl rule such as email.tmpl and/or
email.html), so that running make clean tears down what node_modules and the
email.tmpl rule create.

1-2: Consider using a stamp file for more robust dependency tracking.

Using a directory (node_modules) as a Make target works for the common case, but directory timestamps can behave unexpectedly (e.g., if a file inside is modified without adding/removing entries). A stamp file pattern is more reliable:

♻️ Optional: Use stamp file pattern
-node_modules: package-lock.json
-	npm ci
+.node_modules.stamp: package-lock.json
+	npm ci
+	touch $@
+
+node_modules: .node_modules.stamp

Also add .node_modules.stamp to .gitignore if you adopt this pattern.

That said, the current implementation should work fine for the typical workflow where npm ci is triggered by package-lock.json changes.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@template/Makefile` around lines 1 - 2, The Makefile target currently uses the
directory target "node_modules" which can be unreliable; change the rule to use
a stamp file (e.g., ".node_modules.stamp") as the target: run "npm ci" then
update the stamp file so the target is a regular file dependency on
"package-lock.json"; also add the stamp file (".node_modules.stamp") to
.gitignore. Locate the existing "node_modules: package-lock.json" rule and
replace it with a pattern that creates and touches ".node_modules.stamp" after
running npm ci.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@template/Makefile`:
- Around line 1-6: Add a standard clean target to the Makefile: declare .PHONY:
clean and implement clean to remove generated artifacts and dependencies (e.g.,
delete node_modules and the generated email template(s) produced by the
email.tmpl rule such as email.tmpl and/or email.html), so that running make
clean tears down what node_modules and the email.tmpl rule create.
- Around line 1-2: The Makefile target currently uses the directory target
"node_modules" which can be unreliable; change the rule to use a stamp file
(e.g., ".node_modules.stamp") as the target: run "npm ci" then update the stamp
file so the target is a regular file dependency on "package-lock.json"; also add
the stamp file (".node_modules.stamp") to .gitignore. Locate the existing
"node_modules: package-lock.json" rule and replace it with a pattern that
creates and touches ".node_modules.stamp" after running npm ci.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4dab71c1-25bb-400e-9e4a-f77e65103f16

📥 Commits

Reviewing files that changed from the base of the PR and between f913955 and d3919c7.

⛔ Files ignored due to path filters (2)
  • template/package-lock.json is excluded by !**/package-lock.json
  • ui/app/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (12)
  • .github/workflows/ci.yml
  • .github/workflows/ui-ci.yml
  • .nvmrc
  • template/.gitignore
  • template/Dockerfile
  • template/Makefile
  • template/package.json
  • ui/Dockerfile
  • ui/app/.gitignore
  • ui/app/CONTRIBUTING.md
  • ui/app/Makefile
  • ui/app/package.json
💤 Files with no reviewable changes (2)
  • ui/Dockerfile
  • template/Dockerfile
✅ Files skipped from review due to trivial changes (5)
  • template/.gitignore
  • ui/app/.gitignore
  • ui/app/CONTRIBUTING.md
  • template/package.json
  • ui/app/package.json
🚧 Files skipped from review as they are similar to previous changes (3)
  • .github/workflows/ui-ci.yml
  • .github/workflows/ci.yml
  • ui/app/Makefile

DOCKER_RUN_CURRENT_USER := docker run --user=$(shell id -u $(USER)):$(shell id -g $(USER))
DOCKER_CMD := $(DOCKER_RUN_CURRENT_USER) --rm -t -v $(PWD):/app -w /app $(DOCKER_IMG)
node_modules: package-lock.json
npm ci
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some option of doing this in a container would still be lovely if possible... Can we allow both ways?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would stop someone from running the make command from inside a container? Would that work or are there other constraints that would not be satisfied by that approach?

@SoloJacobs SoloJacobs force-pushed the cache-node_modules branch 2 times, most recently from dd1f689 to 8d994b2 Compare March 26, 2026 19:30
This (together with moving to `npm ci`) should hopefully get
rid of this sporadic failure we have:

```
Errors occurred while compiling your configuration for elm-review. I need your
configuration to compile in order to know how to analyze your files. Hopefully
the compiler error below will help you figure out how to fix it.

make: *** [Makefile:32: test] Error 1
```

At the very least, this makes as better citizens of the internet.

Note: `nvm` picks up its configuration, even if running from a
subdirectory.

Signed-off-by: Solomon Jacobs <solomonjacobs@protonmail.com>
@SoloJacobs SoloJacobs merged commit 8a11f85 into prometheus:main Mar 26, 2026
8 checks passed
@SoloJacobs SoloJacobs deleted the cache-node_modules branch March 26, 2026 19:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants