From d3716007bf299f1718c9555b5e1322ce6ea20816 Mon Sep 17 00:00:00 2001 From: Sam Lord Date: Mon, 5 Dec 2022 13:39:10 +0000 Subject: [PATCH] Fixed browser-based tests running in CI refs: https://github.com/TryGhost/Toolbox/issues/481 * Correctly setup environment variable to run both local & staging browser-based tests * Use non-production Ghost Admin build, since production builds require HTTPS to use Stripe Connect --- .github/workflows/browser-tests.yml | 18 +++++++++++++----- ghost/core/playwright.config.js | 2 +- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/.github/workflows/browser-tests.yml b/.github/workflows/browser-tests.yml index 1fb716ef2b..f92bfba9da 100644 --- a/.github/workflows/browser-tests.yml +++ b/.github/workflows/browser-tests.yml @@ -27,12 +27,17 @@ jobs: timeout-minutes: 60 runs-on: ubuntu-latest if: github.event_name == 'push' || (github.event_name == 'pull_request' && !startsWith(github.head_ref, 'renovate/')) - environment: ${{ github.event.inputs.environment || "browser-tests-local" }} + environment: ${{ github.event.inputs.environment || 'browser-tests-local' }} + env: + ENVIRONMENT: ${{ github.event.inputs.environment || 'browser-tests-local' }} defaults: run: working-directory: ghost/core steps: - uses: actions/checkout@v3 + with: + fetch-depth: 0 + submodules: true - uses: actions/setup-node@v3 with: node-version: '16.x' @@ -49,16 +54,19 @@ jobs: - name: Install dependencies run: yarn + - name: Run migrations + run: yarn setup + - name: Install Playwright run: npx playwright install --with-deps - name: Build Admin - if: github.event.inputs.environment == 'browser-tests-local' + if: env.ENVIRONMENT == 'browser-tests-local' working-directory: ghost/admin - run: yarn build:prod + run: yarn build --silent - name: Run Playwright tests on a remote site - if: github.event.inputs.environment == 'browser-tests-staging' + if: env.ENVIRONMENT == 'browser-tests-staging' run: yarn test:browser env: TEST_URL: ${{ github.event.inputs.site_url || secrets.TEST_URL }} @@ -66,7 +74,7 @@ jobs: TEST_OWNER_PASSWORD: ${{ github.event.inputs.owner_password || secrets.TEST_OWNER_PASSWORD }} - name: Run Playwright tests locally - if: github.event.inputs.environment == 'browser-tests-local' + if: env.ENVIRONMENT == 'browser-tests-local' run: yarn test:browser env: STRIPE_PUBLISHABLE_KEY: ${{ secrets.STRIPE_PUBLISHABLE_KEY }} diff --git a/ghost/core/playwright.config.js b/ghost/core/playwright.config.js index 56a01ebfc6..807c807d43 100644 --- a/ghost/core/playwright.config.js +++ b/ghost/core/playwright.config.js @@ -30,7 +30,7 @@ if (!process.env.TEST_URL) { NODE_ENV: 'development', WEBHOOK_SECRET: getWebhookSecret() }, - reuseExistingServer: !process.env.CI, + reuseExistingServer: false, url: 'http://localhost:2368' }; }