forked from SatcherInstitute/health-equity-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
100 lines (92 loc) · 3.18 KB
/
runFrontendTests.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# 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: Wandalen/wretry.action@master
# with:
# action: jakepartusch/wait-for-netlify-action@v1.4
# attempt_limit: 3
# attempt_delay: 10000
# with: |
# site_name: ${{env.NETLIFY_SITE_NAME}}
# max_timeout: 180
# 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_NIGHTLY --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