Skip to content

Coverage CI: cache OPAM env, rewatch build, and coverage dune state#8434

Open
JonoPrest wants to merge 3 commits into
rescript-lang:masterfrom
JonoPrest:jono/coverage-workflow-cache
Open

Coverage CI: cache OPAM env, rewatch build, and coverage dune state#8434
JonoPrest wants to merge 3 commits into
rescript-lang:masterfrom
JonoPrest:jono/coverage-workflow-cache

Conversation

@JonoPrest
Copy link
Copy Markdown
Contributor

The OPAM install step on a cold runner often takes 10+ minutes and periodically times out / fails. This mirrors the cache strategy used by the main CI workflow: store the OPAM tree (incl. dev-setup deps like bisect_ppx), the rewatch cargo target, and the instrumented dune build state. PRs restore the latest master cache; only master pushes write to it, so PRs can't poison it.

The OPAM cache key is distinct from the main CI workflow's because coverage installs --with-dev-setup (for bisect_ppx) while CI only uses --with-test.

JonoPrest added 2 commits May 20, 2026 14:06
The OPAM install step on a cold runner often takes 10+ minutes and
periodically times out / fails. This mirrors the cache strategy used by
the main CI workflow: store the OPAM tree (incl. dev-setup deps like
bisect_ppx), the rewatch cargo target, and the instrumented dune build
state. PRs restore the latest master cache; only master pushes write to
it, so PRs can't poison it.

The OPAM cache key is distinct from the main CI workflow's because
coverage installs --with-dev-setup (for bisect_ppx) while CI only uses
--with-test.
@JonoPrest
Copy link
Copy Markdown
Contributor Author

@codex review

@JonoPrest JonoPrest requested a review from cknitt May 20, 2026 16:17
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 84b166265b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +121 to +123
- name: Save OPAM environment
if: steps.cache-opam-env.outputs.cache-hit != 'true'
uses: actions/cache/save@v5
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Restrict OPAM cache writes to master pushes

This save step runs on every cache miss, including pull_request runs, so it will upload PR-scoped caches. Per GitHub cache semantics, cache misses auto-create a cache, and caches created on pull_request are tied to refs/pull/.../merge and are not restorable by master or other PRs; that means repeated PR misses for a new key will create isolated entries that add storage pressure and can evict the shared branch cache, reducing hit rate and increasing future OPAM install time. Gate this save to push on refs/heads/master (as done for coverage build state) to keep the cache reusable.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 3a99217 — added github.event_name == 'push' && github.ref == 'refs/heads/master' to the save condition, matching the gating already used on the coverage-build-state cache. PRs still restore the latest master cache on hit; they just don't write new PR-scoped entries.

actions/cache/save@v5 on cache miss runs on every event including
pull_request, which creates PR-scoped cache entries tied to
refs/pull/<n>/merge. Those entries aren't restorable by master or
other PRs, so they consume storage and can evict the shared
master-saved entry, reducing hit rate.

Restrict the save to push events on refs/heads/master, matching the
pattern already used for the coverage-build-state cache. PRs still
benefit from full restore via the latest master cache; they just
don't write new entries.

Flagged by Codex review on rescript-lang#8434.
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 20, 2026

Open in StackBlitz

rescript

npm i https://pkg.pr.new/rescript@8434

@rescript/darwin-arm64

npm i https://pkg.pr.new/@rescript/darwin-arm64@8434

@rescript/darwin-x64

npm i https://pkg.pr.new/@rescript/darwin-x64@8434

@rescript/linux-arm64

npm i https://pkg.pr.new/@rescript/linux-arm64@8434

@rescript/linux-x64

npm i https://pkg.pr.new/@rescript/linux-x64@8434

@rescript/runtime

npm i https://pkg.pr.new/@rescript/runtime@8434

@rescript/win32-x64

npm i https://pkg.pr.new/@rescript/win32-x64@8434

commit: 3a99217

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.

1 participant