-
Notifications
You must be signed in to change notification settings - Fork 18
241 lines (232 loc) · 7.99 KB
/
run-tests.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
# Implicit requirements
# runner must have `docker` and `curl` installed (true on github-runners)
name: run-tests
on:
workflow_call:
workflow_dispatch:
jobs:
start-runner:
runs-on: ubuntu-latest
outputs:
runner-label: ${{ steps.start-yc-runner.outputs.label }}
instance-id: ${{ steps.start-yc-runner.outputs.instance-id }}
steps:
- name: start-yc-runner
id: start-yc-runner
uses: yc-actions/yc-github-runner@v1
with:
mode: start
yc-sa-json-credentials: ${{ secrets.CI_RUNNER_CREATOR_KEY }}
github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
folder-id: b1gmgbhccra2qca8v5g6
image-id: fd80o2eikcn22b229tsa
cores: 16
disk-type: network-ssd-nonreplicated
disk-size: 465GB
memory: 32GB
core-fraction: 100
subnet-id: e9bu12i8ocv6q8kl83ru
user: yc-admin
ssh-public-key: ${{ secrets.CI_RUNNER_DEBUG_SHH_PUBLIC_KEY }}
smart-checkout:
needs:
- start-runner
runs-on: ${{ needs.start-runner.outputs.runner-label }}
steps:
- name: checkout-when-fork-source
uses: actions/checkout@v3
if: github.event.pull_request.head.sha != ''
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: checkout-when-this-repo-source
uses: actions/checkout@v3
if: github.event.pull_request.head.sha == ''
lint:
concurrency:
group: lint-golangci-${{ github.head_ref || github.ref_name }}
cancel-in-progress: true
needs:
- start-runner
- smart-checkout
runs-on: ${{ needs.start-runner.outputs.runner-label }}
steps:
- name: set-env-vars
run: |
echo "HOME=/actions-runner" >> $GITHUB_ENV
- name: setup-go
uses: actions/setup-go@v3
with:
go-version: '1.20'
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
version: v1.52.2
code-format-check:
concurrency:
group: lint-autoformat-${{ github.head_ref || github.ref_name }}
cancel-in-progress: true
needs:
- start-runner
- smart-checkout
runs-on: ${{ needs.start-runner.outputs.runner-label }}
steps:
- name: set-env-vars
run: |
echo "HOME=/actions-runner" >> $GITHUB_ENV
- name: setup-go
uses: actions/setup-go@v3
with:
go-version: '1.20'
- name: Install utilities
run: |
go install mvdan.cc/[email protected]
go install github.com/rinchsan/gosimports/cmd/[email protected]
- name: format all files with auto-formatter
run: bash ./.github/scripts/format-all-go-code.sh "$PWD"
- name: Check repository diff
run: bash ./.github/scripts/check-work-copy-equals-to-committed.sh "auto-format broken"
run-unit-tests:
concurrency:
group: run-unit-tests-${{ github.head_ref || github.ref_name }}
cancel-in-progress: true
needs:
- start-runner
- smart-checkout
- lint
- code-format-check
runs-on: ${{ needs.start-runner.outputs.runner-label }}
outputs:
result: ${{ steps.run-unit-tests.outputs.result }}
steps:
- name: set-env-vars
run: |
echo "HOME=/actions-runner" >> $GITHUB_ENV
- name: setup-go
uses: actions/setup-go@v3
with:
go-version: '1.20'
- name: Set up gotestfmt
uses: gotesttools/gotestfmt-action@v2
- name: setup-medium-test-class-binaries
run: |
# This installs kube-apiserver and etcd binaries for `medium`
# class tests. Refer to the writing tests docs for more info.
make envtest
KUBEBUILDER_ASSETS=$(./bin/setup-envtest use 1.26 -p path)
echo "KUBEBUILDER_ASSETS=$KUBEBUILDER_ASSETS" >> $GITHUB_ENV
- name: run-unit-tests
run: |
set -euo pipefail
go test -json -v -timeout 900s -p 1 ./internal/... -ginkgo.v 2>&1 | tee /tmp/gotest.log | gotestfmt
- name: Upload test log
uses: actions/upload-artifact@v2
if: always()
with:
name: test-log
path: /tmp/gotest.log
if-no-files-found: error
run-e2e-tests:
concurrency:
group: run-e2e-tests-${{ github.head_ref || github.ref_name }}
cancel-in-progress: true
needs:
- start-runner
- smart-checkout
- lint
- code-format-check
runs-on: ${{ needs.start-runner.outputs.runner-label }}
outputs:
result: ${{ steps.run-e2e-tests.outputs.result }}
steps:
- name: set-env-vars
run: |
echo "HOME=/actions-runner" >> $GITHUB_ENV
- name: setup-go
uses: actions/setup-go@v3
with:
go-version: '1.20'
- name: Set up gotestfmt
uses: gotesttools/gotestfmt-action@v2
- name: install-dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential
go install sigs.k8s.io/[email protected]
curl -LO https://dl.k8s.io/release/v1.25.3/bin/linux/amd64/kubectl
chmod +x ./kubectl
HELM_PKG="helm-v3.13.3-linux-amd64.tar.gz"
curl -LO https://get.helm.sh/"${HELM_PKG}"
tar -zxvf "${HELM_PKG}"
mv ./linux-amd64/helm .
curl -sSL https://storage.yandexcloud.net/yandexcloud-ydb/install.sh | bash
echo "$(pwd)" >> $GITHUB_PATH
echo "$HOME/ydb/bin" >> $GITHUB_PATH
echo "$HOME/go/bin" >> $GITHUB_PATH
- name: configure-system
run: |
sudo sysctl fs.inotify.max_user_instances=1280
sudo sysctl fs.inotify.max_user_watches=655360
- name: check-dependencies
run: |
gcc --version
go version
kind version
kubectl version --client=true
helm version
- name: setup-k8s-cluster
run: |
kind delete cluster
kind create cluster \
--image=kindest/node:v1.25.3@sha256:cd248d1438192f7814fbca8fede13cfe5b9918746dfa12583976158a834fd5c5 \
--config=./e2e/kind-cluster-config.yaml
kubectl wait --timeout=5m --for=condition=ready node -l worker=true
- name: build-operator-image
uses: docker/build-push-action@v3
with:
context: .
push: false
# Get commit short sha within Github action workflow
# Just a random string name, we aren't uploading anyway
tags: kind/ydb-operator:current
- name: load-and-deploy-operator
run: |
kind load docker-image kind/ydb-operator:current
- name: pull-and-load-other-images
run: |
docker pull k8s.gcr.io/ingress-nginx/kube-webhook-certgen:v1.0
kind load docker-image k8s.gcr.io/ingress-nginx/kube-webhook-certgen:v1.0
# TODO would be cool to parse YDB image from manifests to avoid duplicating information
docker pull cr.yandex/crptqonuodf51kdj7a7d/ydb:23.3.17
kind load docker-image cr.yandex/crptqonuodf51kdj7a7d/ydb:23.3.17
- name: run-e2e-tests
run: |
set -euo pipefail
go test -json-v -timeout 3600s -p 1 ./e2e/... -ginkgo.v 2>&1 | tee /tmp/gotest.log | gotestfmt
- name: Upload test log
uses: actions/upload-artifact@v2
if: always()
with:
name: test-log
path: /tmp/gotest.log
if-no-files-found: error
- name: teardown-k8s-cluster
run: |
kind delete cluster
stop-runner:
needs:
- start-runner
- lint
- code-format-check
- run-unit-tests
- run-e2e-tests
runs-on: ubuntu-latest
if: always()
steps:
- name: stop-yc-runner
uses: yc-actions/yc-github-runner@v1
with:
mode: stop
yc-sa-json-credentials: ${{ secrets.CI_RUNNER_CREATOR_KEY }}
github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
label: ${{ needs.start-runner.outputs.runner-label }}
instance-id: ${{ needs.start-runner.outputs.instance-id }}