-
Notifications
You must be signed in to change notification settings - Fork 39
132 lines (130 loc) · 4.73 KB
/
v3.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
name: Continuous Integration (CODAP v3)
on:
push:
paths: # only run this workflow if it contains v3 files
- 'v3/**' # https://docs.github.com/en/actions/using-workflows/triggering-a-workflow#example-including-paths
- '.github/workflows/v3.yml'
jobs:
build_test:
name: Build and Run Jest Tests
runs-on: ubuntu-latest
steps:
- uses: snow-actions/[email protected]
with:
patterns: v3
- uses: actions/setup-node@v4
with:
node-version: 18
- name: Install Dependencies
working-directory: v3
run: npm ci
- uses: actions/cache@v4
with:
path: v3/node_modules/.cache/webpack/
key: ${{ github.head_ref || github.ref_name }}-webpack-build
restore-keys: |
main-webpack-build
- name: Build
working-directory: v3
run: npm run build
- name: Run Tests
working-directory: v3
run: npm run test:coverage -- --maxWorkers=2
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: jest
cypress:
runs-on: ubuntu-latest
strategy:
# when one test fails, DO NOT cancel the other
# containers, because this will kill Cypress processes
# leaving the Dashboard hanging ...
# https://github.com/cypress-io/github-action/issues/48
fail-fast: false
matrix:
# run multiple copies of the current job in parallel [1, ..., n]
containers: [1, 2, 3, 4, 5]
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: v3/node_modules/.cache/webpack/
key: ${{ github.head_ref || github.ref_name }}-webpack-build
restore-keys: |
main-webpack-build
- uses: cypress-io/github-action@v6
with:
working-directory: v3
start: npm start
wait-on: 'http://localhost:8080'
# add timeout of 5 minutes to start
wait-on-timeout: 300
# only record the results to dashboard.cypress.io if CYPRESS_RECORD_KEY is set
record: ${{ !!secrets.CYPRESS_RECORD_KEY }}
# only do parallel if we have a record key
parallel: ${{ !!secrets.CYPRESS_RECORD_KEY }}
browser: chrome
env:
# pass the Dashboard record key as an environment variable
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
# pass GitHub token to allow accurately detecting a build vs a re-run build
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# turn on code coverage when running npm start
# so far we've been using a webpack coverage-istanbul-loader for this
# but there has been work on using the code coverage support in the browser directly,
# which should be much faster
CODE_COVERAGE: true
# Also turn on the code coverage tasks in cypress itself, these are disabled
# by default.
CYPRESS_coverage: true
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: cypress
s3-deploy:
name: S3 Deploy
needs:
- build_test
- cypress
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
- name: Install Dependencies
working-directory: v3
run: npm ci
env:
# skip installing cypress since it isn't needed for just building
# This decreases the deploy time quite a bit
CYPRESS_INSTALL_BINARY: 0
- uses: actions/cache@v4
with:
path: v3/node_modules/.cache/webpack/
key: ${{ github.head_ref || github.ref_name }}-webpack-build
restore-keys: |
main-webpack-build
- name: Configure Environment
working-directory: v3
run: |
cat <<EOF > .env
GOOGLE_DRIVE_CLIENT_ID="${{ secrets.GOOGLE_DRIVE_CLIENT_ID }}"
GOOGLE_DRIVE_API_KEY="${{ secrets.GOOGLE_DRIVE_API_KEY }}"
GOOGLE_DRIVE_APP_ID="${{ secrets.GOOGLE_DRIVE_APP_ID }}"
EOF
- uses: concord-consortium/s3-deploy-action@v1
with:
bucket: models-resources
prefix: codap3
workingDirectory: v3
awsAccessKeyId: ${{ secrets.V3_AWS_ACCESS_KEY_ID }}
awsSecretAccessKey: ${{ secrets.V3_AWS_SECRET_ACCESS_KEY }}
# Parameters to GHActions have to be strings, so a regular yaml array cannot
# be used. Instead the `|` turns the following lines into a string
topBranches: |
["main"]