Skip to content

Commit

Permalink
feat: Add Github workflow to run the full e2e test suite on PRs
Browse files Browse the repository at this point in the history
  • Loading branch information
flozia committed Aug 30, 2024
1 parent 78a9920 commit cf6f9b5
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 4 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/e2e_cron.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ jobs:
name: test-results
path: src/e2e/test-results/
retention-days: 30

- name: Send GitHub Action trigger data to Slack workflow
id: slack
uses: slackapi/[email protected]
Expand All @@ -90,7 +89,7 @@ jobs:
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Link to job:* *<https://github.com/mozilla/blurts-server/actions/runs/${{ github.run_id }}|Monitor e2e tests>*"
"text": "*Link to job:* *<https://github.com/mozilla/blurts-server/actions/runs/${{ github.run_id }}|Monitor E2E tests>*"
}
},
{
Expand Down Expand Up @@ -127,4 +126,3 @@ jobs:
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_GHA_FAILURES_WEBHOOK }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK

89 changes: 89 additions & 0 deletions .github/workflows/e2e_full_pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: Monitor E2E Full Test Suite
on: push
jobs:
e2e-tests:
timeout-minutes: 60
runs-on: ubuntu-latest
# Service containers to run with `container-job`
services:
# Label used to access the service container
postgres:
# Docker Hub image
image: postgres
# Provide the password for postgres
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: blurts
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432

steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22.6.x

- name: Install dependencies
run: npm ci
- name: Setting up postgres
run: npm run db:migrate
env:
DATABASE_URL: postgres://postgres:postgres@localhost:5432/blurts
- name: Store Playwright's Version
run: |
# Get the current Playwright version listed in package.json
PLAYWRIGHT_VERSION=$(npx playwright --version | sed 's/Version //')
echo "Playwright Version: $PLAYWRIGHT_VERSION"
echo "PLAYWRIGHT_VERSION=$PLAYWRIGHT_VERSION" >> $GITHUB_ENV
- name: Cache Playwright Browsers for Playwright's Version
id: cache-playwright-browsers
uses: actions/cache@v4
with:
path: ~/.cache/ms-playwright
key: playwright-browsers-${{ env.PLAYWRIGHT_VERSION }}

- name: Setup Playwright Browser
if: steps.cache-playwright-browsers.outputs.cache-hit != 'true'
run: npx playwright install --with-deps

- name: Run Playwright tests
if: github.actor != 'dependabot[bot]'
run: npm run e2e
timeout-minutes: 30
env:
E2E_TEST_ENV: ${{ inputs.environment != null && inputs.environment || 'stage' }}
E2E_TEST_BASE_URL: ${{ secrets.E2E_TEST_BASE_URL }}
E2E_TEST_ACCOUNT_EMAIL: ${{ secrets.E2E_TEST_ACCOUNT_EMAIL }}
E2E_TEST_ACCOUNT_PASSWORD: ${{ secrets.E2E_TEST_ACCOUNT_PASSWORD }}
E2E_TEST_ACCOUNT_EMAIL_ZERO_BREACHES: ${{ secrets.E2E_TEST_ACCOUNT_EMAIL_ZERO_BREACHES }}
E2E_TEST_ACCOUNT_EMAIL_EXPOSURES_STARTED: ${{ secrets.E2E_TEST_ACCOUNT_EMAIL_EXPOSURES_STARTED }}
E2E_TEST_PAYPAL_LOGIN: ${{ secrets.E2E_TEST_PAYPAL_LOGIN }}
E2E_TEST_PAYPAL_PASSWORD: ${{ secrets.E2E_TEST_PAYPAL_PASSWORD }}
ADMINS: ${{ secrets.ADMINS }}
OAUTH_CLIENT_SECRET: ${{ secrets.OAUTH_CLIENT_SECRET }}
ONEREP_API_KEY: ${{ secrets.ONEREP_API_KEY }}
NEXTAUTH_SECRET: ${{ secrets.NEXTAUTH_SECRET }}
NEXTAUTH_URL: ${{ secrets.NEXTAUTH_URL }}
HIBP_KANON_API_TOKEN: ${{ secrets.HIBP_KANON_API_TOKEN }}
HIBP_API_TOKEN: ${{ secrets.HIBP_API_TOKEN }}
REDIS_URL: "redis://redis.mock"
- uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30
- uses: actions/upload-artifact@v4
if: always()
with:
name: test-results
path: src/e2e/test-results/
retention-days: 30
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Monitor e2e Smoke Tests
name: Monitor E2E Smoke Test Suite
on:
push:
branches: [ main ]
Expand Down

0 comments on commit cf6f9b5

Please sign in to comment.