E2e-tests #308
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: E2e-tests | |
on: | |
workflow_dispatch: | |
inputs: | |
plan_identifiers: | |
description: 'Comma separated list of plan identifiers' | |
required: true | |
default: 'sunnydale' | |
frontend_base_url: | |
description: 'Base url for environment to run tests against' | |
required: true | |
default: 'http://{planId}.watch.staging.kausal.tech' | |
backend_base_url: | |
description: 'Base url for backend API' | |
required: true | |
default: 'https://api.watch.kausal.tech/v1' | |
schedule: | |
- cron: '0 21 * * 1-5' # 21:00 UTC, 00:00 EEST | |
jobs: | |
e2e_test: | |
name: Run tests | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v3 | |
- name: Setup Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
- name: Cache node modules | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cache/ms-playwright | |
node_modules | |
key: ${{ runner.os }}-node-modules-${{ hashFiles('**/yarn.lock') }} | |
- name: Install yarn | |
run: | | |
corepack enable | |
yarn set version 3.2.1 | |
yarn config set nodeLinker 'node-modules' | |
yarn config set npmScopes.kausal.npmRegistryServer "${{ secrets.NPM_REGISTRY_SERVER }}" | |
yarn config set npmScopes.kausal.npmAlwaysAuth true | |
yarn config set npmScopes.kausal.npmAuthIdent ${{ secrets.NPM_AUTH_IDENT }} | |
- name: Install dependencies | |
run: yarn install | |
- name: Playwright install | |
run: node_modules/.bin/playwright install --with-deps | |
- name: Set TEST_PLAN_IDENTIFIERS for each job | |
run: | | |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then | |
echo "TEST_PLAN_IDENTIFIERS=${{ github.event.inputs.plan_identifiers }}" >> $GITHUB_ENV | |
echo "FRONTEND_BASE_URL=${{ github.event.inputs.frontend_base_url }}" >> $GITHUB_ENV | |
else | |
echo "TEST_PLAN_IDENTIFIERS=${{ secrets.TEST_PLAN_IDENTIFIERS }}" >> $GITHUB_ENV | |
IFS=',' read -ra PLAN_IDS <<< "$TEST_PLAN_IDENTIFIERS" | |
for PLAN_ID in "${PLAN_IDS[@]}" | |
do | |
FRONTEND_BASE_URL="http://${PLAN_ID}.watch.staging.kausal.tech" | |
echo "Running tests for plan $PLAN_ID with FRONTEND_BASE_URL=$FRONTEND_BASE_URL" | |
echo "APLANS_API_BASE_URL=https://api.watch.kausal.tech/v1" >> $GITHUB_ENV | |
done | |
fi | |
- name: Running Playwright e2e tests | |
run: node_modules/.bin/playwright test | |
env: | |
TEST_PLAN_IDENTIFIERS: ${{ env.TEST_PLAN_IDENTIFIERS }} | |
TEST_PAGE_BASE_URL: ${{ env.FRONTEND_BASE_URL }} | |
APLANS_API_BASE_URL: ${{ env.APLANS_API_BASE_URL }} | |
- uses: actions/upload-artifact@v3 | |
if: always() | |
with: | |
name: playwright-report | |
path: playwright-report/ | |
retention-days: 5 |