Skip to content

refactor: run action steps through the harness CLI - #185

Open
V3RON wants to merge 2 commits into
mainfrom
refactor/ci-scripts-into-cli
Open

refactor: run action steps through the harness CLI#185
V3RON wants to merge 2 commits into
mainfrom
refactor/ci-scripts-into-cli

Conversation

@V3RON

@V3RON V3RON commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

What is this?

The React Native Harness GitHub Action no longer ships bundled JavaScript. Its four Node steps — config loading and the three Metro cache planning steps — now run through the react-native-harness CLI already installed in the project under test, via a new harness ci <subcommand> command group.

Previously those steps ran prebuilt actions/shared/*.cjs files committed to the repository. Because the bundler inlined @react-native-harness/config, @react-native-harness/cache, and @react-native-harness/platform-android, any change to those packages rewrote roughly 628KB of committed output across four near-identical bundles. Contributors had to remember to rebuild and commit them, and regularly did not.

How does it work?

harness ci exposes load-config, plan-metro-restore, snapshot-metro, and plan-metro-save, each a direct move of the corresponding action script with its environment-variable and GITHUB_OUTPUT contract unchanged. The composite action calls them through the detected package manager, the same way it already invokes the CLI to run tests, so the scripts now come from the same package version that will run the suite rather than from a snapshot pinned to the action ref.

Two ordering changes support this. Package manager detection moves to the first step, since it is needed to invoke the CLI at all. A version guard follows it: on a CLI predating harness ci, the subcommand would fall through to the Jest CLI and be read as a test path pattern, so the action resolves the installed version up front and fails with an explicit message when it is missing or older than the release that introduces the command.

Because those steps now run with working-directory set to the project root, path handling is anchored to GITHUB_WORKSPACE rather than the current directory. INPUT_PROJECTROOT and the emitted projectRoot stay relative to the checkout root, which is what actions/cache, actions/upload-artifact, and hashFiles(...) resolve against regardless of a step's working directory.

The @react-native-harness/github-action package and the actions/ directory are removed, and its README moves to docs/github-action.md. packages/cli gains a test target it previously lacked, so the moved cache tests and the package's two existing suites now run in CI.

Why is this useful?

No generated code remains in the repository, so the rebuild-and-commit step disappears along with the class of pull request that silently ships a stale bundle. Changes to config parsing or cache key computation take effect through the normal package graph, and reviewers see the actual diff instead of hundreds of kilobytes of bundler output. Consumers of the action get scripts that match their installed Harness version, with a clear failure when the two drift apart.

Move the GitHub Action's four bundled Node scripts into
@react-native-harness/cli as `harness ci <subcommand>` and delete the
committed bundles.

The action now invokes the project's own installed react-native-harness
binary instead of prebuilt .cjs files checked into the repository, so
changes to config, cache, or platform-android no longer require
rebuilding and committing ~628KB of bundled output.
@vercel

vercel Bot commented Aug 13, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
react-native-harness Ready Ready Preview Aug 13, 2026 10:03am

Request Review

@V3RON
V3RON marked this pull request as draft August 13, 2026 09:54
@V3RON
V3RON marked this pull request as ready for review August 13, 2026 09:54
…n floor

The action's react-native-harness compatibility check used a hard-coded
MIN_VERSION compared via `sort -V`. That's unbootstrappable: it rejects the
very release that introduces `harness ci` (this repo's own workspace
packages carry the pre-release version until the release is cut), and
`sort -V` also ranks prereleases of a compatible release below it.

Replace the version floor with an explicit `harnessActionProtocol` marker
on the `react-native-harness` package.json, which the action reads via the
same `require.resolve` call it already makes. The two packages release in
lockstep via `workspace:*`, so the marker can't drift from the CLI it
describes, and the guard still fails fast (without ever invoking
`harness ci` itself) when a project's installed CLI predates the
CLI-based action.
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