diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 660673d30..0de266fa2 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -49,11 +49,13 @@ jobs: name: ⚫️ Test timeout-minutes: 8 runs-on: ubuntu-latest + if: ${{ vars.ENABLE_E2E_JOB == 'true' }} env: SUPABASE_SERVICE_ROLE_KEY: ${{ secrets.SUPABASE_SERVICE_ROLE_KEY }} SUPABASE_DB_WEBHOOK_SECRET: ${{ secrets.SUPABASE_DB_WEBHOOK_SECRET }} STRIPE_SECRET_KEY: ${{ secrets.STRIPE_SECRET_KEY }} STRIPE_WEBHOOK_SECRET: ${{ secrets.STRIPE_WEBHOOK_SECRET }} + ENABLE_BILLING_TESTS: ${{ vars.ENABLE_BILLING_TESTS }} steps: - uses: actions/checkout@v4 @@ -106,14 +108,16 @@ jobs: run: | docker run --add-host=host.docker.internal:host-gateway --rm -it --name=stripe -d stripe/stripe-cli:latest listen --forward-to http://host.docker.internal:3000/api/billing/webhook --skip-verify --api-key "$STRIPE_SECRET_KEY" --log-level debug & - - name: Production Build (test env) + - name: Run Next.js Production Build (test env) run: pnpm --filter web build:test - - name: Next.js Server + - name: Run Next.js Server run: pnpm --filter web start:test & - name: Run Playwright tests - run: pnpm run test + run: | + echo "Running Playwright tests. Billing tests enabled: $ENABLE_BILLING_TESTS" + pnpm run test - name: Run Supabase tests run: pnpm --filter web supabase:test diff --git a/apps/e2e/playwright.config.ts b/apps/e2e/playwright.config.ts index 15b302139..10fd7eaef 100644 --- a/apps/e2e/playwright.config.ts +++ b/apps/e2e/playwright.config.ts @@ -1,5 +1,18 @@ import { defineConfig, devices } from '@playwright/test'; +const enableBillingTests = process.env.ENABLE_BILLING_TESTS === 'true'; + +const testIgnore: string[] = []; + +if (!enableBillingTests) { + console.log( + `Billing tests are disabled. To enable them, set the environment variable ENABLE_BILLING_TESTS=true.`, + `Current value: "${process.env.ENABLE_BILLING_TESTS}"` + ); + + testIgnore.push('*-billing.spec.ts'); +} + /** * Read environment variables from file. * https://github.com/motdotla/dotenv @@ -20,6 +33,8 @@ export default defineConfig({ workers: process.env.CI ? 1 : undefined, /* Reporter to use. See https://playwright.dev/docs/test-reporters */ reporter: 'html', + /* Ignore billing tests if the environment variable is not set. */ + testIgnore, /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ use: { /* Base URL to use in actions like `await page.goto('/')`. */ diff --git a/turbo.json b/turbo.json index 202790334..b98709af5 100644 --- a/turbo.json +++ b/turbo.json @@ -36,7 +36,8 @@ "NEXT_PUBLIC_BASELIME_KEY", "NEXT_PUBLIC_SUPABASE_URL", "NEXT_PUBLIC_SUPABASE_ANON_KEY", - "SUPABASE_SERVICE_ROLE_KEY" + "SUPABASE_SERVICE_ROLE_KEY", + "ENABLE_BILLING_TESTS" ], "tasks": { "topo": {