Skip to content

Commit c29a96a

Browse files
Update CI pipelines to use new tests (#100)
* Cleanup CI workflows * Remove duplicate test + e2e runs
1 parent ad3473e commit c29a96a

File tree

4 files changed

+196
-172
lines changed

4 files changed

+196
-172
lines changed

.github/workflows/prerelease.yml

Lines changed: 0 additions & 59 deletions
This file was deleted.

.github/workflows/pullrequest.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
name: Pull Request
22

3+
permissions:
4+
contents: read
5+
36
on:
47
pull_request:
58

9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
11+
cancel-in-progress: true
12+
613
jobs:
714
# Unit tests (client + container)
815
unit-tests:
@@ -44,6 +51,14 @@ jobs:
4451
exit 1
4552
fi
4653
54+
- name: Upload sandbox test logs
55+
if: failure()
56+
uses: actions/upload-artifact@v4
57+
with:
58+
name: sandbox-test-logs-unit
59+
path: sandbox_test.log
60+
retention-days: 7
61+
4762
- name: Run container unit tests
4863
run: npm run test -w @repo/sandbox-container
4964

.github/workflows/release.yml

Lines changed: 181 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,38 +5,204 @@ on:
55
branches:
66
- main
77

8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.ref }}
10+
cancel-in-progress: true
11+
812
jobs:
9-
release:
13+
# Unit tests run in parallel
14+
unit-tests:
15+
if: ${{ github.repository_owner == 'cloudflare' }}
16+
runs-on: ubuntu-latest
17+
timeout-minutes: 10
18+
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- uses: actions/setup-node@v4
23+
with:
24+
node-version: 24
25+
cache: "npm"
26+
27+
- uses: oven-sh/setup-bun@v2
28+
with:
29+
bun-version: latest
30+
31+
- name: Install dependencies
32+
run: npm ci
33+
34+
- name: Build packages
35+
run: npm run build
36+
37+
- name: Run sandbox unit tests
38+
run: |
39+
set +e
40+
timeout --preserve-status 30 npm run test -w @cloudflare/sandbox > sandbox_test.log 2>&1
41+
EXIT_CODE=$?
42+
cat sandbox_test.log
43+
44+
if grep -q "Test Files.*passed" sandbox_test.log && grep -q "Tests.*passed" sandbox_test.log; then
45+
echo "Sandbox tests passed"
46+
if [ $EXIT_CODE -eq 124 ] || [ $EXIT_CODE -eq 143 ]; then
47+
echo "::warning::Killed due to workerd shutdown hang (known vitest-pool-workers issue)"
48+
fi
49+
exit 0
50+
else
51+
echo "Sandbox tests failed"
52+
exit 1
53+
fi
54+
55+
- name: Upload sandbox test logs
56+
if: failure()
57+
uses: actions/upload-artifact@v4
58+
with:
59+
name: sandbox-test-logs-release
60+
path: sandbox_test.log
61+
retention-days: 7
62+
63+
- name: Run container unit tests
64+
run: npm run test -w @repo/sandbox-container
65+
66+
# E2E tests run in parallel with unit tests
67+
e2e-tests:
68+
if: ${{ github.repository_owner == 'cloudflare' }}
69+
runs-on: ubuntu-latest
70+
timeout-minutes: 30
71+
72+
steps:
73+
- uses: actions/checkout@v4
74+
75+
- uses: actions/setup-node@v4
76+
with:
77+
node-version: 24
78+
cache: "npm"
79+
80+
- uses: oven-sh/setup-bun@v2
81+
with:
82+
bun-version: latest
83+
84+
- name: Install dependencies
85+
run: npm ci
86+
87+
- name: Build packages
88+
run: npm run build
89+
90+
- name: Build test worker Docker image
91+
run: npm run docker:local -w @cloudflare/sandbox
92+
93+
- name: Set worker name
94+
id: worker-name
95+
run: |
96+
echo "worker_name=sandbox-e2e-test-worker-release-${{ github.run_number }}" >> $GITHUB_OUTPUT
97+
98+
- name: Deploy test worker
99+
uses: cloudflare/wrangler-action@v3
100+
with:
101+
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
102+
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
103+
command: deploy --name ${{ steps.worker-name.outputs.worker_name }}
104+
workingDirectory: tests/e2e/test-worker
105+
106+
- name: Get deployment URL
107+
id: get-url
108+
run: |
109+
echo "worker_url=https://${{ steps.worker-name.outputs.worker_name }}.agents-b8a.workers.dev" >> $GITHUB_OUTPUT
110+
111+
- name: Run E2E tests
112+
run: npx vitest run --config vitest.e2e.config.ts
113+
env:
114+
TEST_WORKER_URL: ${{ steps.get-url.outputs.worker_url }}
115+
CI: true
116+
117+
- name: Cleanup test deployment
118+
if: always()
119+
continue-on-error: true
120+
run: |
121+
npx wrangler delete --name ${{ steps.worker-name.outputs.worker_name }} || echo "Worker already deleted or doesn't exist"
122+
working-directory: tests/e2e/test-worker
123+
env:
124+
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
125+
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
126+
127+
# Prerelease publish - always runs after tests pass
128+
publish-prerelease:
129+
needs: [unit-tests, e2e-tests]
130+
if: ${{ github.repository_owner == 'cloudflare' }}
131+
runs-on: ubuntu-latest
132+
timeout-minutes: 20
10133
permissions:
11-
contents: write
134+
contents: read
135+
136+
steps:
137+
- uses: actions/checkout@v4
12138

139+
- uses: actions/setup-node@v4
140+
with:
141+
node-version: 24
142+
cache: "npm"
143+
144+
- uses: oven-sh/setup-bun@v2
145+
with:
146+
bun-version: latest
147+
148+
- name: Install dependencies
149+
run: npm ci
150+
151+
- name: Build packages
152+
run: npm run build
153+
154+
- name: Modify package.json version
155+
run: npx tsx .github/version-script.ts
156+
157+
- name: Resolve workspace dependencies
158+
run: npx tsx .github/resolve-workspace-versions.ts
159+
160+
- name: Set up Docker Buildx
161+
uses: docker/setup-buildx-action@v3
162+
163+
- name: Login to Docker Hub
164+
uses: docker/login-action@v3
165+
with:
166+
username: ${{ secrets.DOCKER_HUB_USERNAME }}
167+
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
168+
169+
- name: Build and push Docker image (beta)
170+
run: npm run docker:publish:beta --workspace=@cloudflare/sandbox
171+
172+
- name: Publish to npm with beta tag
173+
run: npm publish --tag beta --access public
174+
env:
175+
NPM_PUBLISH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
176+
working-directory: packages/sandbox
177+
178+
# Release publish - only runs if changesets exist
179+
publish-release:
180+
needs: [unit-tests, e2e-tests]
13181
if: ${{ github.repository_owner == 'cloudflare' }}
14-
runs-on: ubuntu-24.04
182+
runs-on: ubuntu-latest
183+
timeout-minutes: 20
184+
permissions:
185+
contents: write
15186

16187
steps:
17188
- uses: actions/checkout@v4
18189
with:
19-
fetch-depth: 1
190+
fetch-depth: 0
20191

21192
- uses: actions/setup-node@v4
22193
with:
23194
node-version: 24
24195
cache: "npm"
25196

197+
- uses: oven-sh/setup-bun@v2
198+
with:
199+
bun-version: latest
200+
26201
- name: Install dependencies
27-
run: npm install
28-
29-
- name: Run type checking
30-
run: npm run typecheck
31-
32-
- name: Run linting
33-
run: npm run check
34-
202+
run: npm ci
203+
35204
- name: Build packages
36205
run: npm run build
37-
38-
- name: Run full test suite
39-
run: npm test
40206

41207
- name: Set up Docker Buildx
42208
uses: docker/setup-buildx-action@v3

0 commit comments

Comments
 (0)