Skip to content

Check for dead code in CI - #9246

Open
cknitt wants to merge 4 commits into
prune-flow-parserfrom
dead-code-ci
Open

cknitt wants to merge 4 commits into
prune-flow-parserfrom
dead-code-ci

Conversation

@cknitt

@cknitt cknitt commented Nov 6, 2026 •

Copy link
Copy Markdown
Member

Stacked on #9208. Runs make dead-code in CI, so new dead code in the OCaml sources fails the build.

reanalyze becomes a test dependency. rescript.opam (generated from dune-project) gets "reanalyze" {os != "win32" & with-test & = "2.27.0"}, alongside the other pinned test tools such as ocamlformat, ounit2 and js_of_ocaml.

  • 2.27.0 is the first release that can analyze several build trees together, and it's on opam (Package reanalyze.2.27.0 ocaml/opam-repository#31123).
  • opam install . --deps-only --with-test installs it for developers, and make dead-code finds reanalyze.exe on PATH.
  • It's not installed on Windows, like js_of_ocaml, because the check runs on Linux.

The CI step. It runs in the build-compiler job entry that builds the playground (ubuntu-26.04-arm, build_playground: true), right after the playground build. That entry has the browser-profile dependencies the check needs: it analyzes the native and the browser build trees together, so code used only by the playground counts as live.

  • CI's setup-ocaml installs reanalyze with the other --with-test dependencies into the cached switch. The cache key hashes the opam files, so the switch rebuilds once for this change.
  • The step itself is just opam exec -- make dead-code.

An earlier version of this PR ran opam install reanalyze in the job. That recompiled the whole restored switch (62 packages, about 4 minutes): opam misses the static switch's musl system package after the cache restore and treats it as a system change. As a declared dependency, reanalyze is installed when the switch is built, so that doesn't happen.

On this stack, make dead-code reports 0 issues with the opam-installed reanalyze 2.27.0.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Kbf3gLDo8mBJKpNE25WAwT

@cknitt
cknitt added this pull request to stack #9209 November 6, 2026 20:53
@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Changelog

🏠 Internal

  • Check in CI that reanalyze reports no dead code in the OCaml sources.

Semantic Diff

4 commits · Full page

Check for dead code in CI

7ac8758 · cknitt + Claude · Nov 06, 2026, 20:53 UTC

The build-compiler job that builds the playground now runs make dead-code after the playground build, so new dead code fails CI. It installs reanalyze 2.27.0, the first release that analyzes the native and the browser build trees together, from its tag until the opam-repository package is merged.

Build reanalyze from its tag instead of installing it with opam

08bd184 · cknitt + Claude · Nov 06, 2026, 21:27 UTC

In CI, opam install reanalyze recompiled the whole restored switch (62 packages, about 4 minutes): opam misses the musl system package of the static switch and treats that as a system change. The step now clones the v2.27.0 tag and builds reanalyze with dune in the existing switch (seconds), and passes it to make dead-code with REANALYZE. This also works unchanged once the opam package is published.

Run opam exec from the repository when building reanalyze

58ed055 · cknitt + Claude · Nov 06, 2026, 21:40 UTC

CI's opam switch is local to the repository, and opam exec finds it from the current directory: run from inside the reanalyze clone it failed with "No switch is currently set". opam exec now runs from the repository and changes into the clone itself.

Make reanalyze a test dependency

23d192d · cknitt + Claude · Nov 07, 2026, 16:01 UTC

reanalyze 2.27.0 is on opam now, so it becomes a pinned test dependency in rescript.opam like ocamlformat and ounit2 (not on Windows, like js_of_ocaml: the check runs on Linux). opam install . --deps-only --with-test installs it for developers, and CI builds it into the cached switch, so the dead-code step just runs make dead-code instead of building reanalyze from its tag.

@pkg-pr-new

pkg-pr-new Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

rescript

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

@rescript/belt

npm i https://pkg.pr.new/@rescript/belt@9246

@rescript/darwin-arm64

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

@rescript/linux-arm64

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

@rescript/linux-x64

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

@rescript/runtime

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

@rescript/win32-x64

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

commit: 23d192d

@cknitt

cknitt commented Nov 7, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-07T06:08:14.020114Z 2f2adec Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: 2f2adec1af

ℹ️ 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".

@cknitt
cknitt marked this pull request as ready for review November 7, 2026 06:16
@cknitt
cknitt requested a review from cristianoc November 7, 2026 06:16
@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

✅ Compiler benchmarks

Allocated words

In total: 338,768,729 → 338,768,729 (±0.00%).

None of the 257 benchmarks changed by 0.1% or more.

Instructions

In total: 9,675,830,640 → 9,675,830,640 (±0.00%).

None of the 33 benchmarks changed by 0.1% or more.

Pull request 23d192d compared with base dfc7836 in this run.

@cknitt
cknitt removed this pull request from stack #9209 November 8, 2026 18:11
@cknitt
cknitt added this pull request to stack #9268 November 8, 2026 18:11
cknitt and others added 4 commits November 8, 2026 18:11
The build-compiler job that builds the playground now runs make dead-code
after the playground build, so new dead code fails CI. It installs
reanalyze 2.27.0, the first release that analyzes the native and the
browser build trees together, from its tag until the opam-repository
package is merged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kbf3gLDo8mBJKpNE25WAwT
Signed-off-by: Christoph Knittel <ck@cca.io>
In CI, opam install reanalyze recompiled the whole restored switch (62
packages, about 4 minutes): opam misses the musl system package of the
static switch and treats that as a system change. The step now clones
the v2.27.0 tag and builds reanalyze with dune in the existing switch
(seconds), and passes it to make dead-code with REANALYZE. This also
works unchanged once the opam package is published.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kbf3gLDo8mBJKpNE25WAwT
Signed-off-by: Christoph Knittel <ck@cca.io>
CI's opam switch is local to the repository, and opam exec finds it from
the current directory: run from inside the reanalyze clone it failed
with "No switch is currently set". opam exec now runs from the
repository and changes into the clone itself.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kbf3gLDo8mBJKpNE25WAwT
Signed-off-by: Christoph Knittel <ck@cca.io>
reanalyze 2.27.0 is on opam now, so it becomes a pinned test dependency
in rescript.opam like ocamlformat and ounit2 (not on Windows, like
js_of_ocaml: the check runs on Linux). opam install . --deps-only
--with-test installs it for developers, and CI builds it into the cached
switch, so the dead-code step just runs make dead-code instead of
building reanalyze from its tag.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kbf3gLDo8mBJKpNE25WAwT
Signed-off-by: Christoph Knittel <ck@cca.io>

This branch has not been deployed

No deployments
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