Chore: Migrate SMS pumping to app
router INTER-911, INTER-459
#434
Workflow file for this run
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: Tests | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
env: | |
# Playwright headless browsers running in CI get low confidence scores, causing flaky e2e tests. Lower the confidence score threshold for CI testing. | |
MIN_CONFIDENCE_SCORE: 0 | |
# Staging Cloudflare credentials and IDs for e2e tests | |
CLOUDFLARE_API_TOKEN: '${{ secrets.CLOUDFLARE_API_TOKEN }}' | |
CLOUDFLARE_ZONE_ID: '${{ secrets.CLOUDFLARE_ZONE_ID }}' | |
CLOUDFLARE_RULESET_ID: '${{ secrets.CLOUDFLARE_RULESET_ID }}' | |
# Some aspects of the app are tweaked to speed up e2e tests, such as cool-down periods for SMS fraud use case | |
TEST_BUILD: 'true' | |
jobs: | |
lint: | |
name: Lint | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: 'Cache' | |
uses: actions/cache@v4 | |
with: | |
path: node_modules | |
key: nodemodules-${{ hashFiles('yarn.lock') }} | |
restore-keys: nodemodules- | |
- name: Install packages | |
run: yarn install --frozen-lockfile --prefer-offline | |
- name: Lint | |
run: yarn lint | |
unit-tests: | |
name: Unit tests | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: 'Cache' | |
uses: actions/cache@v4 | |
with: | |
path: node_modules | |
key: nodemodules-${{ hashFiles('yarn.lock') }} | |
restore-keys: nodemodules- | |
- name: Install packages | |
run: yarn install --frozen-lockfile --prefer-offline | |
- name: Run unit tests | |
run: yarn test | |
e2e: | |
name: Playwright e2e tests | |
timeout-minutes: 60 | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
shardIndex: [1, 2, 3] | |
shardTotal: [3] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Cache node modules | |
uses: actions/cache@v4 | |
with: | |
path: node_modules | |
key: nodemodules-${{ hashFiles('yarn.lock') }} | |
restore-keys: nodemodules- | |
- name: Install node modules | |
run: yarn install --prefer-offline --frozen-lockfile | |
- name: Get installed Playwright version (used in cache key) | |
id: playwright-version | |
run: echo "PLAYWRIGHT_VERSION=$(node -e "process.stdout.write(require('@playwright/test/package.json').version)")" >> $GITHUB_ENV | |
- name: Cache Playwright browser binaries | |
uses: actions/cache@v4 | |
id: playwright-cache | |
with: | |
path: | | |
~/.cache/ms-playwright | |
key: ${{ runner.os }}-playwright-${{ env.PLAYWRIGHT_VERSION }} | |
- name: Install Playwright browsers binaries if cache missed | |
run: yarn playwright install --with-deps | |
if: steps.playwright-cache.outputs.cache-hit != 'true' | |
# Ubuntu needs extra stuff to run webkit tests, alternative is using a Playwright docker container but | |
# that is slower in CI. | |
- name: If browser binaries cache hit, install just webkit dependencies | |
run: yarn playwright install-deps webkit | |
if: steps.playwright-cache.outputs.cache-hit == 'true' | |
- name: Cache Next build | |
uses: actions/cache@v4 | |
with: | |
path: ${{ github.workspace }}/.next/cache | |
# Generate a new cache whenever packages or source files change. | |
key: ${{ runner.os }}-nextjs-${{ hashFiles('yarn.lock') }}-${{ hashFiles('src/*') }} | |
# If source files changed but packages didn't, rebuild from a prior cache. | |
restore-keys: | | |
${{ runner.os }}-nextjs-${{ hashFiles('yarn.lock') }}- | |
- name: Build website | |
run: yarn build | |
- name: Run Playwright tests | |
run: yarn playwright test --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }} | |
- name: Upload Playwright report | |
uses: actions/upload-artifact@v4 | |
if: always() | |
with: | |
name: playwright-report-${{ matrix.shardIndex }} | |
path: playwright-report/ | |
retention-days: 30 |