This repository has been archived by the owner on Sep 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 66
270 lines (253 loc) · 9.19 KB
/
remote-ci.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
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
264
265
266
267
268
269
270
name: Core-CI
on:
repository_dispatch:
types: [triggered_from_core]
env:
JINA_AUTH_TOKEN: ${{ secrets.JINA_AUTH_TOKEN }}
jobs:
receive-message:
runs-on: ubuntu-latest
steps:
- name: echo branch
run: echo branch name is ${{ github.event.client_payload.branch }} !
- name: message_back
run: |
sudo apt install jq
job_url=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}
target_url=${{ github.event.client_payload.url }}
echo "token: ${{ github.event.client_payload.token }}"
echo "target_url: $target_url"
echo "job_url: $job_url"
curl \
-X PATCH \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ github.event.client_payload.token }}"\
-H "X-GitHub-Api-Version: 2022-11-28" \
$target_url \
-d '{"body":"REMOTE TESTING: \nstarting tests... See job here:\n '"$job_url"' "}'
style-flake:
needs: [receive-message]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- uses: actions/checkout@v3
with:
repository: jina-ai/finetuner-core
ref: ${{ github.event.client_payload.branch }}
token: ${{ github.event.client_payload.token }}
- name: Install requirements
run: make install package=style
- name: Lint with flake8
run: make flake
style-black:
needs: [receive-message]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- uses: actions/checkout@v3
with:
repository: jina-ai/finetuner-core
ref: ${{ github.event.client_payload.branch }}
token: ${{ github.event.client_payload.token }}
- name: Install requirements
run: make install package=style
- name: check black
run: make black-check
style-isort:
needs: [receive-message]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- uses: actions/checkout@v3
with:
repository: jina-ai/finetuner-core
ref: ${{ github.event.client_payload.branch }}
token: ${{ github.event.client_payload.token }}
- name: Install requirements
run: make install package=style
- name: check isort
run: make isort-check
prep-testbed:
runs-on: ubuntu-latest
needs: [style-flake, style-black, style-isort]
steps:
- uses: actions/checkout@v2
- name: Install jq
run: sudo apt-get install jq
- uses: actions/checkout@v3
with:
repository: jina-ai/finetuner-core
ref: ${{ github.event.client_payload.branch }}
token: ${{ github.event.client_payload.token }}
- name: Gather core test paths
id: gather-core-tests
run: |
core_test_paths=$( find 'tests' -name 'test_*.py' | xargs grep -l 'def test_' | xargs dirname | sort -u | jq -R . | jq -cs . )
echo "::set-output name=core-tests-matrix::$core_test_paths"
- name: Gather CUDA test paths
id: gather-cuda-tests
run: |
cuda_test_paths=$( find 'tests' -name 'test_*.py' | xargs grep -l 'def test_' | xargs grep -l 'pytest.mark.gpu' | xargs dirname | sort -u | jq -R . | jq -cs . )
echo "::set-output name=cuda-tests-matrix::$cuda_test_paths"
- name: Generate UUID for the artifact of the current run
id: generate-artifact-id
run: |
echo "::set-output name=artifact-id::$(uuidgen)"
outputs:
artifact-id: ${{ steps.generate-artifact-id.outputs.artifact-id }}
core-tests-matrix: ${{ steps.gather-core-tests.outputs.core-tests-matrix }}
cuda-tests-matrix: ${{ steps.gather-cuda-tests.outputs.cuda-tests-matrix }}
test-core:
needs: prep-testbed
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
tests-path: ${{fromJson(needs.prep-testbed.outputs.core-tests-matrix)}}
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- uses: actions/checkout@v3
with:
repository: jina-ai/finetuner-core
ref: ${{ github.event.client_payload.branch }}
token: ${{ github.event.client_payload.token }}
- name: Prepare enviroment
run: |
python -m pip install --upgrade pip
make install package=cicd.cpu
make prepare-executor
- name: Test
id: test
run: |
make test TESTS_PATH=${{ matrix.tests-path }}/test_\*.py
COVERAGE_NAME=.coverage.core.$( echo ${{ matrix.tests-path }} | tr "/" . )
echo "COVERAGE_NAME=$COVERAGE_NAME" >> $GITHUB_ENV
mv .coverage $COVERAGE_NAME
timeout-minutes: 30
- name: Upload coverage
uses: actions/upload-artifact@v3
with:
name: coverage-${{ needs.prep-testbed.outputs.artifact-id }}
path: ${{ env.COVERAGE_NAME }}
retention-days: 1
test-cuda:
needs: prep-testbed
runs-on: [self-hosted, x64, gpu, linux]
strategy:
fail-fast: false
matrix:
tests-path: ${{fromJson(needs.prep-testbed.outputs.cuda-tests-matrix)}}
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- uses: actions/checkout@v3
with:
repository: jina-ai/finetuner-core
ref: ${{ github.event.client_payload.branch }}
token: ${{ github.event.client_payload.token }}
- name: Prepare enviroment
run: |
python -m pip install --upgrade pip
make install package=cicd.cuda
make prepare-executor
- name: Test
id: test
run: |
make test-cuda TESTS_PATH=${{ matrix.tests-path }}/test_\*.py
COVERAGE_NAME=.coverage.cuda.$( echo ${{ matrix.tests-path }} | tr "/" . )
echo "COVERAGE_NAME=$COVERAGE_NAME" >> $GITHUB_ENV
mv .coverage $COVERAGE_NAME
timeout-minutes: 40
- name: Upload coverage
uses: actions/upload-artifact@v3
with:
name: coverage-${{ needs.prep-testbed.outputs.artifact-id }}
path: ${{ env.COVERAGE_NAME }}
retention-days: 1
get-coverage:
needs: [prep-testbed, test-core, test-cuda]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- uses: actions/checkout@v3
with:
repository: jina-ai/finetuner-core
ref: ${{ github.event.client_payload.branch }}
token: ${{ github.event.client_payload.token }}
- name: Prepare enviroment
run: |
python -m pip install --upgrade pip pytest pytest-cov
- name: Download coverage artifact
uses: actions/download-artifact@v3
with:
name: coverage-${{ needs.prep-testbed.outputs.artifact-id }}
- name: Combine coverages
run: |
coverage combine -a .coverage*
coverage xml
- name: Comment with coverage report
uses: MishaKav/pytest-coverage-comment@main
with:
pytest-xml-coverage-path: ./coverage.xml
title: Finetuner Coverage Report
# just for blocking the merge until all parallel core-test are successful
success-tests:
needs: [get-coverage]
if: always()
runs-on: ubuntu-latest
steps:
- uses: technote-space/workflow-conclusion-action@v2
- name: communicate result
run: |
target_url=${{ github.event.client_payload.url }}
job_url=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}
message="Job finished with status: $WORKFLOW_CONCLUSION"
echo "message: $message"
echo "job_url: $job_url"
response=$(curl \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ github.event.client_payload.token }}"\
-H "X-GitHub-Api-Version: 2022-11-28" \
$target_url
)
comment_body=$(echo $response | jq -r \
'.body | select(contains("'"$job_url"'")) // "OUTDATED"')
if [[ "$comment_body" != "OUTDATED" ]]; then
curl \
-X PATCH \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ github.event.client_payload.token }}"\
-H "X-GitHub-Api-Version: 2022-11-28" \
$target_url \
-d '{"body":"REMOTE TESTING: \n'"$message"', see job here:\n '"$job_url"'"}'
else
echo "CI job is outdated, comment will not be updated"
fi
if [ "$WORKFLOW_CONCLUSION" == "success" ]; then
echo "All Done"
else
exit 1
fi