-
-
Notifications
You must be signed in to change notification settings - Fork 21
78 lines (67 loc) · 2.57 KB
/
ci.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
name: CI
on:
push:
branches: [ master ]
# Triggers the workflow on pull request events in the context of the fork
# trying to sidestep limitations here: https://github.com/wearerequired/lint-action/issues/13
pull_request:
jobs:
build-test:
runs-on: ubuntu-latest
services:
# Label used to access the service container
postgres:
# Docker Hub image
image: postgres:12.3
# Provide the password for postgres
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: bookbrainz_test
# Since we run tests on the host machine (not in a docker container)
# we need to bind the Postgres port from Docker container to host machine
ports:
- 5432:5432
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout bookbrainz-data-js repo
uses: actions/checkout@v3
# We need schema files and scripts that are in another repo
- name: Checkout bookbrainz-site repo
uses: actions/checkout@v3
with:
repository: metabrainz/bookbrainz-site
path: bookbrainz-site
# Set up the test dabatase
- name: Set up test database in PostgreSQL
run: scripts/create-test-db.sh
working-directory: bookbrainz-site
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: bookbrainz_test
POSTGRES_HOST: localhost
- name: Set up node
uses: actions/setup-node@v1
with:
# We could also test on multiple Node versions if needed: https://github.com/actions/setup-node#matrix-testing
node-version: '16'
# Enables caching Yarn dependencies (uses https://github.com/actions/cache under the hood)
cache: 'yarn'
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Create config file
run: cp test/bookshelf.js.example test/bookshelf.js
- name: Run tests
run: yarn test-ci # run tests (configured to use mocha's json reporter)
- name: Export test results
uses: actions/upload-artifact@v3 # upload test results
if: success() || failure() # run this step even if previous step failed
with:
name: test-results
path: coverage/test-results.json