-
Notifications
You must be signed in to change notification settings - Fork 26
256 lines (225 loc) · 7.97 KB
/
pr.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
# Workflow on Push
# - unit test
# - build image (push if docker-secret (IMAGE_REPO, BOT_NAME, BOT_TOKEN) exists)
# - collect data (if aws-secret exists)
# - train model (if aws-secret exists)
name: Workflow on Push/PR
on: # yamllint disable-line rule:truthy
pull_request:
paths-ignore:
- fig/**
- .github/ISSUE_TEMPLATE/**
- .vscode/**
- LICENSE
- .gitignore
- "*.md"
- "**/*.md"
env:
TAG: v0.7.11
jobs:
check-branch:
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.image-tag.outputs.tag }}
steps:
- uses: actions/checkout@v4
- name: Find Image Tag
id: image-tag
env:
BRANCH: ${{ github.ref_name }}
COMMIT: ${{ github.sha }}
run: |
if [ "${{ github.event_name }}" == 'pull_request' ]; then
echo "tag=pr-${{ github.event.number }}" >> "$GITHUB_OUTPUT"
else
if [ "$BRANCH" == "main" ]; then
echo "tag=${{ env.TAG }}" >> "$GITHUB_OUTPUT"
else
echo "tag=$COMMIT" >> "$GITHUB_OUTPUT"
fi
fi
check-change:
runs-on: ubuntu-latest
outputs:
base: ${{ steps.filter.outputs.base }}
data: ${{ steps.filter.outputs.data }}
modeling: ${{ steps.filter.outputs.modeling }}
s3: ${{ steps.filter.outputs.s3 }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
base:
- 'pyproject.toml'
- 'dockerfiles/Dockerfile.base'
- '.github/workflows/build-push.yml'
data:
- 'src/kepler_model/util/prom_types.py'
- 'src/kepler_model/util/train_types.py'
- 'src/kepler_model/train/prom/**'
- 'model_training/tekton/tasks/stressng-task.yaml'
- 'model_training/tekton/pipelines/collect.yaml'
- 'hack/**'
- '.github/workflows/collect-data-self-hosted.yml'
modeling:
- 'src/**'
- 'model_training/**'
- 'hack/**'
- '.github/workflows/collect-data-self-hosted.yml'
- '.github/workflows/train-model.yml'
s3:
- 'model_training/s3/**'
check-secret:
runs-on: ubuntu-latest
outputs:
docker-secret: ${{ steps.check-docker-secret.outputs.available }}
steps:
- name: Check Docker Secret
id: check-docker-secret
env:
DOCKER_SECRET: ${{ secrets.BOT_TOKEN}}
run: |
if [ "$DOCKER_SECRET" == "" ]; then
echo "available=false" >> "$GITHUB_OUTPUT"
else
echo "available=true" >> "$GITHUB_OUTPUT"
fi
check-base-exist:
runs-on: ubuntu-latest
outputs:
exists: ${{ steps.check-base-exist.outputs.exists }}
steps:
- name: Check if Docker base image exists
id: check-base-exist
run: |
if docker pull ${{ env.BASE_IMAGE }}; then
echo "exists=true" >> "$GITHUB_OUTPUT"
else
echo "exists=false" >> "$GITHUB_OUTPUT"
fi
unit-test:
needs: [check-change]
uses: ./.github/workflows/unit-test.yml
with:
base_change: ${{ needs.check-change.outputs.base }}
base-image:
if: ${{ (needs.check-base-exist.outputs.exists == 'false') || (needs.check-change.outputs.base == 'true') }}
needs: [check-base-exist, check-branch, check-change]
runs-on: ubuntu-latest
outputs:
change: ${{ steps.record.outputs.change }}
env:
tag: ${{ needs.check-branch.outputs.tag }}
steps:
- name: checkout
uses: actions/checkout@v4
- name: set up QEMU
uses: docker/setup-qemu-action@v3
- name: set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build base image
uses: docker/build-push-action@v6
with:
push: false
tags: ${{ vars.IMAGE_REPO || 'docker.io/library' }}/kepler_model_server_base:${{ needs.check-branch.outputs.tag }}
file: dockerfiles/Dockerfile.base
- name: Record change
id: record
run: |
echo "change=true" >> "$GITHUB_OUTPUT"
s3-image:
if: ${{ needs.check-change.outputs.s3 == 'true' }}
needs: [check-change, check-branch]
runs-on: ubuntu-latest
outputs:
change: ${{ steps.record.outputs.change }}
env:
tag: ${{ needs.check-branch.outputs.tag }}
steps:
- name: checkout
uses: actions/checkout@v4
- name: set up QEMU
uses: docker/setup-qemu-action@v3
- name: set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build s3 image
uses: docker/build-push-action@v6
with:
push: false
load: true
tags: ${{ vars.IMAGE_REPO || 'docker.io/library' }}/kepler_model_server/s3:${{ needs.check-branch.outputs.tag }}
context: model_training/s3
file: model_training/s3/Dockerfile
- name: Test s3 image
run: |
img=${{ vars.IMAGE_REPO || 'docker.io/library' }}/kepler_model_server/s3:${{ needs.check-branch.outputs.tag }}
docker run --rm $img s3-pusher --version
docker run --rm $img s3-loader --version
- name: Record change
id: record
run: |
echo "change=true" >> "$GITHUB_OUTPUT"
tekton-test:
needs: [check-secret, check-branch, check-change, base-image]
if: always()
uses: ./.github/workflows/tekton-test.yml
with:
base_change: ${{ needs.check-change.outputs.base }}
docker_secret: ${{ needs.check-secret.outputs.docker-secret }}
image_repo: ${{ vars.IMAGE_REPO || 'docker.io/library' }}
image_tag: ${{ needs.check-branch.outputs.tag }}
pipeline_name: std_v0.7.11
integration-test-internal-only:
needs: [check-secret, check-branch, check-change, base-image]
if: always()
uses: ./.github/workflows/integration-test.yml
with:
base_change: ${{ needs.check-change.outputs.base }}
docker_secret: ${{ needs.check-secret.outputs.docker-secret }}
image_repo: ${{ vars.IMAGE_REPO || 'docker.io/library' }}
image_tag: ${{ needs.check-branch.outputs.tag }}
kepler_tag: release-0.7.11
additional_opts: --test
integration-test-with-exporter:
needs: [check-secret, check-branch, check-change, base-image]
if: always()
uses: ./.github/workflows/integration-test.yml
with:
base_change: ${{ needs.check-change.outputs.base }}
docker_secret: ${{ needs.check-secret.outputs.docker-secret }}
image_repo: ${{ vars.IMAGE_REPO || 'docker.io/library' }}
image_tag: ${{ needs.check-branch.outputs.tag }}
kepler_tag: release-0.7.11
additional_opts: ""
integration-test-with-exporter-and-db:
needs: [check-secret, check-branch, check-change, base-image]
if: always()
uses: ./.github/workflows/integration-test.yml
with:
base_change: ${{ needs.check-change.outputs.base }}
docker_secret: ${{ needs.check-secret.outputs.docker-secret }}
image_repo: ${{ vars.IMAGE_REPO || 'docker.io/library' }}
image_tag: ${{ needs.check-branch.outputs.tag }}
kepler_tag: release-0.7.11
additional_opts: --db
integration-test-with-latest:
needs: [check-secret, check-branch, check-change, base-image]
if: always()
uses: ./.github/workflows/integration-test.yml
with:
base_change: ${{ needs.check-change.outputs.base }}
docker_secret: ${{ needs.check-secret.outputs.docker-secret }}
image_repo: ${{ vars.IMAGE_REPO || 'docker.io/library' }}
image_tag: ${{ needs.check-branch.outputs.tag }}
kepler_tag: latest
additional_opts: --db
verify_model_training_script:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: local script test
run: cd model_training && ./script.sh prepare_cluster
- name: clean up
run: cd model_training && ./script.sh cleanup