-
Notifications
You must be signed in to change notification settings - Fork 41
108 lines (106 loc) · 3.58 KB
/
main.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
name: CI
on:
push:
branches:
- "**"
pull_request:
jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 20
env:
MONGODB_TEST: 127.0.0.1:27017/circleci_test
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16
- uses: supercharge/mongodb-github-action@1.3.0
with:
mongodb-version: 4.2
- run: npm install
- run: npm run build-pages
- name: Instantiate github-keys.json
run: |
echo "{ \"clientID\": \"clientID\", \"clientSecret\": \"clientSecret\", \"callbackURL\": \"http://localhost:3000/auth/github/callback\"}" > app/auth/github-keys.json
mkdir test/e2e/auth
cp app/auth/github-keys.json $_
- name: Instantiate configuration file
run: cp cfg.json.example cfg.json
- name: Instantiate blacklist
run: echo {} > app/controller/microdrawWebsocketServer/blacklist.json
- name: Instantiate whitelist
run: echo "{}" > app/controller/microdrawWebsocketServer/whitelist.json
- name: Run the server during 5 seconds
run: timeout 5 npm start && exit 10 || [[ $? -eq 124 ]]
- name: Run api tests
run: npm run mocha
- name: Run browser tests
run: |
npm start &
sleep 5
npm test
pkill node
mongo circleci_test --eval "db.dropDatabase();"
- name: Run e2e tests
run: npm run test-e2e
- name: Archive screenshots
if: always()
uses: actions/upload-artifact@v2
with:
name: screenshots
path: test/e2e/screenshots/
test-docker-build:
runs-on: ubuntu-latest
timeout-minutes: 20
env:
NETWORK_NAME: microdraw-docker-test
MICRODRAW_IMAGE_NAME: "microdraw:test-label"
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16
- name: Build docker image
run: docker build -t ${{ env.MICRODRAW_IMAGE_NAME }} .
- name: Run docker image
run: |
docker network create ${{ env.NETWORK_NAME }}
docker run \
--rm \
--name mongo \
--network ${{ env.NETWORK_NAME }} \
-dit \
mongo
docker run \
--rm \
--name microdraw \
--network ${{ env.NETWORK_NAME }} \
--env MONGODB=mongo:27017 \
-dit \
--env MONGODB=mongo:27017 \
-v ${PWD}/app/auth/github-keys.json.example:/microdraw/app/auth/github-keys.json \
-v ${PWD}/app/controller/microdrawWebsocketServer/blacklist.json.example:/microdraw/app/controller/microdrawWebsocketServer/blacklist.json \
-v ${PWD}/app/controller/microdrawWebsocketServer/whitelist.json.example:/microdraw/app/controller/microdrawWebsocketServer/whitelist.json \
-v ${PWD}/cfg.json.example:/microdraw/cfg.json \
-p 3000:3000 \
${{ env.MICRODRAW_IMAGE_NAME }}
- name: Ping server
run: |
sleep 5
curl -vf http://localhost:3000
- name: Clean up
run: |
docker stop microdraw
docker stop mongo
docker network rm ${{ env.NETWORK_NAME }}
deploy:
needs: test
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
- name: Invoke deployment hook
uses: distributhor/workflow-webhook@v1
env:
webhook_url: ${{ secrets.WEBHOOK_URL }}
webhook_secret: ${{ secrets.WEBHOOK_SECRET }}