Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .nx/version-plans/version-plan-1786612420017.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
__default__: minor
---

The `react-native-harness` CLI now exposes `harness ci <subcommand>`
(`load-config`, `plan-metro-restore`, `snapshot-metro`, `plan-metro-save`),
which the official GitHub Action uses to run its configuration and Metro
caching steps through your project's own installed CLI instead of bundled
scripts checked into the action. As a result, the action now requires a
`react-native-harness` install that supports this interface — it checks
this itself via a capability marker on the installed package rather than a
version number, and fails clearly when the installed CLI predates it. Keep
the action ref and the `react-native-harness` package version in sync, as
already recommended.
146 changes: 93 additions & 53 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,101 @@ inputs:
runs:
using: 'composite'
steps:
- name: Detect Package Manager
id: detect-pm
shell: bash
working-directory: ${{ inputs.projectRoot || '.' }}
run: |
if [ -n "${{ inputs.packageManager }}" ]; then
case "${{ inputs.packageManager }}" in
pnpm)
echo "manager=pnpm" >> $GITHUB_OUTPUT
echo "runner=pnpm exec " >> $GITHUB_OUTPUT
;;
yarn)
echo "manager=yarn" >> $GITHUB_OUTPUT
echo "runner=yarn " >> $GITHUB_OUTPUT
;;
bun)
echo "manager=bun" >> $GITHUB_OUTPUT
echo "runner=bunx " >> $GITHUB_OUTPUT
;;
deno)
echo "manager=deno" >> $GITHUB_OUTPUT
echo "runner=deno run -A npm:" >> $GITHUB_OUTPUT
;;
npm)
echo "manager=npm" >> $GITHUB_OUTPUT
echo "runner=npx " >> $GITHUB_OUTPUT
;;
*)
echo "Error: Unsupported packageManager '${{ inputs.packageManager }}'"
echo "Supported values: npm, yarn, pnpm, bun, deno"
exit 1
;;
esac
elif [ -f "pnpm-lock.yaml" ]; then
echo "manager=pnpm" >> $GITHUB_OUTPUT
echo "runner=pnpm exec " >> $GITHUB_OUTPUT
elif [ -f "yarn.lock" ]; then
echo "manager=yarn" >> $GITHUB_OUTPUT
echo "runner=yarn " >> $GITHUB_OUTPUT
elif [ -f "bun.lock" ] || [ -f "bun.lockb" ]; then
echo "manager=bun" >> $GITHUB_OUTPUT
echo "runner=bunx " >> $GITHUB_OUTPUT
elif [ -f "deno.lock" ]; then
echo "manager=deno" >> $GITHUB_OUTPUT
echo "runner=deno run -A npm:" >> $GITHUB_OUTPUT
else
echo "manager=npm" >> $GITHUB_OUTPUT
echo "runner=npx " >> $GITHUB_OUTPUT
fi
# This action invokes the project's own installed react-native-harness CLI
# (via `harness ci ...`) instead of shipping bundled scripts, so a CLI
# that predates that interface must be rejected before it's ever
# invoked. On such a CLI, `harness ci load-config` falls through to the
# Jest CLI and treats `ci` as a test path pattern -- silently running
# (zero) tests instead of failing -- so this guard must run before any
# `harness ci ...` step, and it must NOT probe support by invoking
# `harness ci` itself and inspecting the result.
- name: Verify react-native-harness supports this action's CLI interface
shell: bash
working-directory: ${{ inputs.projectRoot || '.' }}
run: |
# Support is detected via an explicit capability marker
# (harnessActionProtocol) on the 'react-native-harness' package.json,
# not by comparing version numbers: a version floor can't be
# satisfied by the very release that introduces the capability it
# requires (this repo's own pre-release CI installs the in-tree
# workspace version), and it would also reject semver-correct
# prereleases of that release. Bump REQUIRED_PROTOCOL only when a
# change to the `harness ci` contract is breaking for this action.
REQUIRED_PROTOCOL=1
INSTALLED_VERSION=$(node -p "require(require.resolve('react-native-harness/package.json',{paths:[process.cwd()]})).version" 2>/dev/null)
if [ -z "$INSTALLED_VERSION" ]; then
echo "Error: could not resolve the 'react-native-harness' package in this project."
echo "Pin the action ref to the same release as the installed react-native-harness package."
exit 1
fi
PROTOCOL=$(node -p "require(require.resolve('react-native-harness/package.json',{paths:[process.cwd()]})).harnessActionProtocol || 0" 2>/dev/null)
if [ -z "$PROTOCOL" ]; then
PROTOCOL=0
fi
if [ "$PROTOCOL" -lt "$REQUIRED_PROTOCOL" ]; then
echo "Error: the installed react-native-harness ($INSTALLED_VERSION) predates this action's CLI-based interface (harness ci)."
echo "Align the action ref with the react-native-harness version installed in this project."
exit 1
fi
- name: Load React Native Harness configuration
id: load-config
shell: bash
working-directory: ${{ inputs.projectRoot || '.' }}
env:
INPUT_RUNNER: ${{ inputs.runner }}
INPUT_PROJECTROOT: ${{ inputs.projectRoot }}
HARNESS_AVD_CACHING: ${{ inputs.cacheAvd }}
run: |
node ${{ github.action_path }}/actions/shared/index.cjs
${{ steps.detect-pm.outputs.runner }}react-native-harness ci load-config
- name: Verify native app input
if: fromJson(steps.load-config.outputs.config).platformId != 'web'
shell: bash
Expand All @@ -72,10 +158,11 @@ runs:
- name: Plan Metro cache restore
id: plan-metro-restore
shell: bash
working-directory: ${{ steps.load-config.outputs.projectRoot }}
env:
INPUT_PROJECTROOT: ${{ steps.load-config.outputs.projectRoot }}
run: |
node ${{ github.action_path }}/actions/shared/plan-restore.cjs
${{ steps.detect-pm.outputs.runner }}react-native-harness ci plan-metro-restore
- name: Restore Metro cache (.harness/cache/metro)
id: restore-metro
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
Expand All @@ -95,13 +182,14 @@ runs:
- name: Snapshot Metro cache
id: snapshot-metro-restore
shell: bash
working-directory: ${{ steps.load-config.outputs.projectRoot }}
env:
INPUT_PROJECTROOT: ${{ steps.load-config.outputs.projectRoot }}
# Empty on a cache miss; snapshot-metro.cjs uses it to report whether
# the Metro cache was actually restored and from which key.
METRO_RESTORED_KEY: ${{ steps.restore-metro.outputs.cache-matched-key }}
run: |
node ${{ github.action_path }}/actions/shared/snapshot-metro.cjs
${{ steps.detect-pm.outputs.runner }}react-native-harness ci snapshot-metro
- name: Restore Harness cache
id: cache-harness-restore
if: fromJson(steps.load-config.outputs.config).platformId == 'ios'
Expand Down Expand Up @@ -178,55 +266,6 @@ runs:
run: npx playwright install --with-deps chromium

# ── Shared ───────────────────────────────────────────────────────────────
- name: Detect Package Manager
id: detect-pm
shell: bash
working-directory: ${{ steps.load-config.outputs.projectRoot }}
run: |
if [ -n "${{ inputs.packageManager }}" ]; then
case "${{ inputs.packageManager }}" in
pnpm)
echo "manager=pnpm" >> $GITHUB_OUTPUT
echo "runner=pnpm exec " >> $GITHUB_OUTPUT
;;
yarn)
echo "manager=yarn" >> $GITHUB_OUTPUT
echo "runner=yarn " >> $GITHUB_OUTPUT
;;
bun)
echo "manager=bun" >> $GITHUB_OUTPUT
echo "runner=bunx " >> $GITHUB_OUTPUT
;;
deno)
echo "manager=deno" >> $GITHUB_OUTPUT
echo "runner=deno run -A npm:" >> $GITHUB_OUTPUT
;;
npm)
echo "manager=npm" >> $GITHUB_OUTPUT
echo "runner=npx " >> $GITHUB_OUTPUT
;;
*)
echo "Error: Unsupported packageManager '${{ inputs.packageManager }}'"
echo "Supported values: npm, yarn, pnpm, bun, deno"
exit 1
;;
esac
elif [ -f "pnpm-lock.yaml" ]; then
echo "manager=pnpm" >> $GITHUB_OUTPUT
echo "runner=pnpm exec " >> $GITHUB_OUTPUT
elif [ -f "yarn.lock" ]; then
echo "manager=yarn" >> $GITHUB_OUTPUT
echo "runner=yarn " >> $GITHUB_OUTPUT
elif [ -f "bun.lock" ] || [ -f "bun.lockb" ]; then
echo "manager=bun" >> $GITHUB_OUTPUT
echo "runner=bunx " >> $GITHUB_OUTPUT
elif [ -f "deno.lock" ]; then
echo "manager=deno" >> $GITHUB_OUTPUT
echo "runner=deno run -A npm:" >> $GITHUB_OUTPUT
else
echo "manager=npm" >> $GITHUB_OUTPUT
echo "runner=npx " >> $GITHUB_OUTPUT
fi
- name: Run E2E tests
id: run-tests
shell: bash
Expand Down Expand Up @@ -277,13 +316,14 @@ runs:
id: plan-metro-save
if: always()
shell: bash
working-directory: ${{ steps.load-config.outputs.projectRoot }}
env:
INPUT_PROJECTROOT: ${{ steps.load-config.outputs.projectRoot }}
INPUT_METRO_SNAPSHOT: ${{ steps.snapshot-metro-restore.outputs.metroSnapshot }}
INPUT_CACHESAVEPOLICY: ${{ inputs.cacheSavePolicy }}
IS_DEFAULT_BRANCH: ${{ github.ref_name == github.event.repository.default_branch }}
run: |
node ${{ github.action_path }}/actions/shared/plan-save.cjs
${{ steps.detect-pm.outputs.runner }}react-native-harness ci plan-metro-save
- name: Save Metro cache
if: always() && steps.plan-metro-save.outputs.metroShouldSave == 'true'
uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
Expand Down
174 changes: 0 additions & 174 deletions actions/android/action.yml

This file was deleted.

1 change: 0 additions & 1 deletion actions/android/index.cjs

This file was deleted.

Loading
Loading