-
Notifications
You must be signed in to change notification settings - Fork 33
282 lines (247 loc) · 9.08 KB
/
e2e.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
271
272
273
274
275
276
277
278
279
280
281
282
name: e2e
on:
push:
branches: [ master ]
pull_request_review:
types: [submitted]
env:
REGISTRY: 'ghcr.io/dell/csi-baremetal'
go_version: '1.21.12'
golangci_version: '1.55.2'
helm_version: '3.7.1'
kubectl_version: 'v1.25.3'
kind_config: 'small-kind.yaml'
kind_wait: '30s'
jobs:
e2e:
# we need to start validation on master push or on /ci comment in PR only
if: github.event_name == 'push' || github.event.review.state == 'approved'
runs-on: ubuntu-20.04
steps:
- name: Get operator branch
uses: actions/github-script@v5
id: operator_branch
env:
COMMENT_BODY: ${{ github.event.comment.body }}
KEY: "operator_branch="
with:
result-encoding: string
script: |
const { COMMENT_BODY, KEY } = process.env
var branch = `${COMMENT_BODY}`.split(String.fromCharCode(0x0A))[1]
var key = `${KEY}`
if (branch){
if (branch.search(key) !== -1){
return branch.split(key)[1]
} else {
return 'keyword'
}
}
return ''
- name: Get PR SHA
# Since the issue comment event runs against the main branch
# we need to figure out a way to checkout the correct revision
# if we want to work with the changes from a pull request.
if: github.event.issue.pull_request_review
id: sha
uses: actions/github-script@v4
with:
result-encoding: string
script: |
const { owner, repo, number } = context.issue;
const pr = await github.pulls.get({
owner,
repo,
pull_number: number,
});
return pr.data.head.sha
# Set ref if triggered from comment
- name: Check out code
if: github.event.issue.pull_request_review
uses: actions/checkout@v2
with:
ref: '${{ steps.sha.outputs.result }}'
# Set ref if event is merge to master
- name: Check out code
if: github.event.issue.pull_request == false
uses: actions/checkout@v2
- name: Checkout csi-baremetal-operator repo
id: checkout_branch
uses: actions/checkout@v2
env:
OPERATOR_BRANCH: ${{ steps.operator_branch.outputs.result }}
with:
repository: dell/csi-baremetal-operator
ref: ${{ env.OPERATOR_BRANCH }}
path: ./csi-baremetal-operator
continue-on-error: true
- name: Create answer body
if: github.event.issue.pull_request && startsWith(github.event.comment.body, '/ci')
uses: actions/github-script@v5
id: set-answer
env:
OPERATOR_BRANCH: ${{ steps.operator_branch.outputs.result }}
CHECKOUT_BRANCH_OUTCOME: ${{ steps.checkout_branch.outcome }}
with:
result-encoding: string
script: |
const { OPERATOR_BRANCH, CHECKOUT_BRANCH_OUTCOME } = process.env
if (`${OPERATOR_BRANCH}` === 'keyword'){
return "Keyword error"
} else if (`${CHECKOUT_BRANCH_OUTCOME}` === 'failure'){
return "Branch doesn't exist"
}
return "Start CI"
- name: Send CI details
# don't send on push to master
if: github.event.issue.pull_request && startsWith(github.event.comment.body, '/ci')
uses: actions-ecosystem/action-create-comment@v1
env:
OPERATOR_BRANCH: ${{ steps.operator_branch.outputs.result }}
ANSWER: ${{ steps.set-answer.outputs.result }}
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
body: |
@${{ github.actor }} ${{ env.ANSWER }}.
Operator branch: ${{ env.OPERATOR_BRANCH }}
Go Version: ${{ env.go_version }}
GoLangCI Version: ${{ env.golangci_version }}
Helm Version: ${{ env.helm_version }}
Kubectl Version: ${{ env.kubectl_version }}
- name: Check on failures
if: steps.checkout_branch.outcome != 'success'
run: exit 1
- name: Set environment variables
run: |
echo "CSI_BAREMETAL_DIR=$RUNNER_WORKSPACE/csi-baremetal/" >> $GITHUB_ENV
echo "CSI_BAREMETAL_OPERATOR_DIR=$RUNNER_WORKSPACE/csi-baremetal/csi-baremetal-operator" >> $GITHUB_ENV
- name: Set CSI_VERSION
run: |
cd ${{ env.CSI_BAREMETAL_DIR }}
echo "CSI_VERSION=`make version`" >> $GITHUB_ENV
- name: Set CSI_OPERATOR_VERSION
run: |
cd ${{ env.CSI_BAREMETAL_OPERATOR_DIR }}
echo "CSI_OPERATOR_VERSION=`make version`" >> $GITHUB_ENV
- name: Send tested versions
# don't send on push to master
if: github.event.issue.pull_request && startsWith(github.event.comment.body, '/ci')
uses: actions-ecosystem/action-create-comment@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
body: |
Versions using in CI
CSI Version: ${{ env.CSI_VERSION }}
OPERATOR Version: ${{ env.CSI_OPERATOR_VERSION }}
- name: LVM2 install
run: sudo apt-get install -y lvm2
- name: Prepare Golang
uses: actions/setup-go@v2
with:
go-version: ${{ env.go_version }}
- name: Install helm
uses: azure/setup-helm@v1
with:
version: ${{ env.helm_version }}
- name: Kubectl install
uses: azure/setup-kubectl@v1
with:
version: ${{ env.kubectl_version }}
- name: Get dependencies
run: make dependency
#TODO: Generate CRD - #618
- name: Build binary
run: |
make build
make DRIVE_MANAGER_TYPE=loopbackmgr build-drivemgr
#TODO: Install and compile proto - #613
- name: Download health-probe
run: make download-grpc-health-probe
- name: Build docker images
run: |
make images REGISTRY=${{ env.REGISTRY }}
make DRIVE_MANAGER_TYPE=loopbackmgr image-drivemgr REGISTRY=${{ env.REGISTRY }}
- name: Build Operator docker image
run: |
cd ${{env.CSI_BAREMETAL_OPERATOR_DIR}}
make docker-build REGISTRY=${{ env.REGISTRY }}
- name: Kind preparation
run: |
cd ${{env.CSI_BAREMETAL_DIR}}
make kind-build
make kind-create-cluster KIND_CONFIG=${{env.kind_config}} KIND_WAIT=${{env.kind_wait}}
kubectl cluster-info --context kind-kind
kubectl get pods -o wide --all-namespaces
echo "current-context:" $(kubectl config current-context)
echo "environment-kubeconfig:" ${KUBECONFIG}
- name: Sidecars preparing
run: |
make deps-docker-pull
make deps-docker-tag
- name: Retag CSI images and load them to kind
run: |
docker images
make kind-tag-images TAG=$CSI_VERSION REGISTRY=${{ env.REGISTRY }}
make kind-load-images TAG=$CSI_VERSION REGISTRY=${{ env.REGISTRY }}
make kind-tag-operator-image OPERATOR_VERSION=$CSI_OPERATOR_VERSION REGISTRY=${{ env.REGISTRY }}
make kind-load-operator-image OPERATOR_VERSION=$CSI_OPERATOR_VERSION
- name: Make test
continue-on-error: true
id: tests
run: make test-short-ci CSI_VERSION=$CSI_VERSION OPERATOR_VERSION=$CSI_OPERATOR_VERSION CHARTS_DIR=${{env.CSI_BAREMETAL_OPERATOR_DIR}}/charts
- name: Publish Unit Test Results
if: github.event.issue.pull_request && startsWith(github.event.comment.body, '/ci')
uses: EnricoMi/publish-unit-test-result-action@v1
with:
check_name: "E2E Test Results"
commit: '${{ steps.sha.outputs.result }}'
files: tests/e2e/reports/report.xml
hide_comments: off
check_run_annotations: all tests
comment_mode: create new
- uses: montudor/action-zip@v1
with:
args: zip -qq -r reports.zip tests/e2e/reports
- name: Upload report to artifacts
uses: actions/upload-artifact@v2.2.1
with:
name: e2e_artifacts_archive
path: reports.zip
- name: Upload report to artifacts
uses: actions/upload-artifact@v2.2.1
with:
name: e2e_artifacts_log
path: tests/log.txt
- name: Fail if test fails
if: steps.tests.outcome != 'success'
uses: actions/github-script@v3
with:
script: |
core.setFailed('E2E Tests failed!')
result_job:
needs: e2e
# answer must be posted on PR with /ci comment only
if: always() && github.event_name == 'issue_comment' && startsWith(github.event.comment.body, '/ci')
runs-on: ubuntu-20.04
steps:
- name: Create answer body
uses: actions/github-script@v5
id: set-answer
env:
TEST_RESULT: ${{ needs.e2e.result }}
with:
result-encoding: string
script: |
const { TEST_RESULT } = process.env
if (`${TEST_RESULT}` === 'failure' ){
return "CI tests failed"
} else if (`${TEST_RESULT}` === 'success'){
return "CI tests passed"
}
return "CI tests canceled"
- name: answer
uses: actions-ecosystem/action-create-comment@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
body: |
@${{ github.actor }}, ${{ steps.set-answer.outputs.result }} Run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}