-
Notifications
You must be signed in to change notification settings - Fork 68
165 lines (152 loc) · 6.75 KB
/
ci.yaml
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
name: CI
on:
push
jobs:
build:
runs-on: ubuntu-latest
steps:
- run: mkdir -p repos/undefx
- name: Checkout undefx/py3tester
uses: actions/checkout@v2
with:
repository: undefx/py3tester
path: repos/undefx/py3tester
- name: Checkout undefx/undef-analysis
uses: actions/checkout@v2
with:
repository: undefx/undef-analysis
path: repos/undefx/undef-analysis
- run: mkdir -p repos/delphi
- name: Checkoutcmu-delphi/operations
uses: actions/checkout@v2
with:
repository: cmu-delphi/operations
path: repos/delphi/operations
- name: Checkout cmu-delphi/utils
uses: actions/checkout@v2
with:
repository: cmu-delphi/utils
path: repos/delphi/utils
- name: Checkout cmu-delphi/github-deploy-repo
uses: actions/checkout@v2
with:
repository: cmu-delphi/github-deploy-repo
path: repos/delphi/github-deploy-repo
- name: Checkout THIS REPO
uses: actions/checkout@v2
with:
path: repos/delphi/delphi-epidata
- name: Checkout cmu-delphi/flu-contest
uses: actions/checkout@v2
with:
repository: cmu-delphi/flu-contest
path: repos/delphi/flu-contest
- name: Checkout cmu-delphi/nowcast
uses: actions/checkout@v2
with:
repository: cmu-delphi/nowcast
path: repos/delphi/nowcast
- name: Build docker images
run: |
docker build -t delphi_database_epidata -f ./repos/delphi/delphi-epidata/dev/docker/database/epidata/Dockerfile .
docker build -t delphi_web_python -f repos/delphi/delphi-epidata/dev/docker/python/Dockerfile .
sudo docker build -t delphi_redis -f repos/delphi/delphi-epidata/dev/docker/redis/Dockerfile .
cd ./repos/delphi/delphi-epidata
docker build -t delphi_web_epidata -f ./devops/Dockerfile .
cd ../../../
# MODULE_NAME specifies the location of the `app` variable, the actual WSGI application object to run.
# see https://github.com/tiangolo/meinheld-gunicorn-docker#module_name
- name: Start database and Redis services
run: |
docker network create --driver bridge delphi-net
docker run --rm -d -p 13306:3306 --network delphi-net --name delphi_database_epidata --cap-add=sys_nice delphi_database_epidata
docker run --rm -d -p 6379:6379 --network delphi-net --env "REDIS_PASSWORD=1234" --name delphi_redis delphi_redis
- run: |
wget https://raw.githubusercontent.com/eficode/wait-for/master/wait-for
chmod +x wait-for
./wait-for localhost:13306 -- echo 'ready'
sleep 10s
- name: Start delphi_web_epidata
run: |
docker run --rm -d -p 10080:80 --env "MODULE_NAME=delphi.epidata.server.main" --env "SQLALCHEMY_DATABASE_URI=mysql+mysqldb://user:pass@delphi_database_epidata:3306/epidata" --env "FLASK_SECRET=abc" --env "FLASK_PREFIX=/epidata" --env "REDIS_HOST=delphi_redis" --env "REDIS_PASSWORD=1234" --env "API_KEY_REGISTER_WEBHOOK_TOKEN=abc" --env "API_KEY_ADMIN_PASSWORD=test_admin_password" --network delphi-net --name delphi_web_epidata delphi_web_epidata
docker ps
- name: Run Unit Tests
run: |
docker run --rm --network delphi-net --env "SQLALCHEMY_DATABASE_URI=mysql+mysqldb://user:pass@delphi_database_epidata:3306/epidata" --env "FLASK_SECRET=abc" delphi_web_python python -m pytest --import-mode importlib repos/delphi/delphi-epidata/tests
- name: Run Integration Tests
run: |
docker run --rm --network delphi-net delphi_web_python python -m pytest --import-mode importlib repos/delphi/delphi-epidata/integrations
- name: Clean Up
run: |
docker stop delphi_database_epidata delphi_web_epidata delphi_redis
docker network remove delphi-net
build_js_client:
runs-on: ubuntu-latest
defaults:
run:
working-directory: src/client/packaging/npm
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '14.x'
- name: Cache Node.js modules
uses: actions/cache@v2
with:
path: ~/.npm # npm cache files are stored in `~/.npm` on Linux/macOS
key: ${{ runner.OS }}-node2-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.OS }}-node2-
- run: npm ci
- run: npm test
image:
needs: build
# only on main and dev branch
# TODO: #1112 Remove `|| github.ref == 'refs/heads/api-keys'` after transition to production status.
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/api-keys'
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: cmu-delphi-deploy-machine
password: ${{ secrets.CMU_DELPHI_DEPLOY_MACHINE_PAT }}
- name: Build Image
env:
DEVOPS_DOCKER_FILE: ./devops/Dockerfile
run: |
docker build -t repo --file ${DEVOPS_DOCKER_FILE} .
- name: Resolve Tag
id: tagname
run: |
baseRef="${GITHUB_REF#*/}"
imageTag="${baseRef#*/}"
if [ "$imageTag" = "main" ] ; then
imageTag="latest"
fi
echo "::set-output name=tag::$imageTag"
echo "::set-output name=repo::ghcr.io/${{ github.repository }}"
- name: Push Dev Tag
run: |
docker tag repo ${{ steps.tagname.outputs.repo }}:${{ steps.tagname.outputs.tag }}
docker push ${{ steps.tagname.outputs.repo }}:${{ steps.tagname.outputs.tag }}
# - name: Extract version
# if: startsWith(github.ref, 'refs/heads/main')
# id: extract_version
# run: node -pe "'::set-output name=version::' + require('./package.json').version"
- name: Trigger Webhook
run: |
# trigger a webhook update
curl -H "Authorization: Bearer ${{ secrets.DELPHI_DEPLOY_WEBHOOK_TOKEN }}" \
-X POST ${{ secrets.DELPHI_DEPLOY_WEBHOOK_URL }} \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "repository=${{ steps.tagname.outputs.repo }}&tag=${{ steps.tagname.outputs.tag }}"
# - name: Push Version Tag Tag
# if: startsWith(github.ref, 'refs/heads/main')
# run: |
# docker tag repo ${{ steps.tagname.outputs.repo }}:v${{ steps.extract_version.outputs.version }}
# docker push ${{ steps.tagname.outputs.repo }}:v${{ steps.extract_version.outputs.version }}