-
Notifications
You must be signed in to change notification settings - Fork 4
/
github-action-test.yml
61 lines (55 loc) · 1.56 KB
/
github-action-test.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
name: Node CI
on: [push]
jobs:
test:
runs-on: ubuntu-latest
{% if postgres or redis %}
services:
{% if postgres %}
postgres:
image: postgres:11.6-alpine
ports: ["5432:5432"]
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
env:
POSTGRES_PASSWORD: postgres
{% endif %}
{% if redis %}
redis:
image: redis
ports:
- 6379:6379
options: --entrypoint redis-server
{% endif %}
{% endif %}
steps:
- uses: actions/checkout@v2
- name: Use Node.js {{ node_version }}.x
uses: actions/setup-node@v2
with:
node-version: '{{ node_version }}.x'
- name: npm ci
run: npm ci
env:
NODE_AUTH_TOKEN: {% raw %}${{ secrets.NPM_TOKEN }}{% endraw %}
{% if postgres %}
- name: create the database
run: createdb -U postgres -h localhost -p 5432 database
env:
PGPASSWORD: postgres
- name: run migrations
run: |
docker run -v \
$(pwd)/migrations:/migrations \
--network host \
migrate/migrate \
-path=/migrations/ \
-database 'postgres://postgres:postgres@localhost:5432/database?sslmode=disable' \
up
{% endif %}
- name: npm test
run: PATH=node_modules/.bin:$PATH eval "$(jq -r '.scripts.test' < package.json)"
env:
{% if postgres %}
PGURL: postgres://postgres:postgres@localhost:5432/database
{% endif %}
CI: true