Fix executor mutex race condition and memory leak (#258) #235
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release | |
| on: | |
| push: | |
| branches: | |
| - main | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| # Unit tests run in parallel | |
| unit-tests: | |
| if: ${{ github.repository_owner == 'cloudflare' }} | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| outputs: | |
| version: ${{ steps.get-version.outputs.version }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 24 | |
| cache: 'npm' | |
| - uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: latest | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build packages | |
| run: npm run build | |
| - name: Get package version | |
| id: get-version | |
| run: | | |
| VERSION=$(node -p "require('./packages/sandbox/package.json').version") | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| - name: Run sandbox unit tests | |
| run: | | |
| set +e | |
| timeout --preserve-status 30 npm run test -w @cloudflare/sandbox > sandbox_test.log 2>&1 | |
| EXIT_CODE=$? | |
| cat sandbox_test.log | |
| if grep -q "Test Files.*passed" sandbox_test.log && grep -q "Tests.*passed" sandbox_test.log; then | |
| echo "Sandbox tests passed" | |
| if [ $EXIT_CODE -eq 124 ] || [ $EXIT_CODE -eq 143 ]; then | |
| echo "::warning::Killed due to workerd shutdown hang (known vitest-pool-workers issue)" | |
| fi | |
| exit 0 | |
| else | |
| echo "Sandbox tests failed" | |
| exit 1 | |
| fi | |
| - name: Upload sandbox test logs | |
| if: failure() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: sandbox-test-logs-release | |
| path: sandbox_test.log | |
| retention-days: 7 | |
| - name: Run container unit tests | |
| run: npm run test -w @repo/sandbox-container | |
| # E2E tests - runs on every push to main | |
| e2e-tests: | |
| needs: [unit-tests] | |
| if: ${{ github.repository_owner == 'cloudflare' }} | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 30 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 24 | |
| cache: 'npm' | |
| - uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: latest | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build packages | |
| run: npm run build | |
| - name: Generate wrangler config | |
| run: | | |
| cd tests/e2e/test-worker | |
| ./generate-config.sh sandbox-e2e-test-worker-main | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build test worker Docker image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: packages/sandbox/Dockerfile | |
| platforms: linux/amd64 | |
| load: true | |
| tags: cloudflare/sandbox-test:${{ needs.unit-tests.outputs.version }} | |
| build-args: | | |
| SANDBOX_VERSION=${{ needs.unit-tests.outputs.version }} | |
| - name: Deploy test worker | |
| uses: cloudflare/wrangler-action@v3 | |
| with: | |
| apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
| accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
| workingDirectory: tests/e2e/test-worker | |
| command: deploy --name sandbox-e2e-test-worker-main | |
| - name: Run E2E tests | |
| env: | |
| TEST_WORKER_URL: https://sandbox-e2e-test-worker-main.agents-b8a.workers.dev | |
| run: npm run test:e2e | |
| - name: Cleanup test deployment | |
| if: always() | |
| continue-on-error: true | |
| run: | | |
| cd tests/e2e/test-worker | |
| ../../../scripts/cleanup-test-deployment.sh sandbox-e2e-test-worker-main | |
| env: | |
| CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
| CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
| # Release publish - only runs if changesets exist | |
| publish-release: | |
| needs: [unit-tests, e2e-tests] | |
| if: ${{ github.repository_owner == 'cloudflare' }} | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 30 | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 24 | |
| cache: 'npm' | |
| - uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: latest | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build packages | |
| run: npm run build | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
| password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: packages/sandbox/Dockerfile | |
| platforms: linux/amd64 | |
| push: true | |
| tags: cloudflare/sandbox:${{ needs.unit-tests.outputs.version }} | |
| cache-from: type=gha,scope=release | |
| cache-to: type=gha,mode=max,scope=release | |
| build-args: | | |
| SANDBOX_VERSION=${{ needs.unit-tests.outputs.version }} | |
| - id: changesets | |
| uses: changesets/action@v1 | |
| with: | |
| version: npx tsx .github/changeset-version.ts | |
| publish: npx tsx .github/changeset-publish.ts | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| NPM_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} | |
| NPM_PUBLISH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} |