Skip to content

Commit 34516f3

Browse files
committed
chore: add workflow
1 parent 2c2c303 commit 34516f3

3 files changed

Lines changed: 101 additions & 1 deletion

File tree

.github/workflows/e2e-tests.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ on:
1212
- all
1313
- android
1414
- ios
15+
- web
1516
pull_request:
1617
types: [ready_for_review]
1718
branches:
@@ -189,3 +190,50 @@ jobs:
189190
app: ios/build/Build/Products/Debug-iphonesimulator/HarnessPlayground.app
190191
runner: ios
191192
projectRoot: apps/playground
193+
194+
e2e-web:
195+
name: E2E Web
196+
runs-on: ubuntu-22.04
197+
if: ${{ (github.event_name == 'pull_request' && github.event.pull_request.base.ref == 'main') || (github.event_name == 'workflow_dispatch' && (github.event.inputs.platform == 'all' || github.event.inputs.platform == 'web')) }}
198+
env:
199+
HARNESS_DEBUG: true
200+
201+
steps:
202+
- name: Checkout code
203+
uses: actions/checkout@v4
204+
with:
205+
ref: ${{ github.event.pull_request.head.sha || github.ref }}
206+
fetch-depth: 0
207+
208+
- name: Install pnpm
209+
uses: pnpm/action-setup@v2
210+
with:
211+
version: latest
212+
213+
- name: Setup Node.js
214+
uses: actions/setup-node@v4
215+
with:
216+
node-version: '24.10.0'
217+
cache: 'pnpm'
218+
219+
- name: Metro cache
220+
uses: actions/cache@v4
221+
with:
222+
path: apps/playground/node_modules/.cache/rn-harness/metro-cache
223+
key: metro-cache-${{ hashFiles('apps/playground/node_modules/.cache/rn-harness/metro-cache/**/*') }}
224+
restore-keys: |
225+
metro-cache
226+
227+
- name: Install dependencies
228+
run: |
229+
pnpm install
230+
231+
- name: Build packages
232+
run: |
233+
pnpm nx run-many -t build --projects="packages/*"
234+
235+
- name: Run React Native Harness
236+
uses: ./actions/web
237+
with:
238+
runner: chromium
239+
projectRoot: apps/playground

actions/web/action.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: React Native Harness for Web
2+
description: Run React Native Harness tests on Web
3+
inputs:
4+
runner:
5+
description: The runner to use
6+
required: true
7+
type: string
8+
projectRoot:
9+
description: The project root directory
10+
required: false
11+
type: string
12+
uploadVisualTestArtifacts:
13+
description: Whether to upload visual test diff and actual images as artifacts
14+
required: false
15+
type: boolean
16+
default: 'true'
17+
runs:
18+
using: 'composite'
19+
steps:
20+
- name: Load React Native Harness configuration
21+
id: load-config
22+
shell: bash
23+
env:
24+
INPUT_RUNNER: ${{ inputs.runner }}
25+
INPUT_PROJECTROOT: ${{ inputs.projectRoot }}
26+
run: |
27+
node ${{ github.action_path }}/../shared/index.cjs
28+
- name: Install Playwright Browsers
29+
shell: bash
30+
run: npx playwright install --with-deps chromium
31+
- name: Run E2E tests
32+
shell: bash
33+
working-directory: ${{ inputs.projectRoot }}
34+
run: |
35+
pnpm react-native-harness --harnessRunner ${{ inputs.runner }}
36+
- name: Upload visual test artifacts
37+
if: always() && inputs.uploadVisualTestArtifacts == 'true'
38+
uses: actions/upload-artifact@v4
39+
with:
40+
name: visual-test-diffs-chromium
41+
path: |
42+
${{ inputs.projectRoot }}/**/__image_snapshots__/**/*-diff.png
43+
${{ inputs.projectRoot }}/**/__image_snapshots__/**/*-actual.png
44+
if-no-files-found: ignore

apps/playground/rn-harness.config.mjs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ import {
1212
vegaPlatform,
1313
vegaEmulator,
1414
} from '@react-native-harness/platform-vega';
15-
import { webPlatform, chrome } from '@react-native-harness/platform-web';
15+
import {
16+
webPlatform,
17+
chromium,
18+
chrome,
19+
} from '@react-native-harness/platform-web';
1620

1721
const config = {
1822
entryPoint: './index.js',
@@ -53,6 +57,10 @@ const config = {
5357
name: 'web',
5458
browser: chrome('http://localhost:8081/index.html', { headless: false }),
5559
}),
60+
webPlatform({
61+
name: 'chromium',
62+
browser: chromium('http://localhost:8081/index.html', { headless: true }),
63+
}),
5664
],
5765
defaultRunner: 'android',
5866
bridgeTimeout: 120000,

0 commit comments

Comments
 (0)