Repository navigation
162 lines (154 loc) · 5.37 KB
/
Copy pathk8s_e2e.yml
File metadata and controls
162 lines (154 loc) · 5.37 KB
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
name: K8S E2E Suite
on:
workflow_dispatch:
push:
branches:
- master
paths:
- ".github/workflows/k8s_e2e.yml"
- ".cargo/**"
- "benches/**"
- "lib/**"
- "proto/**"
- "scripts/**"
- "skaffold/**"
- "src/**"
- "tests/**"
- "build.rs"
- "Cargo.lock"
- "Cargo.toml"
- "Makefile"
- "rust-toolchain"
- "distribution/**"
pull_request:
env:
AUTOINSTALL: true
AWS_ACCESS_KEY_ID: "dummy"
AWS_SECRET_ACCESS_KEY: "dummy"
CONTAINER_TOOL: "docker"
RUST_BACKTRACE: full
RUST_TEST_THREADS: 1
TEST_LOG: vector=debug
VERBOSE: true
CI: true
PROFILE: debug
jobs:
cancel-previous:
name: Cancel redundant jobs
runs-on: ubuntu-20.04
timeout-minutes: 3
if: github.ref != 'refs/heads/master'
steps:
- uses: styfle/cancel-workflow-action@0.5.0
with:
access_token: ${{ secrets.GITHUB_TOKEN }}
build-x86_64-unknown-linux-gnu:
name: Build - x86_64-unknown-linux-gnu
runs-on: ubuntu-20.04
if: |
!github.event.pull_request
|| contains(github.event.pull_request.labels.*.name, 'ci-condition: k8s e2e tests enable')
|| contain
9C0A
s(github.event.pull_request.labels.*.name, 'ci-condition: k8s e2e all targets')
steps:
- uses: actions/checkout@v2
- run: make ci-sweep
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- run: sudo bash scripts/environment/bootstrap-ubuntu-20.04.sh
- run: bash scripts/environment/prepare.sh
- run: echo "::add-matcher::.github/matchers/rust.json"
- run: make slim-builds
- run: make package-deb-x86_64-unknown-linux-gnu
- uses: actions/upload-artifact@v2
with:
name: e2e-test-deb-package
path: target/artifacts/*
# Github Actions don't support `matrix` at the job-level `if:` condition.
# We apply this workaround - compute `matrix` in a preceding job, and assign
# it's value dynamically at the actual test job.
# This approach can be advanced further by, for instance, dynamically
# detecting versions of various components, or reading them from `.meta`.
# See https://github.community/t/feature-request-and-use-case-example-to-allow-matrix-in-if-s/126067
compute-k8s-test-plan:
name: Compute K8s test plan
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
if: |
!github.event.pull_request
|| contains(github.event.pull_request.labels.*.name, 'ci-condition: k8s e2e tests enable')
|| contains(github.event.pull_request.labels.*.name, 'ci-condition: k8s e2e all targets')
steps:
- uses: actions/github-script@v2
id: set-matrix
with:
script: |
// Parameters.
const minikube_version = [
"v1.15.1",
]
const kubernetes_version = [
{ version: "v1.19.2", is_essential: true },
{ version: "v1.18.9" },
{ version: "v1.17.12" },
{ version: "v1.16.15" }, // v1.16.13 is broken, see https://github.com/kubernetes/kubernetes/issues/93194
{ version: "v1.15.12" },
{ version: "v1.14.10" },
]
const container_runtime = [
"docker",
"containerd",
"crio",
]
const ci_condition_label = 'ci-condition: k8s e2e all targets'
// Planing.
const is_in_pull_request = !!context.payload.pull_request;
const should_test_all_targets = (
!is_in_pull_request ||
context.payload.pull_request.labels.some(label => label.name === ci_condition_label)
)
const filter_targets = array => array.filter(val => should_test_all_targets || val.is_essential)
const matrix = {
minikube_version,
kubernetes_version: filter_targets(kubernetes_version).map(e => ({
version: e.version,
role: e.is_essential ? "essential" : "extra",
})),
container_runtime,
}
core.setOutput('matrix', matrix)
- name: Dump matrix context
env:
MATRIX_CONTEXT: ${{ toJson(steps.set-matrix.outputs.matrix) }}
run: echo "$MATRIX_CONTEXT"
test-e2e-kubernetes:
name: K8s ${{ matrix.kubernetes_version.version }} / ${{ matrix.container_runtime }} (${{ matrix.kubernetes_version.role }})
runs-on: ubuntu-latest
needs:
- build-x86_64-unknown-linux-gnu
- compute-k8s-test-plan
strategy:
matrix: ${{ fromJson(needs.compute-k8s-test-plan.outputs.matrix) }}
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: actions/download-artifact@v2
with:
name: e2e-test-deb-package
path: target/artifacts
- name: Setup Minikube
run: scripts/ci-setup-minikube.sh
env:
KUBERNETES_VERSION: ${{ matrix.kubernetes_version.version }}
MINIKUBE_VERSION: ${{ matrix.minikube_version }}
CONTAINER_RUNTIME: ${{ matrix.container_runtime }}
- run: make slim-builds
- run: make test-e2e-kubernetes
env:
USE_MINIKUBE_CACHE: "true"
SKIP_PACKAGE_DEB: "true"