-
Notifications
You must be signed in to change notification settings - Fork 5
212 lines (178 loc) · 6.44 KB
/
test.yaml
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
name: Tests
on:
pull_request:
push:
branches:
- master
jobs:
unit:
name: Unit Tests
runs-on: ubuntu-latest
timeout-minutes: 10
env:
TWILIO_ACCOUNT_SID: AC_dummy_value_so_tests_dont_error_out
TWILIO_AUTH_TOKEN: 123
elasticURL: "http://localhost:9200"
NODE_COVERALLS_DEBUG: 1
steps:
- uses: actions/checkout@v4
- name: Install Node
uses: actions/setup-node@v4
with:
node-version: "22"
- name: Enable Corepack
run: corepack enable
- name: Install deps
run: yarn install
- name: Run unit tests
run: yarn unittest --coverage
- name: Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
flag-name: Unit tests
parallel: true
tests:
name: Tests
runs-on: ubuntu-latest
timeout-minutes: 10
services:
postgres:
image: postgres:11.5
env:
POSTGRES_MULTIPLE_DATABASES: searchneu_dev,searchneu_test
POSTGRES_USER: postgres
ports:
- 5432:5432
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:7.10.0
env:
discovery.type: single-node
ports:
- 9200:9200
env:
TWILIO_ACCOUNT_SID: AC_dummy_value_so_tests_dont_error_out
TWILIO_AUTH_TOKEN: 123
elasticURL: "http://localhost:9200"
NODE_COVERALLS_DEBUG: 1
steps:
- uses: actions/checkout@v4
- name: Install Node
uses: actions/setup-node@v4
with:
node-version: "22"
- name: Enable Corepack
run: corepack enable
- name: Install deps
run: yarn install
- name: Setup database
run: |
yarn db:migrate
yarn db:refresh
- name: Run the mixed tests
run: yarn test --coverage --detectOpenHandles
- name: Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
flag-name: General tests
parallel: true
- name: Run the integration tests
run: yarn dbtest --coverage
- name: Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
flag-name: Database tests
parallel: true
end_to_end:
name: End-to-end tests
runs-on: ubuntu-latest
services:
postgres:
image: postgres:11.5
env:
POSTGRES_MULTIPLE_DATABASES: searchneu_dev,searchneu_test
POSTGRES_USER: postgres
ports:
- 5432:5432
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:7.10.0
env:
discovery.type: single-node
ports:
- 9200:9200
env:
TWILIO_ACCOUNT_SID: AC_dummy_value_so_tests_dont_error_out
TWILIO_AUTH_TOKEN: 123
elasticURL: "http://localhost:9200"
NODE_COVERALLS_DEBUG: 1
NODE_ENV: dev
DEV: true
steps:
- uses: actions/checkout@v4
- name: Install Node
uses: actions/setup-node@v4
with:
node-version: "22"
- name: Enable Corepack
run: corepack enable
- name: Install deps
run: yarn install
- run: mv ./data/cache_2022_summer ./cache
- run: yarn db:migrate
- run: yarn db:refresh
- run: yarn scrape
### Test removing outdated classes
# Add two sections - one which shouldn't be removed, one which should
- run: |-
psql -U postgres -h localhost -p 5432 -d searchneu_dev -c \
"INSERT INTO sections (class_hash, id, crn) VALUES ('neu.edu/202240/CS/2501', 'neu.edu/202240/CS/2501/123456789', '123456789');"
- run: |-
psql -U postgres -h localhost -p 5432 -d searchneu_dev -c \
"INSERT INTO sections (class_hash, id, crn, last_update_time) VALUES ('neu.edu/202240/CS/2501', 'neu.edu/202240/CS/2501/987654321', '987654321', '1999-04-03 18:34:35.882');"
# Set all Term IDS to active for testing purposes
- run: |-
psql -U postgres -h localhost -p 5432 -d searchneu_dev -c \
"UPDATE term_ids SET active = true;"
- name: Run the updater ONLY ONCE, so that it removes the newly-inserted section with an outdated lastUpdateTime
run: UPDATE_ONLY_ONCE=true LOG_LEVEL=VERBOSE yarn updater | tee _updater.log
- name: Ensure that we're using the cache, not sending live requests
run: '! cat _updater.log | egrep "Firing request.*ssb\/searchResults\/searchResults"'
# All requests to ssb/searchResults/searchResults should be going to the cache
# We can detect this, because our requests library will log:
# "Firing request to <URL>" right before it sends a live request
# We search the _updater.log (which is the output from running the updater),
# and the "!" INVERTS the result (so, if we find it, the grep command will fail).
# If we are sending live requests, this should fail.
- run: yarn dev > _dev_api.log &
- name: Wait until the dev API server is ready
run: sleep 10
- name: Checks that 'yarn dev' actually starts the API server
run: curl -Is http://localhost:4000/.well-known/apollo/server-health | head -1 | grep -q 200
- run: yarn jest -i --projects tests/end_to_end --verbose --coverage
- name: Check API logs
run: cat _dev_api.log
if: always()
- name: Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
flag-name: End to end tests
parallel: true
path-to-lcov: "./tests/end_to_end/coverage/lcov.info"
#### Some useful CLI queries to help troubleshoot
# psql -U postgres -h localhost -p 5432 -d searchneu_dev -c 'SELECT count(*) from sections'
# - run: 'curl ''http://localhost:4000'' -X POST -H ''content-type: application/json'' --data ''{ "query": "query { search(termId: \"202250\", query: \"fundies\") { nodes { ... on ClassOccurrence { name subject classId } } } }" }'''
coverage:
needs: [end_to_end, tests, unit]
name: Sends Coveralls coverage
runs-on: ubuntu-latest
env:
NODE_COVERALLS_DEBUG: 1
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true