2022-02-17 13:31:54 +03:00
|
|
|
name: Browser Tests
|
|
|
|
on:
|
2022-12-01 04:30:24 +03:00
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- 'main'
|
2022-02-17 13:31:54 +03:00
|
|
|
workflow_dispatch:
|
2022-02-17 14:20:29 +03:00
|
|
|
inputs:
|
2022-12-02 18:46:59 +03:00
|
|
|
environment:
|
|
|
|
description: 'Environment to run tests against'
|
|
|
|
type: environment
|
|
|
|
required: true
|
2022-02-17 14:20:29 +03:00
|
|
|
site_url:
|
2022-12-02 18:46:59 +03:00
|
|
|
description: 'Site URL (override)'
|
|
|
|
required: false
|
|
|
|
type: string
|
|
|
|
owner_email:
|
|
|
|
description: 'Owner email (override)'
|
|
|
|
required: false
|
|
|
|
type: string
|
|
|
|
owner_password:
|
|
|
|
description: 'Owner password (override)'
|
2022-12-01 04:30:24 +03:00
|
|
|
required: false
|
2022-02-17 14:20:29 +03:00
|
|
|
type: string
|
2023-03-17 17:58:26 +03:00
|
|
|
concurrency:
|
|
|
|
group: ${{ github.workflow }}
|
2022-02-17 13:31:54 +03:00
|
|
|
jobs:
|
|
|
|
test:
|
|
|
|
timeout-minutes: 60
|
2023-03-20 23:34:18 +03:00
|
|
|
runs-on: ubuntu-latest
|
2022-12-05 17:48:39 +03:00
|
|
|
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request' && !startsWith(github.head_ref, 'renovate/'))
|
2022-12-05 16:39:10 +03:00
|
|
|
environment: ${{ github.event.inputs.environment || 'browser-tests-local' }}
|
|
|
|
env:
|
|
|
|
ENVIRONMENT: ${{ github.event.inputs.environment || 'browser-tests-local' }}
|
2022-02-17 13:31:54 +03:00
|
|
|
steps:
|
2022-08-03 23:32:37 +03:00
|
|
|
- uses: actions/checkout@v3
|
2022-12-05 16:39:10 +03:00
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
|
|
|
submodules: true
|
2022-08-03 23:32:37 +03:00
|
|
|
- uses: actions/setup-node@v3
|
2022-02-17 13:31:54 +03:00
|
|
|
with:
|
2023-06-01 12:18:33 +03:00
|
|
|
node-version: '18.x'
|
2022-02-17 13:31:54 +03:00
|
|
|
cache: yarn
|
|
|
|
|
2022-12-01 04:30:24 +03:00
|
|
|
- name: Install Stripe-CLI
|
|
|
|
run: |
|
|
|
|
export VERSION=1.13.5
|
|
|
|
wget "https://github.com/stripe/stripe-cli/releases/download/v$VERSION/stripe_${VERSION}_linux_x86_64.tar.gz"
|
|
|
|
tar -zxvf "stripe_${VERSION}_linux_x86_64.tar.gz"
|
|
|
|
mv stripe /usr/local/bin
|
|
|
|
stripe -v
|
|
|
|
|
2022-02-17 13:31:54 +03:00
|
|
|
- name: Install dependencies
|
|
|
|
run: yarn
|
|
|
|
|
2023-07-13 12:14:08 +03:00
|
|
|
- name: Build packages
|
|
|
|
run: yarn nx run-many -t build:ts
|
|
|
|
|
2022-12-05 16:39:10 +03:00
|
|
|
- name: Run migrations
|
2023-05-03 21:37:40 +03:00
|
|
|
working-directory: ghost/core
|
2023-07-12 17:39:58 +03:00
|
|
|
run: yarn knex-migrator init
|
2023-07-13 12:14:08 +03:00
|
|
|
|
2023-07-04 16:53:48 +03:00
|
|
|
- name: Get Playwright version
|
|
|
|
id: playwright-version
|
|
|
|
run: echo "version=$(node -p "require('@playwright/test/package.json').version")" >> $GITHUB_OUTPUT
|
|
|
|
- uses: actions/cache@v3
|
|
|
|
name: Check if Playwright browser is cached
|
|
|
|
id: playwright-cache
|
|
|
|
with:
|
|
|
|
path: ~/.cache/ms-playwright
|
|
|
|
key: ${{ runner.os }}-Playwright-${{steps.playwright-version.outputs.version}}
|
|
|
|
- name: Install Playwright browser if not cached
|
|
|
|
if: steps.playwright-cache.outputs.cache-hit != 'true'
|
2022-02-17 13:31:54 +03:00
|
|
|
run: npx playwright install --with-deps
|
2023-07-04 16:53:48 +03:00
|
|
|
- name: Install OS dependencies of Playwright if cache hit
|
|
|
|
if: steps.playwright-cache.outputs.cache-hit == 'true'
|
|
|
|
run: npx playwright install-deps
|
2022-02-17 13:31:54 +03:00
|
|
|
|
2022-12-01 04:30:24 +03:00
|
|
|
- name: Build Admin
|
2022-12-05 16:39:10 +03:00
|
|
|
if: env.ENVIRONMENT == 'browser-tests-local'
|
2022-12-01 04:30:24 +03:00
|
|
|
working-directory: ghost/admin
|
2023-05-05 13:11:33 +03:00
|
|
|
run: yarn build:dev
|
2022-12-01 04:30:24 +03:00
|
|
|
|
2022-12-02 18:46:59 +03:00
|
|
|
- name: Run Playwright tests on a remote site
|
2022-12-05 16:39:10 +03:00
|
|
|
if: env.ENVIRONMENT == 'browser-tests-staging'
|
2023-05-03 21:37:40 +03:00
|
|
|
working-directory: ghost/core
|
2022-12-02 18:46:59 +03:00
|
|
|
run: yarn test:browser
|
|
|
|
env:
|
|
|
|
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
|
2022-12-05 16:39:10 +03:00
|
|
|
if: env.ENVIRONMENT == 'browser-tests-local'
|
2023-05-03 21:37:40 +03:00
|
|
|
working-directory: ghost/core
|
2022-02-17 13:31:54 +03:00
|
|
|
run: yarn test:browser
|
|
|
|
env:
|
2022-12-02 18:46:59 +03:00
|
|
|
STRIPE_PUBLISHABLE_KEY: ${{ secrets.STRIPE_PUBLISHABLE_KEY }}
|
|
|
|
STRIPE_SECRET_KEY: ${{ secrets.STRIPE_SECRET_KEY }}
|
|
|
|
STRIPE_ACCOUNT_ID: ${{ secrets.STRIPE_ACCOUNT_ID }}
|
2022-02-17 13:31:54 +03:00
|
|
|
|
2023-05-12 14:11:16 +03:00
|
|
|
- uses: tryghost/actions/actions/slack-build@main
|
2023-03-09 12:30:41 +03:00
|
|
|
if: failure() && github.event_name == 'push' && github.ref == 'refs/heads/main'
|
|
|
|
with:
|
|
|
|
status: ${{ job.status }}
|
|
|
|
env:
|
|
|
|
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
|
|
|
|
|
2022-08-03 23:32:37 +03:00
|
|
|
- uses: actions/upload-artifact@v3
|
2022-02-17 13:31:54 +03:00
|
|
|
if: always()
|
|
|
|
with:
|
2023-10-02 22:57:35 +03:00
|
|
|
name: browser-tests-playwright-report
|
|
|
|
path: ghost/core/playwright-report
|
2022-02-17 13:31:54 +03:00
|
|
|
retention-days: 30
|