0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-04-08 02:52:39 -05:00

Improved browser test CI integration

refs: https://github.com/TryGhost/Toolbox/issues/481
This commit is contained in:
Sam Lord 2022-12-02 15:46:59 +00:00 committed by Sam Lord
parent 7bfe5db716
commit 00d223991d
3 changed files with 28 additions and 5 deletions

View file

@ -6,8 +6,20 @@ on:
pull_request:
workflow_dispatch:
inputs:
environment:
description: 'Environment to run tests against'
type: environment
required: true
site_url:
description: 'Site URL to test, or blank for local'
description: 'Site URL (override)'
required: false
type: string
owner_email:
description: 'Owner email (override)'
required: false
type: string
owner_password:
description: 'Owner password (override)'
required: false
type: string
jobs:
@ -44,10 +56,21 @@ jobs:
working-directory: ghost/admin
run: yarn build:prod
- name: Run Playwright tests
- name: Run Playwright tests on a remote site
if: github.event.inputs.environment == 'browser-tests-staging'
run: yarn test:browser
env:
TEST_URL: ${{ github.event.inputs.site_url }}
TEST_URL: ${{ github.event.inputs.site_url || secrets.TEST_URL }}
TEST_OWNER_EMAIL: ${{ github.event.inputs.owner_email || secrets.TEST_OWNER_EMAIL }}
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'
run: yarn test:browser
env:
STRIPE_PUBLISHABLE_KEY: ${{ secrets.STRIPE_PUBLISHABLE_KEY }}
STRIPE_SECRET_KEY: ${{ secrets.STRIPE_SECRET_KEY }}
STRIPE_ACCOUNT_ID: ${{ secrets.STRIPE_ACCOUNT_ID }}
- uses: actions/upload-artifact@v3
if: always()

View file

@ -1,7 +1,7 @@
const {execSync} = require('child_process');
const getWebhookSecret = () => {
const command = `stripe listen --print-secret ${process.env.CI ? `--api-key ${process.env.STRIPE_API_KEY}` : ''}`.trim();
const command = `stripe listen --print-secret ${process.env.CI ? `--api-key ${process.env.STRIPE_SECRET_KEY}` : ''}`.trim();
const webhookSecret = execSync(command);
return webhookSecret.toString().trim();
};

View file

@ -7,7 +7,7 @@ const {chromium} = require('@playwright/test');
const models = require('../../../core/server/models');
const startWebhookServer = () => {
const command = `stripe listen --forward-to ${config.getSiteUrl()}/members/webhooks/stripe/ ${process.env.CI ? `--api-key ${process.env.STRIPE_API_KEY}` : ''}`.trim();
const command = `stripe listen --forward-to ${config.getSiteUrl()}/members/webhooks/stripe/ ${process.env.CI ? `--api-key ${process.env.STRIPE_SECRET_KEY}` : ''}`.trim();
spawn(command.split(' ')[0], command.split(' ').slice(1));
};