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
This commit is contained in:
Sam Lord 2022-12-05 13:39:10 +00:00 committed by GitHub
parent 5e973688bf
commit d3716007bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 6 deletions

View File

@ -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 }}

View File

@ -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'
};
}