-
Notifications
You must be signed in to change notification settings - Fork 13
143 lines (119 loc) · 5.07 KB
/
develop-pull-request-end-to-end-tests.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
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
name: MCDA-test | pull request | end-to-end tests
on:
pull_request:
branches: develop
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
node-version: ['18']
os: [ubuntu-22.04]
services:
postgres:
image: postgres:12.2-alpine
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: develop
POSTGRES_DB: postgres
POSTGRES_HOST_AUTH_METHOD: trust
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- uses: actions/checkout@v2
- name: fetch schema
run: curl https://raw.githubusercontent.com/drugis/patavi/master/server/schema.sql -o patavi.schema.sql
- name: setup patavi database
run: |
docker exec ${{ job.services.postgres.id }} psql -U postgres -c "CREATE USER patavi WITH PASSWORD 'develop'"
docker exec ${{ job.services.postgres.id }} psql -U postgres -c "CREATE DATABASE patavi ENCODING 'utf-8' OWNER patavi"
- name: initialize patavi database
run: |
docker cp patavi.schema.sql ${{ job.services.postgres.id }}:/patavi.schema.sql
docker exec ${{ job.services.postgres.id }} psql -v ON_ERROR_STOP=1 -U patavi -f patavi.schema.sql
- name: run rabbit
run: docker run -d --hostname my-rabbit --name my-rabbit -p 5672:5672 -p 15672:15672 rabbitmq:3-management
- name: run patavi server
run: >-
docker run -d --name patavi-server
--network host
-e PATAVI_BROKER_HOST=guest:guest@localhost
-p 3000:3000
-e PATAVI_HOST=localhost
-e PATAVI_PORT=3000
-e PATAVI_DB_HOST=localhost
-e PATAVI_DB_NAME=patavi
-e PATAVI_DB_USER=patavi
-e PATAVI_DB_PASSWORD=develop
-e SECURE_TRAFFIC=false
-e PATAVI_API_KEY=${{ secrets.pataviApiKeyTest }}
addis/patavi-server:test
- name: build and run patavi worker
run: |
cd R
docker build --tag addis/patavi-smaa-worker .
docker run -d --link my-rabbit:rabbit -e PATAVI_BROKER_HOST=rabbit --name patavi-mcda-worker addis/patavi-smaa-worker
cd ..
- name: setup mcda database
run: |
docker exec ${{ job.services.postgres.id }} psql -U postgres -c "CREATE USER mcdaweb WITH PASSWORD 'develop'"
docker exec ${{ job.services.postgres.id }} psql -U postgres -c "CREATE DATABASE mcdaweb ENCODING 'utf-8' OWNER mcdaweb"
- name: initialize mcda database
run: |
docker cp database.pg.sql ${{ job.services.postgres.id }}:/database.pg.sql
docker exec ${{ job.services.postgres.id }} psql -v ON_ERROR_STOP=1 -U mcdaweb -f database.pg.sql
- name: add local users
run: |
docker exec ${{ job.services.postgres.id }} psql -U mcdaweb -c "INSERT INTO Account (username, firstName, lastName, password) VALUES ('user', 'user', 'user', '\$2a\$10\$HOkkgYW2IqzPc6ryCbi/9OWUpJPxh2mu7IzDpLvxShBcZRtwb/1F.')"
docker exec ${{ job.services.postgres.id }} psql -U mcdaweb -c "INSERT INTO Account (username, firstName, lastName, password) VALUES ('user2', 'user2', 'user2', '\$2a\$10\$HOkkgYW2IqzPc6ryCbi/9OWUpJPxh2mu7IzDpLvxShBcZRtwb/1F.')"
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Cache node modules
uses: actions/cache@v1
with:
path: node_modules
key: ${{ runner.OS }}-build-${{ hashFiles('package.json') }}
- name: run yarn
run: yarn
- name: build backend
run: yarn build-backend
- name: run webpack
run: yarn build-local-login
- name: run mcda
run: yarn start &
env:
MCDAWEB_AUTHENTICATION_METHOD: LOCAL
MCDAWEB_DB_USER: mcdaweb
MCDAWEB_DB_PASSWORD: develop
MCDAWEB_DB_HOST: localhost
MCDAWEB_DB_NAME: mcdaweb
MCDAWEB_COOKIE_SECRET: abc
MCDA_HOST: localhost
PATAVI_HOST: localhost
PATAVI_PORT: 3000
SECURE_TRAFFIC: false
PATAVI_API_KEY: ${{ secrets.pataviApiKeyTest }}
- name: run nightwatch tests
id: nightwatch
run: yarn tsc -p ts-end-to-end-config.json && yarn nightwatch -c nightwatch.github.conf.js
- name: notify on slack channel on nightwatch failure
if: failure()
uses: rtCamp/action-slack-notify@master
env:
SLACK_WEBHOOK: ${{ secrets.slackWebhook }}
SLACK_USERNAME: gitbot
SLACK_TITLE: 'Develop pull request:'
SLACK_MESSAGE: 'End-to-end tests failed'
- name: notify on slack channel on success
if: success()
uses: rtCamp/action-slack-notify@master
env:
SLACK_WEBHOOK: ${{ secrets.slackWebhook }}
SLACK_USERNAME: gitbot
SLACK_TITLE: 'Develop pull request:'
SLACK_MESSAGE: 'End-to-end tests passed'
- name: stop mcda
run: sudo pkill -9 node