Skip to content

Commit 1d6d023

Browse files
Optimize CI workflows for faster PR checks (#218)
Remove GitHub Actions Docker cache that was adding 60s overhead with poor hit rates. Add concurrency controls to prevent redundant workflow runs on rapid PR updates. Add E2E tests to release workflow to catch race conditions when multiple PRs merge to main. Skip E2E tests and preview publish for Version Packages PRs since changes are already tested in contributor PRs before merge.
1 parent 6aad8e4 commit 1d6d023

File tree

4 files changed

+78
-5
lines changed

4 files changed

+78
-5
lines changed

.github/workflows/claude-code-review.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ on:
1010
# - "src/**/*.js"
1111
# - "src/**/*.jsx"
1212

13+
concurrency:
14+
group: claude-review-${{ github.event.pull_request.number }}
15+
cancel-in-progress: true
16+
1317
jobs:
1418
claude-review:
1519
# Skip review for automated "Version Packages" PRs created by changesets

.github/workflows/pkg-pr-new.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,13 @@ on:
1212
- '!**/*.md'
1313
- '!.changeset/**'
1414

15+
concurrency:
16+
group: pkg-pr-new-${{ github.event.pull_request.number }}
17+
cancel-in-progress: true
18+
1519
jobs:
1620
publish-preview:
21+
if: ${{ !contains(github.event.pull_request.title, 'Version Packages') }}
1722
runs-on: ubuntu-latest
1823
timeout-minutes: 30
1924

.github/workflows/pullrequest.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ jobs:
7373
# E2E tests against deployed worker
7474
e2e-tests:
7575
needs: unit-tests
76+
if: ${{ !contains(github.event.pull_request.title, 'Version Packages') }}
7677
timeout-minutes: 30
7778
runs-on: ubuntu-latest
7879
steps:
@@ -123,10 +124,6 @@ jobs:
123124
platforms: linux/amd64 # Explicit single-arch for compatibility with release-amd64 cache
124125
load: true # Load into Docker daemon for local testing
125126
tags: cloudflare/sandbox-test:${{ needs.unit-tests.outputs.version || '0.0.0' }}
126-
cache-from: |
127-
type=gha,scope=pr-${{ github.event.pull_request.number }}-amd64
128-
type=gha,scope=release-amd64
129-
cache-to: type=gha,mode=max,scope=pr-${{ github.event.pull_request.number }}-amd64
130127
build-args: |
131128
SANDBOX_VERSION=${{ needs.unit-tests.outputs.version || '0.0.0' }}
132129

.github/workflows/release.yml

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,76 @@ jobs:
7171
- name: Run container unit tests
7272
run: npm run test -w @repo/sandbox-container
7373

74+
# E2E tests - runs on every push to main
75+
e2e-tests:
76+
needs: [unit-tests]
77+
if: ${{ github.repository_owner == 'cloudflare' }}
78+
runs-on: ubuntu-latest
79+
timeout-minutes: 30
80+
81+
steps:
82+
- uses: actions/checkout@v4
83+
84+
- uses: actions/setup-node@v4
85+
with:
86+
node-version: 24
87+
cache: 'npm'
88+
89+
- uses: oven-sh/setup-bun@v2
90+
with:
91+
bun-version: latest
92+
93+
- name: Install dependencies
94+
run: npm ci
95+
96+
- name: Build packages
97+
run: npm run build
98+
99+
- name: Generate wrangler config
100+
run: |
101+
cd tests/e2e/test-worker
102+
./generate-config.sh sandbox-e2e-test-worker-main
103+
104+
- name: Set up Docker Buildx
105+
uses: docker/setup-buildx-action@v3
106+
107+
- name: Build test worker Docker image
108+
uses: docker/build-push-action@v6
109+
with:
110+
context: .
111+
file: packages/sandbox/Dockerfile
112+
platforms: linux/amd64
113+
load: true
114+
tags: cloudflare/sandbox-test:${{ needs.unit-tests.outputs.version }}
115+
build-args: |
116+
SANDBOX_VERSION=${{ needs.unit-tests.outputs.version }}
117+
118+
- name: Deploy test worker
119+
uses: cloudflare/wrangler-action@v3
120+
with:
121+
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
122+
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
123+
workingDirectory: tests/e2e/test-worker
124+
command: deploy --name sandbox-e2e-test-worker-main
125+
126+
- name: Run E2E tests
127+
env:
128+
TEST_WORKER_URL: https://sandbox-e2e-test-worker-main.agents-b8a.workers.dev
129+
run: npm run test:e2e
130+
131+
- name: Cleanup test deployment
132+
if: always()
133+
continue-on-error: true
134+
run: |
135+
cd tests/e2e/test-worker
136+
../../../scripts/cleanup-test-deployment.sh sandbox-e2e-test-worker-main
137+
env:
138+
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
139+
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
140+
74141
# Release publish - only runs if changesets exist
75142
publish-release:
76-
needs: [unit-tests]
143+
needs: [unit-tests, e2e-tests]
77144
if: ${{ github.repository_owner == 'cloudflare' }}
78145
runs-on: ubuntu-latest
79146
timeout-minutes: 30

0 commit comments

Comments
 (0)