-
Notifications
You must be signed in to change notification settings - Fork 1
84 lines (75 loc) · 1.91 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
79
80
81
82
83
84
name: CI
on:
# push:
# branches: [ main ]
# paths: [ 'hangman-api/**' ]
workflow_dispatch:
pull_request:
branches: [main]
paths: ["hangman-api/**"]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 16
cache: "npm"
cache-dependency-path: hangman-api/package-lock.json
- name: build
working-directory: ./hangman-api
run: |
npm ci
npm run build --if-present
test:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 16
- name: test
working-directory: ./hangman-api
run: |
npm ci
npm test
test-integration:
runs-on: ubuntu-latest
needs: test
services:
postgres:
image: postgres:14-alpine
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: hangman_db
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 16
# - name: Create database relationships
- name: Running integration tests
working-directory: ./hangman-api
env:
DATABASE_PORT: 5432
DATABASE_HOST: localhost
DATABASE_NAME: hangman_db
DATABASE_USER: postgres
DATABASE_PASSWORD: postgres
DATABASE_POOL_MIN: 2
DATABASE_POOL_MAX: 10
run: |
npm ci
npx knex migrate:latest --env development
npm run test:integration