-
Notifications
You must be signed in to change notification settings - Fork 6
377 lines (371 loc) · 14.3 KB
/
test.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
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
name: Run Tests
on:
push:
paths-ignore:
- "docs/**"
- "helm/**"
- "*.md"
- Makefile
pull_request:
paths-ignore:
- "docs/**"
- "helm/**"
- "*.md"
- Makefile
branches:
- main
jobs:
pre_job:
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@master
with:
concurrent_skipping: "same_content"
paths_ignore: '["**/README.md", "**/docs/**", "CHANGELOG.md"]'
do_not_skip: '["pull_request", "workflow_dispatch", "schedule"]'
setup_build:
needs: pre_job
runs-on: ubuntu-20.04
if: needs.pre_job.outputs.should_skip != 'true'
outputs:
python-version: ${{ steps.artifact-versions.outputs.python-version }}
kubectl-version: ${{ steps.artifact-versions.outputs.kubectl-version }}
aws-iam-auth-version: ${{ steps.artifact-versions.outputs.aws-iam-auth-version }}
steps:
- uses: actions/checkout@master
- name: Output versions into env vars for various artifacts
id: artifact-versions
run: |
echo "::set-output name=python-version::$(cat .python-version)"
echo "::set-output name=kubectl-version::$(cat .kubectl-version)"
echo "::set-output name=aws-iam-auth-version::$(cat .aws-iam-auth-version)"
- uses: actions/[email protected]
id: setup-python
with:
python-version: ${{ steps.artifact-versions.outputs.python-version }}
architecture: x64
- name: Set up Poetry cache
uses: actions/cache@v4
id: cached-poetry
with:
path: ~/.local
key: poetry-${{ runner.os }}-1.7.0a-python-${{ steps.setup-python.outputs.python-version }}
- name: Install and configure Poetry
uses: snok/install-poetry@v1
if: steps.cached-poetry.outputs.cache-hit != 'true'
with:
version: 1.7.0
virtualenvs-create: true
virtualenvs-in-project: true
- name: Initialize Poetry
# NOTE: We have to apply the config options to cover cases where the install-poetry action is skipped but we have new deps
run: |
echo "$HOME/.local/bin" >> $GITHUB_PATH
poetry config virtualenvs.create true
poetry config virtualenvs.in-project true
- name: Set up dependencies cache
uses: actions/cache@v4
id: cached-poetry-dependencies
with:
path: .venv
key: ".venv-${{ runner.os }}-\
python-${{ steps.setup-python.outputs.python-version }}-\
${{ hashFiles('**/poetry.lock') }}"
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root
# NOTE: Install our root project into the venv cache without busting it
- name: Set up root + dependencies cache
uses: actions/cache@v4
id: cached-project
with:
path: .venv
key: ".venv-${{ runner.os }}-\
python-${{ steps.setup-python.outputs.python-version }}-\
${{ hashFiles('**/poetry.lock', 'servo/**/*.py') }}"
- name: Install root project
# NOTE: Skipping root project install accelerates cases where only tests have changed
if: steps.cached-project.outputs.cache-hit != 'true'
run: poetry install --no-interaction
unit:
needs:
- pre_job
- setup_build
if: needs.pre_job.outputs.should_skip != 'true'
name: Run Unit Tests
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@master
- uses: actions/[email protected]
id: setup-python
with:
python-version: ${{ needs.setup_build.outputs.python-version }}
architecture: x64
- name: Set up root + dependencies cache
uses: actions/cache@v4
id: cached-project
with:
path: .venv
key: ".venv-${{ runner.os }}-\
python-${{ steps.setup-python.outputs.python-version }}-\
${{ hashFiles('**/poetry.lock', 'servo/**/*.py') }}"
- name: Export coverage file
run: |
echo "COVERAGE_FILE=${{ github.workspace }}/.coverage-unit-temp" >> $GITHUB_ENV
- name: Run tests
run: |
source .venv/bin/activate
TERM=dumb pytest -T unit -n 6 \
--cov=servo --cov-config=setup.cfg --doctest-modules \
--cov-report=term-missing:skip-covered \
--cov-report=xml:artifacts/unit-test-coverage.xml --cov-report=html:artifacts/unit-test-coverage-html \
--junitxml=artifacts/unit-test-report.xml --html=artifacts/unit-test-report.html \
--self-contained-html
- name: Upload coverage file
uses: actions/upload-artifact@v4
with:
name: coverage-unit-temp
path: ${{ github.workspace }}/.coverage-unit-temp
- uses: actions/upload-artifact@v4
with:
name: unit-test-reports
path: artifacts/
- name: Test CLI entrypoints
run: |
source .venv/bin/activate
servo version
# migrated to Teamcity
# integration:
# name: Run Integration Tests
# runs-on: ubuntu-20.04
# needs:
# - pre_job
# - setup_build
# if: |
# needs.pre_job.outputs.should_skip != 'true' &&
# github.actor != 'dependabot[bot]' &&
# (github.ref == 'refs/heads/main' ||
# startsWith(github.ref, 'refs/heads/release/') ||
# startsWith(github.ref, 'refs/heads/bugfix/') ||
# startsWith(github.ref, 'refs/tags/') ||
# github.event_name == 'pull_request' ||
# contains(github.event.head_commit.message, '#test:integration'))
# steps:
# - uses: actions/checkout@master
# - uses: actions/[email protected]
# id: setup-python
# with:
# python-version: ${{ needs.setup_build.outputs.python-version }}
# architecture: x64
# - name: Install Vegeta
# run: |
# wget https://github.com/tsenart/vegeta/releases/download/v12.8.4/vegeta_12.8.4_linux_amd64.tar.gz
# tar xfz vegeta_12.8.4_linux_amd64.tar.gz
# sudo mv vegeta /usr/local/bin/vegeta
# - name: Install Kubectl
# run: |
# KUBECTL_RELEASE="https://dl.k8s.io/release/v${{ needs.setup_build.outputs.kubectl-version }}/bin/linux/amd64/kubectl"
# mkdir -p ${{ github.workspace }}/bin
# curl -o ${{ github.workspace }}/bin/kubectl -fLO $KUBECTL_RELEASE
# echo "${{ github.workspace }}/bin" >> $GITHUB_PATH
# chmod +x ${{ github.workspace }}/bin/kubectl
# - name: Set up root + dependencies cache
# uses: actions/cache@v4
# id: cached-project
# with:
# path: .venv
# key: ".venv-${{ runner.os }}-\
# python-${{ steps.setup-python.outputs.python-version }}-\
# ${{ hashFiles('**/poetry.lock', 'servo/**/*.py') }}"
# - name: Configure AWS credentials
# uses: aws-actions/configure-aws-credentials@v1
# with:
# aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
# aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# aws-region: us-west-2
# - name: Create tests/kubeconfig
# run: |
# mkdir ~/.kube
# echo "$KUBE_CONFIG_DATA" | base64 --decode > $HOME/.kube/config
# kubectl config view --minify --flatten > tests/kubeconfig
# shell: bash
# env:
# KUBE_CONFIG_DATA: ${{ secrets.KUBE_CONFIG_DATA }}
# - name: Install aws-iam-authenticator
# run: |
# AWS_AUTH_RELEASE="https://github.com/kubernetes-sigs/aws-iam-authenticator/releases/download/v${{ needs.setup_build.outputs.aws-iam-auth-version }}/aws-iam-authenticator_${{ needs.setup_build.outputs.aws-iam-auth-version }}_linux_amd64"
# curl -o ${{ github.workspace }}/bin/aws-iam-authenticator -fLO $AWS_AUTH_RELEASE
# chmod 0755 ${{ github.workspace }}/bin/aws-iam-authenticator
# - name: Export coverage file
# run: |
# echo "COVERAGE_FILE=${{ github.workspace }}/.coverage-integration-temp" >> $GITHUB_ENV
# - name: Run integration tests
# run: |
# source .venv/bin/activate
# pytest -n 8 \
# -T integration --verbose --durations=0 --durations-min=5 \
# --cov=servo --cov-config=setup.cfg --doctest-modules \
# --cov-report=term-missing:skip-covered --cov-report=xml:artifacts/integration-test-coverage.xml \
# --cov-report=html:artifacts/integration-test-coverage-html --junitxml=artifacts/integration-test-report.xml \
# --html=artifacts/integration-test-report.html --self-contained-html
# - name: Upload coverage file
# uses: actions/upload-artifact@v4
# with:
# name: coverage-integration-temp
# path: ${{ github.workspace }}/.coverage-integration-temp
# - uses: actions/upload-artifact@v4
# with:
# name: integration-test-reports
# path: artifacts/
# - uses: actions/upload-artifact@v4
# with:
# name: integration-test-logs
# path: logs/
# combined_coverage:
# name: Combine coverage reports
# runs-on: ubuntu-20.04
# needs:
# - pre_job
# - setup_build
# - unit
# - integration
# if: |
# needs.pre_job.outputs.should_skip != 'true' &&
# github.actor != 'dependabot[bot]' &&
# (github.ref == 'refs/heads/main' ||
# startsWith(github.ref, 'refs/heads/release/') ||
# startsWith(github.ref, 'refs/heads/bugfix/') ||
# startsWith(github.ref, 'refs/tags/') ||
# github.event_name == 'pull_request' ||
# contains(github.event.head_commit.message, '#test:integration'))
# steps:
# - uses: actions/checkout@master
# - uses: actions/[email protected]
# id: setup-python
# with:
# python-version: ${{ needs.setup_build.outputs.python-version }}
# architecture: x64
# - name: Set up root + dependencies cache
# uses: actions/cache@v4
# id: cached-project
# with:
# path: .venv
# key: ".venv-${{ runner.os }}-\
# python-${{ steps.setup-python.outputs.python-version }}-\
# ${{ hashFiles('**/poetry.lock', 'servo/**/*.py') }}"
# - name: Download unit coverage
# uses: actions/download-artifact@v4
# with:
# name: coverage-unit-temp
# - name: Download integration coverage
# uses: actions/download-artifact@v4
# with:
# name: coverage-integration-temp
# - name: Combine coverage reports
# run: |
# source .venv/bin/activate
# coverage combine --append .coverage-unit-temp .coverage-integration-temp
# coverage html -d artifacts/combined_coverage --skip-covered
# - uses: actions/upload-artifact@v4
# with:
# name: combined-coverage-report
# path: artifacts/
# - uses: geekyeggo/delete-artifact@v1
# with:
# name: |
# coverage-unit-temp
# coverage-integration-temp
system:
name: Run System Tests
runs-on: ubuntu-20.04
needs:
- pre_job
- setup_build
if: |
needs.pre_job.outputs.should_skip != 'true' &&
github.actor != 'dependabot[bot]' &&
(github.ref == 'refs/heads/main' ||
startsWith(github.ref, 'refs/heads/release/') ||
startsWith(github.ref, 'refs/heads/bugfix/') ||
startsWith(github.ref, 'refs/tags/') ||
github.event_name == 'pull_request' ||
contains(github.event.head_commit.message, '#test:system'))
steps:
- uses: actions/checkout@master
- uses: actions/[email protected]
id: setup-python
with:
python-version: ${{ needs.setup_build.outputs.python-version }}
architecture: x64
- name: Set up Poetry cache
uses: actions/cache@v4
id: cached-poetry
with:
path: ~/.local
key: poetry-${{ runner.os }}-1.7.0a-python-${{ steps.setup-python.outputs.python-version }}
- name: Ensure Poetry is on GITHUB_PATH
run: |
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Set up root + dependencies cache
uses: actions/cache@v4
id: cached-project
with:
path: .venv
key: ".venv-${{ runner.os }}-\
python-${{ steps.setup-python.outputs.python-version }}-\
${{ hashFiles('**/poetry.lock', 'servo/**/*.py') }}"
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-west-2
- name: Create tests/kubeconfig
run: |
mkdir ~/.kube
echo "$KUBE_CONFIG_DATA" | base64 --decode > $HOME/.kube/config
kubectl config view --minify --flatten > tests/kubeconfig
shell: bash
env:
KUBE_CONFIG_DATA: ${{ secrets.KUBE_CONFIG_DATA }}
- name: Fix permissions
run: |
if [ -d /home/runner/.kube ]; then
sudo chown -R runner:docker /home/runner/.kube
else
mkdir /home/runner/.kube
fi
sudo chown runner:docker tests/kubeconfig
- name: Rename EKS cluster to eks
run: |
kubectl config rename-context \
--kubeconfig=tests/kubeconfig \
kubetest eks
- name: Create kind cluster
uses: helm/[email protected]
with:
cluster_name: kind
- name: Display kind kubeconfig
run: kind get clusters && kind get kubeconfig --name kind
- name: Merge kind kubeconfig
run: kind export kubeconfig --name kind --kubeconfig tests/kubeconfig
- name: Install AWS IAM Authenticator
uses: prepor/action-aws-iam-authenticator@master
- name: Run system tests
run: |
source .venv/bin/activate
pytest -n 6 \
-T system --verbose --durations=0 --durations-min=5 \
--junitxml=artifacts/system-test-report.xml \
--html=artifacts/system-test-report.html --self-contained-html
- uses: actions/upload-artifact@v4
with:
name: system-test-reports
path: artifacts/
- uses: actions/upload-artifact@v4
with:
name: system-test-logs
path: logs/