feat: cloud-based e2e tests with Terraform + wrangler deploy#152
Merged
andreasjansson merged 2 commits intomainfrom Feb 3, 2026
Merged
feat: cloud-based e2e tests with Terraform + wrangler deploy#152andreasjansson merged 2 commits intomainfrom
andreasjansson merged 2 commits intomainfrom
Conversation
Deploy real workers to Cloudflare infrastructure for e2e testing, replacing local wrangler dev. This catches issues that local testing can't: R2 bucket mounting, container cold starts, Access auth flows. ## Infrastructure (test/e2e/fixture/server/) - Terraform: Creates R2 bucket + service token (unique per test run) - create-access-app: Creates Access app via API after worker deploy - deploy: Generates dynamic wrangler config for unique container names - start/stop: Orchestrate full lifecycle with proper cleanup ## Access protection - Access app protects worker URL externally - Service Auth policy for automated tests (service token headers) - Allow policy for @cloudflare.com emails (manual debugging) - Playwright sets headers via page.context().setExtraHTTPHeaders() ## Test flow 1. Terraform creates R2 bucket + service token 2. Deploy worker with unique name (timestamp + random) 3. Create Access app via API (must be after worker exists) 4. Start browser, navigate to worker, wait for 'Pairing required' 5. Video captures loading screen through full test 6. Teardown: Access app → worker → R2 bucket → service token ## Code changes - src/config.ts: getR2BucketName() for configurable bucket - src/gateway/r2.ts: Uses configurable bucket name - src/types.ts: Added R2_BUCKET_NAME to MoltbotEnv ## GitHub Actions - Updated workflow with Terraform setup - Infrastructure secrets use E2E_ prefix - E2E_TEST_RUN_ID uses run_id + matrix name for isolation ## Documentation - test/e2e/README.md: Comprehensive architecture docs - test/e2e/.dev.vars.example: Credential setup instructions Required repo secrets: - E2E_CLOUDFLARE_API_TOKEN, E2E_CF_ACCOUNT_ID, E2E_WORKERS_SUBDOMAIN - E2E_CF_ACCESS_TEAM_DOMAIN, E2E_R2_ACCESS_KEY_ID, E2E_R2_SECRET_ACCESS_KEY - AI_GATEWAY_API_KEY, AI_GATEWAY_BASE_URL (existing, for chat tests)
cc0f7f1 to
7c7cfb6
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Deploy real workers to Cloudflare infrastructure for e2e testing, replacing local wrangler dev. This catches issues that local testing can't: R2 bucket mounting, container cold starts, Access auth flows.
Infrastructure (test/e2e/fixture/server/)
Access protection
Test flow
Code changes
GitHub Actions
Documentation