Skip to content

Commit 5e5b998

Browse files
mydeaclaude
andauthored
ci: Share the E2E test setup between build.yml and optional-e2e.yml (#25616)
Stacked on #25548. The optional E2E workflow copied most of \`job_e2e_tests\` from build.yml, so the two could drift apart. The steps that prepare a test application (runtimes, artifact downloads including the AWS ones, prepare/validate, copy to temp, pnpm overrides) now live in \`.github/actions/prepare-e2e-test\`. The action downloads from the current run by default; optional-e2e.yml passes the build.yml run ID and a token instead. Installing Playwright, building and running the test stay in the workflows: Playwright installs as a background step, and [a composite action cannot declare background steps](https://docs.github.com/actions/using-workflows/workflow-syntax-for-github-actions). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 219312d commit 5e5b998

3 files changed

Lines changed: 121 additions & 128 deletions

File tree

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
name: 'Prepare E2E test application'
2+
description:
3+
'Sets up the runtimes for an E2E test application, restores the built tarballs and copies the application to
4+
`runner.temp/test-application` with pnpm overrides pointing at the tarballs.'
5+
inputs:
6+
test-application:
7+
description: 'The name of the test application in dev-packages/e2e-tests/test-applications.'
8+
required: true
9+
runtime:
10+
description: 'The `runtime` of a runtime variant, see dev-packages/e2e-tests/README.md.'
11+
default: ''
12+
deno-version:
13+
description: 'The Deno version to install, if the application needs Deno.'
14+
default: 'v2.8.3'
15+
artifacts-run-id:
16+
description: 'The workflow run that uploaded the tarball artifacts. Defaults to the current run.'
17+
default: ''
18+
github-token:
19+
description: 'Token to download artifacts from `artifacts-run-id`. Only needed when that is set.'
20+
default: ''
21+
22+
runs:
23+
using: 'composite'
24+
steps:
25+
- name: Set up Node
26+
uses: actions/setup-node@v7
27+
with:
28+
node-version-file: 'dev-packages/e2e-tests/test-applications/${{ inputs.test-application }}/package.json'
29+
- name: Set up Bun
30+
if:
31+
inputs.test-application == 'node-exports-test-app' || contains(inputs.test-application, 'bun') || inputs.runtime
32+
== 'bun'
33+
uses: oven-sh/setup-bun@v2
34+
with:
35+
bun-version: '1.3.14'
36+
- name: Set up AWS SAM
37+
if: contains(inputs.test-application, 'aws-serverless')
38+
uses: aws-actions/setup-sam@v3
39+
with:
40+
use-installer: true
41+
token: ${{ github.token }}
42+
- name: Set up Deno
43+
if: contains(inputs.test-application, 'deno') || inputs.runtime == 'deno'
44+
uses: denoland/setup-deno@v2.0.5
45+
with:
46+
deno-version: ${{ inputs.deno-version || 'v2.8.3' }}
47+
# Keeps the pnpm store on the cache volume for the `pnpm install` of the test application
48+
- name: Mount pnpm store
49+
uses: ./.github/actions/mount-pnpm-store
50+
- name: Install pnpm
51+
uses: ./.github/actions/install-pnpm
52+
53+
# upload-artifact strips the path through the first `*`, so the tarballs are stored as <pkg>/*.tgz and have to be
54+
# downloaded into packages/.
55+
- name: Restore tarball artifacts
56+
uses: actions/download-artifact@v8
57+
with:
58+
name: build-tarball-output
59+
path: ${{ github.workspace }}/packages
60+
run-id: ${{ inputs.artifacts-run-id || github.run_id }}
61+
github-token: ${{ inputs.github-token }}
62+
63+
- name: Restore test-utils tarball artifact
64+
uses: actions/download-artifact@v8
65+
with:
66+
name: build-test-utils-tarball-output
67+
path: dev-packages/test-utils
68+
run-id: ${{ inputs.artifacts-run-id || github.run_id }}
69+
github-token: ${{ inputs.github-token }}
70+
71+
- name: Restore build layer artifacts
72+
if: contains(inputs.test-application, 'aws-serverless')
73+
uses: actions/download-artifact@v8
74+
with:
75+
name: build-layer-output
76+
path: ${{ github.workspace }}/packages/aws-serverless/build/aws/dist-serverless
77+
run-id: ${{ inputs.artifacts-run-id || github.run_id }}
78+
github-token: ${{ inputs.github-token }}
79+
80+
# The Lambda functions install the built workspace packages directly (see `src/stack.ts`).
81+
- name: Restore build artifacts
82+
if: inputs.test-application == 'aws-serverless'
83+
uses: actions/download-artifact@v8
84+
with:
85+
name: build-output
86+
run-id: ${{ inputs.artifacts-run-id || github.run_id }}
87+
github-token: ${{ inputs.github-token }}
88+
89+
- name: Prepare E2E tests
90+
run: pnpm run test:prepare
91+
shell: bash
92+
working-directory: dev-packages/e2e-tests
93+
94+
- name: Validate E2E test setup
95+
run: pnpm run test:validate
96+
shell: bash
97+
working-directory: dev-packages/e2e-tests
98+
99+
- name: Copy to temp
100+
run:
101+
pnpm run ci:copy-to-temp ./test-applications/${{ inputs.test-application }} ${{ runner.temp }}/test-application
102+
shell: bash
103+
working-directory: dev-packages/e2e-tests
104+
105+
- name: Add pnpm overrides
106+
run:
107+
pnpm run ci:pnpm-overrides ${{ runner.temp }}/test-application ${{ github.workspace
108+
}}/dev-packages/e2e-tests/packed
109+
shell: bash
110+
working-directory: dev-packages/e2e-tests

‎.github/workflows/build.yml‎

Lines changed: 5 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,79 +1108,12 @@ jobs:
11081108
uses: actions/checkout@v7
11091109
with:
11101110
ref: ${{ env.HEAD_COMMIT }}
1111-
- name: Set up Node
1112-
uses: actions/setup-node@v7
1113-
with:
1114-
node-version-file: 'dev-packages/e2e-tests/test-applications/${{ matrix.test-application }}/package.json'
1115-
- name: Set up Bun
1116-
if:
1117-
matrix.test-application == 'node-exports-test-app' || contains(matrix.test-application, 'bun') ||
1118-
matrix.runtime == 'bun'
1119-
uses: oven-sh/setup-bun@v2
1120-
with:
1121-
bun-version: '1.3.14'
1122-
- name: Set up AWS SAM
1123-
if: matrix.test-application == 'aws-serverless' || matrix.test-application == 'aws-serverless-layer'
1124-
uses: aws-actions/setup-sam@v3
1125-
with:
1126-
use-installer: true
1127-
token: ${{ secrets.GITHUB_TOKEN }}
1128-
- name: Set up Deno
1129-
if: contains(matrix.test-application, 'deno') || matrix.runtime == 'deno'
1130-
uses: denoland/setup-deno@v2.0.5
1131-
with:
1132-
deno-version: ${{ matrix.deno-version || 'v2.8.3' }}
1133-
# Keeps the pnpm store on the cache volume for the `pnpm install` of the test application
1134-
- name: Mount pnpm store
1135-
uses: ./.github/actions/mount-pnpm-store
1136-
- name: Install pnpm
1137-
uses: ./.github/actions/install-pnpm
1138-
1139-
- name: Restore tarball artifacts
1140-
uses: actions/download-artifact@v8
1141-
with:
1142-
name: build-tarball-output
1143-
path: ${{ env.TARBALL_ARTIFACT_DOWNLOAD_PATH }}
1144-
1145-
- name: Restore test-utils tarball artifact
1146-
uses: actions/download-artifact@v8
1111+
- name: Prepare E2E test application
1112+
uses: ./.github/actions/prepare-e2e-test
11471113
with:
1148-
name: build-test-utils-tarball-output
1149-
path: dev-packages/test-utils
1150-
1151-
- name: Restore build layer artifacts
1152-
uses: actions/download-artifact@v8
1153-
if: matrix.test-application == 'aws-serverless' || matrix.test-application == 'aws-serverless-layer'
1154-
with:
1155-
name: build-layer-output
1156-
path: ${{ env.BUILD_LAYER_PATH }}
1157-
1158-
# The Lambda functions install the built workspace packages directly (see `src/stack.ts`).
1159-
- name: Restore build artifacts
1160-
uses: actions/download-artifact@v8
1161-
if: matrix.test-application == 'aws-serverless'
1162-
with:
1163-
name: build-output
1164-
1165-
- name: Prepare e2e tests
1166-
run: pnpm run test:prepare
1167-
working-directory: dev-packages/e2e-tests
1168-
1169-
- name: Validate e2e tests setup
1170-
run: pnpm run test:validate
1171-
working-directory: dev-packages/e2e-tests
1172-
1173-
- name: Copy to temp
1174-
run:
1175-
pnpm run ci:copy-to-temp ./test-applications/${{ matrix.test-application }} ${{ runner.temp
1176-
}}/test-application
1177-
working-directory: dev-packages/e2e-tests
1178-
1179-
- name: Add pnpm overrides
1180-
run:
1181-
pnpm run ci:pnpm-overrides ${{ runner.temp }}/test-application ${{ github.workspace
1182-
}}/dev-packages/e2e-tests/packed
1183-
working-directory: dev-packages/e2e-tests
1114+
test-application: ${{ matrix.test-application }}
1115+
runtime: ${{ matrix.runtime }}
1116+
deno-version: ${{ matrix.deno-version }}
11841117

11851118
# Installs Playwright while the app builds. Keep it right before the build: the runner sets up a background
11861119
# composite action's steps from the job's shared `github` context, which fails with "Collection was modified" if

‎.github/workflows/optional-e2e.yml‎

Lines changed: 6 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ env:
3535
HEAD_COMMIT: ${{ inputs.commit }}
3636

3737
# See build.yml
38-
TARBALL_ARTIFACT_DOWNLOAD_PATH: ${{ github.workspace }}/packages
3938
DISABLE_V8_COMPILE_CACHE: '1'
4039

4140
jobs:
@@ -85,64 +84,15 @@ jobs:
8584
uses: actions/checkout@v7
8685
with:
8786
ref: ${{ env.HEAD_COMMIT }}
88-
- name: Set up Node
89-
uses: actions/setup-node@v7
87+
- name: Prepare E2E test application
88+
uses: ./.github/actions/prepare-e2e-test
9089
with:
91-
node-version-file: 'dev-packages/e2e-tests/test-applications/${{ matrix.test-application }}/package.json'
92-
- name: Set up Bun
93-
if:
94-
matrix.test-application == 'node-exports-test-app' || contains(matrix.test-application, 'bun') ||
95-
matrix.runtime == 'bun'
96-
uses: oven-sh/setup-bun@v2
97-
with:
98-
bun-version: '1.3.14'
99-
- name: Set up Deno
100-
if: contains(matrix.test-application, 'deno') || matrix.runtime == 'deno'
101-
uses: denoland/setup-deno@v2.0.5
102-
with:
103-
deno-version: ${{ matrix.deno-version || 'v2.8.3' }}
104-
# Keeps the pnpm store on the cache volume for the `pnpm install` of the test application
105-
- name: Mount pnpm store
106-
uses: ./.github/actions/mount-pnpm-store
107-
- name: Install pnpm
108-
uses: ./.github/actions/install-pnpm
109-
110-
- name: Restore tarball artifacts
111-
uses: actions/download-artifact@v8
112-
with:
113-
name: build-tarball-output
114-
path: ${{ env.TARBALL_ARTIFACT_DOWNLOAD_PATH }}
115-
run-id: ${{ inputs.build_run_id }}
90+
test-application: ${{ matrix.test-application }}
91+
runtime: ${{ matrix.runtime }}
92+
deno-version: ${{ matrix.deno-version }}
93+
artifacts-run-id: ${{ inputs.build_run_id }}
11694
github-token: ${{ github.token }}
11795

118-
- name: Restore test-utils tarball artifact
119-
uses: actions/download-artifact@v8
120-
with:
121-
name: build-test-utils-tarball-output
122-
path: dev-packages/test-utils
123-
run-id: ${{ inputs.build_run_id }}
124-
github-token: ${{ github.token }}
125-
126-
- name: Prepare E2E tests
127-
run: pnpm run test:prepare
128-
working-directory: dev-packages/e2e-tests
129-
130-
- name: Validate test setup
131-
run: pnpm run test:validate
132-
working-directory: dev-packages/e2e-tests
133-
134-
- name: Copy to temp
135-
run:
136-
pnpm run ci:copy-to-temp ./test-applications/${{ matrix.test-application }} ${{ runner.temp
137-
}}/test-application
138-
working-directory: dev-packages/e2e-tests
139-
140-
- name: Add pnpm overrides
141-
run:
142-
pnpm run ci:pnpm-overrides ${{ runner.temp }}/test-application ${{ github.workspace
143-
}}/dev-packages/e2e-tests/packed
144-
working-directory: dev-packages/e2e-tests
145-
14696
# Installs Playwright while the app builds. Keep it right before the build: the runner sets up a background
14797
# composite action's steps from the job's shared `github` context, which fails with "Collection was modified" if
14898
# a foreground step starts at that moment. Starting next to `download-artifact` also made it fail to read the event file.

0 commit comments

Comments
 (0)