-
Notifications
You must be signed in to change notification settings - Fork 0
263 lines (221 loc) · 6.68 KB
/
main.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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
name: Test
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
pre-clean-badge:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Clean coverage badge
run: |
curl -s https://github.com/DimasDMM/live-timing-strategy/blob/master/README.md > README.md.tmp
grep -Eo '<img src="[^"]+"' README.md.tmp | grep camo | grep -Eo 'https[^"]+' | xargs -I {} curl -w "\n" -s -X PURGE {}
test-lts-pipeline:
runs-on: ubuntu-latest
timeout-minutes: 5
needs: pre-clean-badge
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.10'
- name: Load environment variables
uses: cardinalby/export-env-action@v2
with:
envFile: 'lts-pipeline/.env.local'
expand: 'true'
- name: Prepare network of Docker
run: |
docker network create lts-network
- name: Start API of LTS
run: |
cd lts-api
docker build --tag lts-api .
docker run -d --name lts-api --network lts-network --env-file .env.indocker -p ${{ env.API_PORT }}:80 lts-api
- name: Start MySQL
run: |
docker run -d --name lts-mysql --network lts-network -p ${{ env.DB_PORT }}:3306 -e MYSQL_ROOT_PASSWORD=root mysql:8.1.0
- name: Install dependencies
run: |
cd lts-pipeline
python -m pip install --upgrade pip
python -m pip install tox==4.11 poetry==1.6.1
poetry install
- name: Wait for MySQL
run: |
sh ./lts-api/bin/wait-database.sh
- name: Wait for API REST
run: |
sh ./lts-api/bin/wait-api.sh
- name: Run tests
run: |
cd lts-pipeline
tox -e 'py310-test'
poetry run coverage-badge -o "docs/coverage.svg" -f
- name: Verify Changed files
uses: tj-actions/verify-changed-files@v13
id: verify-changed-files
with:
files: lts-pipeline/docs/coverage.svg
- name: Commit files
if: steps.verify-changed-files.outputs.files_changed == 'true'
run: |
git config user.email "github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
git add lts-pipeline/docs/coverage.svg
git commit -m "ci: Update lts-pipeline coverage.svg"
- name: Push changes
if: steps.verify-changed-files.outputs.files_changed == 'true'
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.github_token }}
branch: ${{ github.ref }}
linter-lts-pipeline:
runs-on: ubuntu-latest
timeout-minutes: 5
needs: pre-clean-badge
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install tox==4.11 poetry==1.6.1
- name: Run linter
run: |
cd lts-pipeline
tox -e 'py310-lint'
mypy-lts-pipeline:
runs-on: ubuntu-latest
timeout-minutes: 5
needs: pre-clean-badge
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install tox==4.11 poetry==1.6.1
- name: Run MyPy
run: |
cd lts-pipeline
tox -e 'py310-mypy'
test-lts-api:
runs-on: ubuntu-latest
timeout-minutes: 5
needs: pre-clean-badge
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.10'
- name: Load environment variables
uses: cardinalby/export-env-action@v2
with:
envFile: 'lts-api/.env.local'
expand: 'true'
- name: Start MySQL
run: |
docker run -d --name lts-mysql -p ${{ env.DB_PORT }}:3306 -e MYSQL_ROOT_PASSWORD=root mysql:8.1.0
- name: Install dependencies
run: |
cd lts-api
python -m pip install --upgrade pip
python -m pip install tox==4.11 poetry==1.6.1
poetry install
- name: Wait for MySQL
run: |
sh ./lts-api/bin/wait-database.sh
- name: Run tests
run: |
cd lts-api
tox -e 'py310-test'
poetry run coverage-badge -o "docs/coverage.svg" -f
- name: Verify Changed files
uses: tj-actions/verify-changed-files@v13
id: verify-changed-files
with:
files: lts-api/docs/coverage.svg
- name: Commit files
if: steps.verify-changed-files.outputs.files_changed == 'true'
run: |
git config user.email "github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
git add lts-api/docs/coverage.svg
git commit -m "ci: Update lts-api coverage.svg"
- name: Push changes
if: steps.verify-changed-files.outputs.files_changed == 'true'
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.github_token }}
branch: ${{ github.ref }}
linter-lts-api:
runs-on: ubuntu-latest
timeout-minutes: 5
needs: pre-clean-badge
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install tox==4.11 poetry==1.6.1
- name: Run linter
run: |
cd lts-api
tox -e 'py310-lint'
mypy-lts-api:
runs-on: ubuntu-latest
timeout-minutes: 5
needs: pre-clean-badge
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install tox==4.11 poetry==1.6.1
- name: Run MyPy
run: |
cd lts-api
tox -e 'py310-mypy'
post-clean-badge:
runs-on: ubuntu-latest
timeout-minutes: 5
needs:
- test-lts-api
- test-lts-pipeline
- linter-lts-api
- linter-lts-pipeline
- mypy-lts-api
- mypy-lts-pipeline
steps:
- name: Clean coverage badge
run: |
curl -s https://github.com/DimasDMM/live-timing-strategy/blob/master/README.md > README.md.tmp
grep -Eo '<img src="[^"]+"' README.md.tmp | grep camo | grep -Eo 'https[^"]+' | xargs -I {} curl -w "\n" -s -X PURGE {}