forked from SatcherInstitute/health-equity-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5458a70
commit 897f345
Showing
1 changed file
with
103 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
# 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 Netlify Preview | ||
# uses: josephduffy/wait-for-netlify-action@v1 | ||
# id: wait-for-netlify-preview | ||
# with: | ||
# site_name: ${{env.NETLIFY_SITE_NAME}} | ||
# max_timeout: 90 | ||
- 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 |