-
Notifications
You must be signed in to change notification settings - Fork 109
390 lines (376 loc) · 15.7 KB
/
tests-selectable.yaml
File metadata and controls
390 lines (376 loc) · 15.7 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
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
378
379
380
381
382
383
384
385
386
387
388
389
390
name: Tests-selectable
# This workflow is for running tests based on PR labels
# NOTE:
# The label filter app is used to select tests based on GitHub PR labels
# Tests in the ./int directory are considered an integration test and executed in a separate job
# Tests in the ./e2e directory are considered an end-to-end test and executed in a separate job
# Tests in the ./e2e directory with labels starting with "helm-" are considered Helm tests and executed in a separate job WITHOUT operator image building
# Tests in the ./e2e directory are considered a GOV test ONLY IF their labels contain "atlas-gov" and executed in a separate job
on:
workflow_call:
workflow_dispatch:
inputs:
testLabels:
description: 'Test labels to run'
required: false
default: '[]'
branchName:
description: 'The branch name to checkout'
required: false
default: 'main'
jobs:
detect-tests:
name: "Select tests to run"
runs-on: ubuntu-latest
outputs:
int_matrix: ${{ steps.set-matrix.outputs.int_matrix }}
e2e_matrix: ${{ steps.set-matrix.outputs.e2e_matrix }}
e2e_helm_matrix: $ {{ steps.set-matrix.outputs.e2e_helm_matrix }}
e2e_gov_matrix: ${{ steps.set-matrix.outputs.e2e_gov_matrix }}
version: ${{ steps.read_version.outputs.version }}
image_tag: ${{ steps.read_version.outputs.image_tag }}
steps:
- name: Checkout Code
uses: actions/checkout@v6
with:
ref: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.branchName || github.event.pull_request.head.sha }}
- name: Setup GO
uses: actions/setup-go@v6
with:
go-version-file: "${{ github.workspace }}/go.mod"
- name: Install Ginkgo
run: go install github.com/onsi/ginkgo/v2/ginkgo@latest
- name: Get test labels from PR or input
env:
TEST_LABELS: ${{ github.event.inputs.testLabels }}
id: get-labels
uses: actions/github-script@v8
with:
script: |
if (context.eventName === 'pull_request' || context.eventName === 'pull_request_target') {
prLabels = context.payload.pull_request.labels.map(label => label.name);
console.log("PR Labels:", prLabels);
return prLabels;
}
if (context.eventName === "workflow_dispatch") {
inputLabels = process.env.TEST_LABELS;
console.log("Input labels:", inputLabels);
return inputLabels.split(",").map(label => label.trim()).filter(label => label !== "");
}
console.log("Not a PullRequest or WorkflowDispatch event skipping");
return [];
- name: List available Ginkgo test labels
id: fetch-labels
run: |
INT_LABELS=$(cd ./test/int && ginkgo labels | sed 's/^int: //' | jq -s -c '.[0]')
E2E_LABELS=$(cd ./test/e2e && ginkgo labels | sed 's/^e2e: //' | jq -s -c '.[0]')
echo "int_labels=$INT_LABELS" >> $GITHUB_ENV
echo "e2e_labels=$E2E_LABELS" >> $GITHUB_ENV
echo "Available Integration Tests: $INT_LABELS"
echo "Available E2E Tests: $E2E_LABELS"
- name: Compute Test Matrix
id: set-matrix
env:
PR_LABELS: ${{ steps.get-labels.outputs.result }}
INT_LABELS: ${{ env.int_labels }}
E2E_LABELS: ${{ env.e2e_labels }}
SKIP_PREFIXES: "[\"focus\"]"
USE_JSON: true
run: |
make compute-labels
./bin/ginkgo-labels > result.json
echo "Int tests to execute $(cat result.json | jq -c .int)"
echo "E2E tests to execute $(cat result.json | jq -c .e2e)"
echo "E2E Helm tests to execute $(cat result.json | jq -c .e2e_helm)" # ADD THIS LINE
echo "E2E GOV tests to execute $(cat result.json | jq -c .e2e_gov)"
echo "int_matrix=$(cat result.json | jq -c .int)" >> $GITHUB_OUTPUT
echo "e2e_matrix=$(cat result.json | jq -c .e2e)" >> $GITHUB_OUTPUT
echo "e2e_helm_matrix=$(cat result.json | jq -c .e2e_helm)" >> $GITHUB_OUTPUT
echo "e2e_gov_matrix=$(cat result.json | jq -c .e2e_gov)" >> $GITHUB_OUTPUT
- name: Read binary version and image tag
id: read_version
run: |
VERSION=$(jq -r '.next' version.json)
echo "version=${VERSION}" >> ${GITHUB_OUTPUT}
echo "Read version: ${VERSION}"
COMMIT=$(git rev-parse --short HEAD)
IMAGE_TAG="${VERSION}-BUILD-${COMMIT}"
echo "image_tag=${IMAGE_TAG}" >> ${GITHUB_OUTPUT}
echo "Computed image tag: ${IMAGE_TAG}"
compute:
needs: detect-tests
name: "Compute test matrix for k8s versions"
runs-on: ubuntu-latest
outputs:
test_matrix: ${{ steps.test.outputs.matrix }}
steps:
- id: test
name: Compute test matrix for k8s versions
run: |
# Note the use of external single quotes to allow for double quotes at inline YAML array
matrix='["v1.32.8-kind"]'
if [ "${{ github.ref }}" == "refs/heads/main" ];then
matrix='["v1.32.8-kind", "v1.34.0-kind"]'
fi
echo "matrix=${matrix}" >> "${GITHUB_OUTPUT}"
cat "${GITHUB_OUTPUT}"
prepare-e2e-bundle:
needs: detect-tests
name: Prepare E2E Bundle configuration and image
if: ${{ needs.detect-tests.outputs.e2e_matrix != '[]' }}
runs-on: ubuntu-latest
env:
GHCR_REPO: ghcr.io/mongodb/mongodb-atlas-kubernetes-operator-prerelease
GHCR_BUNDLES_REPO: ghcr.io/mongodb/mongodb-atlas-kubernetes-bundles-prerelease
steps:
- name: Check out code
uses: actions/checkout@v6
with:
ref: ${{github.event.pull_request.head.sha}}
submodules: true
fetch-depth: 0
- name: Install devbox
uses: jetify-com/devbox-install-action@v0.14.0
with:
enable-cache: 'true'
- name: Prepare bundle
env:
OPERATOR_IMAGE: ${{ env.GHCR_BUNDLES_REPO }}:${{ steps.detect-tests.outputs.image_tag }}
VERSION: ${{ steps.detect-tests.outputs.image_tag }}
run: |
devbox run -- make bundle-dev
- name: Cache repo files
uses: actions/cache@v5
with:
path: |
./*
key: ${{ github.sha }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Push image
uses: ./.github/actions/build-push-image
with:
file: fast.Dockerfile
version: ${{ needs.detect-tests.outputs.version }}
tags: |
${{ env.GHCR_REPO }}:${{ needs.detect-tests.outputs.image_tag }}
${{ env.GHCR_BUNDLES_REPO }}:${{ needs.detect-tests.outputs.image_tag }}
platforms: linux/amd64
push_to_docker: false
run-integration-tests:
environment: test
needs: detect-tests
if: ${{ needs.detect-tests.outputs.int_matrix != '[]' && fromJSON(needs.detect-tests.outputs.int_matrix) != '[]' }}
strategy:
fail-fast: false
matrix:
test: ${{ fromJSON(needs.detect-tests.outputs.int_matrix) }}
target: [ "test/int" ]
nodes: [12]
runs-on: ubuntu-latest
name: "integration: ${{ matrix.test }}"
steps:
- name: Checkout Code
uses: actions/checkout@v6
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Install devbox
uses: jetify-com/devbox-install-action@v0.14.0
with:
enable-cache: 'true'
- name: Run integration test
env:
ATLAS_ORG_ID: ${{ secrets.ATLAS_ORG_ID }}
ATLAS_PUBLIC_KEY: ${{ secrets.ATLAS_PUBLIC_KEY }}
ATLAS_PRIVATE_KEY: ${{ secrets.ATLAS_PRIVATE_KEY }}
GINKGO_FILTER_LABEL: ${{ matrix.test }}
GINKGO_NODES: ${{ matrix.nodes }}
GO111MODULE: on
GINKGO_EDITOR_INTEGRATION: "true"
run: |
devbox run -- 'make ${{ matrix.target }}'
run-e2e-tests:
needs: [detect-tests, compute, prepare-e2e-bundle]
environment: test
if: ${{ needs.detect-tests.outputs.e2e_matrix != '[]' && fromJSON(needs.detect-tests.outputs.e2e_matrix) != '[]' }}
strategy:
fail-fast: false
matrix:
test: ${{ fromJSON(needs.detect-tests.outputs.e2e_matrix) }}
k8s: ${{ fromJSON(needs.compute.outputs.test_matrix) }}
runs-on: ubuntu-latest
name: "e2e: ${{ matrix.test }}"
steps:
- name: Get repo files from cache
id: get-repo-files-from-cache
uses: actions/cache@v5
with:
path: ./*
key: ${{ github.sha }}
- name: Checkout if cache repo files missed
if: steps.get-repo-files-from-cache.outputs.cache-hit != 'true'
uses: actions/checkout@v6
with:
ref: ${{github.event.pull_request.head.sha}}
submodules: true
fetch-depth: 0
- name: Install devbox
uses: jetify-com/devbox-install-action@v0.14.0
with:
enable-cache: 'true'
- name: Set properties
id: properties
run: |
version=$(echo ${{ matrix.k8s }} | awk -F "-" '{print $1}')
platform=$(echo ${{ matrix.k8s }} | awk -F "-" '{print $2}')
echo "k8s_version=$version" >> $GITHUB_OUTPUT
echo "k8s_platform=$platform" >> $GITHUB_OUTPUT
- name: Run E2E test
env:
MCLI_OPS_MANAGER_URL: "https://cloud-qa.mongodb.com/"
MCLI_ORG_ID: ${{ secrets.ATLAS_ORG_ID}}
MCLI_PUBLIC_API_KEY: ${{ secrets.ATLAS_PUBLIC_KEY }}
MCLI_PRIVATE_API_KEY: ${{ secrets.ATLAS_PRIVATE_KEY }}
BUNDLE_IMAGE: "ghcr.io/mongodb/mongodb-atlas-kubernetes-bundles-prerelease:${{ needs.detect-tests.outputs.image_tag }}"
IMAGE_PULL_SECRET_REGISTRY: ghcr.io
IMAGE_PULL_SECRET_USERNAME: $
IMAGE_PULL_SECRET_PASSWORD: "${{ secrets.GITHUB_TOKEN }}"
TEST_NAME: "${{ matrix.test }}"
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_ACCOUNT_ARN_LIST: ${{ secrets.AWS_ACCOUNT_ARN_LIST }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ vars.AWS_REGION }}
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
GCP_SA_CRED: ${{ secrets.GCP_SA_CRED }}
DATADOG_KEY: ${{ secrets.DATADOG_KEY }}
PAGER_DUTY_SERVICE_KEY: ${{ secrets.PAGER_DUTY_SERVICE_KEY }}
run: |
echo "Using ENV: ${{ steps.select-env.outputs.ENV }}"
devbox run -- make e2e label=${{ env.TEST_NAME }}
- name: Upload operator logs
if: ${{ failure() }}
uses: actions/upload-artifact@v6
with:
name: logs
path: output/**
run-e2e-helm-tests:
needs: [detect-tests, compute]
environment: test
if: ${{ needs.detect-tests.outputs.e2e_matrix != '[]' && fromJSON(needs.detect-tests.outputs.e2e_matrix) != '[]' }}
strategy:
fail-fast: false
matrix:
test: ${{ fromJSON(needs.detect-tests.outputs.e2e_matrix) }}
k8s: ${{ fromJSON(needs.compute.outputs.test_matrix) }}
runs-on: ubuntu-latest
name: "e2e: ${{ matrix.test }}"
steps:
- name: Get repo files from cache
id: get-repo-files-from-cache
uses: actions/cache@v5
with:
path: ./*
key: ${{ github.sha }}
- name: Checkout if cache repo files missed
if: steps.get-repo-files-from-cache.outputs.cache-hit != 'true'
uses: actions/checkout@v6
with:
ref: ${{github.event.pull_request.head.sha}}
submodules: true
fetch-depth: 0
- name: Install devbox
uses: jetify-com/devbox-install-action@v0.14.0
with:
enable-cache: 'true'
- name: Set properties
id: properties
run: |
version=$(echo ${{ matrix.k8s }} | awk -F "-" '{print $1}')
platform=$(echo ${{ matrix.k8s }} | awk -F "-" '{print $2}')
echo "k8s_version=$version" >> $GITHUB_OUTPUT
echo "k8s_platform=$platform" >> $GITHUB_OUTPUT
# TODO: Build image, fix helm tests, run
# - name: Run E2E test
# env:
# MCLI_OPS_MANAGER_URL: "https://cloud-qa.mongodb.com/"
# MCLI_ORG_ID: ${{ secrets.ATLAS_ORG_ID}}
# MCLI_PUBLIC_API_KEY: ${{ secrets.ATLAS_PUBLIC_KEY }}
# MCLI_PRIVATE_API_KEY: ${{ secrets.ATLAS_PRIVATE_KEY }}
# BUNDLE_IMAGE: "ghcr.io/mongodb/mongodb-atlas-kubernetes-bundles-prerelease:${{ needs.detect-tests.outputs.image_tag }}"
# IMAGE_PULL_SECRET_REGISTRY: ghcr.io
# IMAGE_PULL_SECRET_USERNAME: $
# IMAGE_PULL_SECRET_PASSWORD: "${{ secrets.GITHUB_TOKEN }}"
# TEST_NAME: "${{ matrix.test }}"
# AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
# AWS_ACCOUNT_ARN_LIST: ${{ secrets.AWS_ACCOUNT_ARN_LIST }}
# AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# AWS_REGION: ${{ vars.AWS_REGION }}
# AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
# AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
# AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
# AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
# GCP_SA_CRED: ${{ secrets.GCP_SA_CRED }}
# DATADOG_KEY: ${{ secrets.DATADOG_KEY }}
# PAGER_DUTY_SERVICE_KEY: ${{ secrets.PAGER_DUTY_SERVICE_KEY }}
# run: |
# echo "Using ENV: ${{ steps.select-env.outputs.ENV }}"
# devbox run -- make e2e label=${{ env.TEST_NAME }}
# - name: Upload operator logs
# if: ${{ failure() }}
# uses: actions/upload-artifact@v6
# with:
# name: logs
# path: output/**
run-e2e-gov-tests:
needs: detect-tests
environment: gov-test
if: ${{ needs.detect-tests.outputs.e2e_gov_matrix != '[]' && fromJSON(needs.detect-tests.outputs.e2e_gov_matrix) != '[]' }}
strategy:
fail-fast: false
matrix:
test: ${{ fromJSON(needs.detect-tests.outputs.e2e_gov_matrix) }}
runs-on: ubuntu-latest
name: "e2e gov: ${{ matrix.test }}"
steps:
- name: Get repo files from cache
id: get-repo-files-from-cache
uses: actions/cache@v5
with:
path: ./*
key: ${{ github.sha }}
- name: Checkout if cache repo files missed
if: steps.get-repo-files-from-cache.outputs.cache-hit != 'true'
uses: actions/checkout@v6
with:
ref: ${{github.event.pull_request.head.sha}}
submodules: true
fetch-depth: 0
- name: Install devbox
uses: jetify-com/devbox-install-action@v0.14.0
with:
enable-cache: 'true'
- name: Run e2e test
env:
MCLI_PUBLIC_API_KEY: ${{ secrets.ATLAS_GOV_PUBLIC_KEY }}
MCLI_PRIVATE_API_KEY: ${{ secrets.ATLAS_GOV_PRIVATE_KEY }}
MCLI_ORG_ID: ${{ secrets.ATLAS_GOV_ORG_ID}}
MCLI_OPS_MANAGER_URL: "https://cloud-qa.mongodbgov.com/"
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_ACCOUNT_ARN_LIST: ${{ secrets.AWS_ACCOUNT_ARN_LIST }}
PAGER_DUTY_SERVICE_KEY: ${{ secrets.PAGER_DUTY_SERVICE_KEY }}
TEST_NAME: "${{ matrix.test }}"
run: devbox run -- make e2e label=${{ env.TEST_NAME }}
- name: Upload operator logs
if: ${{ failure() }}
uses: actions/upload-artifact@v6
with:
name: logs
path: output/**