Skip to content

Yarn berry

Yarn berry #1021

Workflow file for this run

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