Skip to content

feat: introduce injectable filesystem context - #169

Merged
V3RON merged 2 commits into
mainfrom
fix/issue-165
Aug 31, 2026
Merged

feat: introduce injectable filesystem context#169
V3RON merged 2 commits into
mainfrom
fix/issue-165

Conversation

@V3RON

@V3RON V3RON commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

What is this?

Introduces a filesystem context for Harness and applies it to the GitHub Action so its filesystem-dependent behavior can be tested without host temporary directories.

How does it work?

@react-native-harness/tools now provides an AsyncLocalStorage-backed context, a real Node filesystem default, and a memfs-powered testing helper. The GitHub Action establishes that context at its entrypoints, uses getFs() in migrated code, and keeps runner logic separately callable under an in-memory filesystem.

Why is this useful?

Action tests become hermetic and faster to reason about, while the new port creates a consistent path for incrementally migrating the remaining Harness filesystem usage.

Closes #165

@vercel

vercel Bot commented Jul 21, 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 31, 2026 9:10am

Request Review

@V3RON
V3RON merged commit c588adb into main Aug 31, 2026
6 checks passed
@V3RON
V3RON deleted the fix/issue-165 branch August 31, 2026 09:20
StasDoskalenko added a commit to StasDoskalenko/react-native-harness that referenced this pull request Aug 31, 2026
* refactor: run action steps through the harness CLI (callstackincubator#185)

## 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.

* feat: introduce injectable filesystem context (callstackincubator#169)

## What is this?

Introduces a filesystem context for Harness and applies it to the GitHub
Action so its filesystem-dependent behavior can be tested without host
temporary directories.

## How does it work?

`@react-native-harness/tools` now provides an AsyncLocalStorage-backed
context, a real Node filesystem default, and a memfs-powered testing
helper. The GitHub Action establishes that context at its entrypoints,
uses `getFs()` in migrated code, and keeps runner logic separately
callable under an in-memory filesystem.

## Why is this useful?

Action tests become hermetic and faster to reason about, while the new
port creates a consistent path for incrementally migrating the remaining
Harness filesystem usage.

Closes callstackincubator#165

* fix(cli): emit the ci projectRoot output with forward slashes

`harness ci load-config` writes `projectRoot=` to GITHUB_OUTPUT from a raw
`path.relative`, which is `apps\foo` on a Windows runner. The action feeds
that into `actions/cache` globs, `hashFiles()`, and a bash
`working-directory`, all of which want `/`. Normalize the separator.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

---------

Co-authored-by: Szymon Chmal <szymon@chmal.it>
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
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.

Introduce a FileSystem port injected via HarnessContext (AsyncLocalStorage) for hermetic tests

1 participant