Skip to content

Merge branch 'main' of https://github.com/SatcherInstitute/health-equ… #128

Merge branch 'main' of https://github.com/SatcherInstitute/health-equ…

Merge branch 'main' of https://github.com/SatcherInstitute/health-equ… #128

# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: RUN Frontend Tests
env:
## Sets environment variables
NETLIFY_SITE_NAME: 'health-equity-tracker'
GITHUB_PR_NUMBER: ${{github.event.pull_request.number}}
on:
push:
branches: [main]
pull_request:
branches: [main]
paths:
- 'frontend/**' # Run when changes occur in the frontend subfolder
defaults:
run:
working-directory: frontend
jobs:
build_frontend:
name: Builds frontend
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: frontend/package.json
cache: 'npm'
cache-dependency-path: frontend/package-lock.json
- name: Install dependencies
run: npm ci
- name: Build React frontend
env:
NODE_OPTIONS: '--max_old_space_size=4096'
run: npm run build:deploy_preview
frontend_unit_tests:
name: Runs frontend unit tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: frontend/package.json
cache: 'npm'
cache-dependency-path: frontend/package-lock.json
- name: Install dependencies
run: npm ci
- name: Run Vitest unit tests
run: npm test
# If it's a PR creation or update, we'll run the e2e test here on Netlify
# if it's a merge to main, the E2E will run in e2eStaging.yml
tests_e2e_netlify_prepare:
name: Wait for Netlify deploy
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- name: Waiting for "Success" from Netlify Preview
uses: jakepartusch/wait-for-netlify-action@v1.4
id: waitFor200
with:
site_name: ${{env.NETLIFY_SITE_NAME}}
max_timeout: 90
tests_e2e_netlify:
needs: tests_e2e_netlify_prepare
name: Run E2E tests on deploy preview
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: frontend/package.json
cache: 'npm'
cache-dependency-path: frontend/package-lock.json
- name: Install dependencies
run: npm ci
- name: Install playwright deps
run: npx playwright install --with-deps chromium
- name: run quicker E2E on DEPLOY_PREVIEW
run: npx playwright test --project=E2E_CI --workers 4
# base url based on the GITHUB_PR_NUMBER + NETLIFY_SITE_NAME
env:
E2E_BASE_URL: 'https://deploy-preview-${{env.GITHUB_PR_NUMBER}}--${{env.NETLIFY_SITE_NAME}}.netlify.app'
# store test run reports if they fail
- uses: actions/upload-artifact@v4
if: ${{ failure() }}
with:
name: playwright-report
path: frontend/playwright-report/
retention-days: 30