Skip to content

Commit b87b6b4

Browse files
authored
CLOUDP-126642: github actions: use workflow call (#574)
1 parent c6c9bdf commit b87b6b4

File tree

5 files changed

+359
-511
lines changed

5 files changed

+359
-511
lines changed

.github/workflows/test-e2e.yml

Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
name: E2E tests.
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
forked:
7+
type: boolean
8+
required: false
9+
default: false
10+
11+
jobs:
12+
prepare-e2e:
13+
name: Prepare E2E configuration and image
14+
runs-on: ubuntu-latest
15+
env:
16+
# uncomment the below for local testing
17+
# DOCKER_REPO: ${{ env.DOCKER_REGISTRY }}/mongodb-atlas-kubernetes-operator
18+
DOCKER_REPO: mongodb/mongodb-atlas-kubernetes-operator-prerelease
19+
steps:
20+
- if: ${{ inputs.forked == false }}
21+
name: Check out code
22+
uses: actions/[email protected]
23+
with:
24+
fetch-depth: 0 # required for tags
25+
26+
- if: ${{ inputs.forked == true }}
27+
name: Check out code
28+
uses: actions/[email protected]
29+
with:
30+
ref: ${{github.event.pull_request.head.ref}}
31+
repository: ${{github.event.pull_request.head.repo.full_name}}
32+
fetch-depth: 0 # required for tags
33+
34+
- name: Prepare tag
35+
id: prepare
36+
uses: ./.github/actions/set-tag
37+
38+
- name: Push Atlas Operator to Registry
39+
uses: docker/build-push-action@v1
40+
with:
41+
username: ${{ secrets.DOCKER_USERNAME }}
42+
password: ${{ secrets.DOCKER_PASSWORD }}
43+
repository: ${{ env.DOCKER_REPO }}
44+
registry: ${{ env.DOCKER_REGISTRY }}
45+
tags: ${{ steps.prepare.outputs.tag }}
46+
47+
e2e:
48+
name: E2E tests
49+
needs: prepare-e2e
50+
runs-on: ubuntu-latest
51+
env:
52+
# uncomment the below for local testing
53+
# DOCKER_REPO: ${{ env.DOCKER_REGISTRY }}/mongodb-atlas-kubernetes-operator
54+
DOCKER_REGISTRY: docker.io
55+
DOCKER_BUNDLES_REPO: mongodbinternal/mongodb-atlas-kubernetes-bundles-prerelease
56+
DOCKER_REPO: mongodb/mongodb-atlas-kubernetes-operator-prerelease
57+
strategy:
58+
fail-fast: false
59+
matrix:
60+
# k8s: ["1.17-kind", "1.19-kind", "1.17-opeshift"] # <supported platform version>-<platform>
61+
k8s: ["v1.21.1-kind"] # <K8sGitVersion>-<Platform>
62+
test:
63+
[
64+
"cluster-ns",
65+
"cluster-wide",
66+
"bundle-test",
67+
"helm-ns",
68+
"helm-wide",
69+
"helm-update",
70+
"serverless-instance",
71+
"multinamespaced",
72+
"privatelink",
73+
"integration-ns",
74+
"x509auth",
75+
"long-run",
76+
]
77+
include:
78+
- k8s: "latest-openshift"
79+
test: "openshift"
80+
81+
steps:
82+
- if: ${{ inputs.forked == false }}
83+
name: Check out code
84+
uses: actions/[email protected]
85+
with:
86+
# Make sure we also get the helm-charts submodule!
87+
submodules: recursive
88+
89+
- if: ${{ inputs.forked == true }}
90+
name: Check out code
91+
uses: actions/[email protected]
92+
with:
93+
ref: ${{github.event.pull_request.head.ref}}
94+
repository: ${{github.event.pull_request.head.repo.full_name}}
95+
# Make sure we also get the helm-charts submodule!
96+
submodules: recursive
97+
98+
- name: Prepare tag
99+
id: prepare
100+
uses: ./.github/actions/set-tag
101+
102+
- name: Generate configuration for the tests
103+
uses: ./.github/actions/gen-install-scripts
104+
with:
105+
IMAGE_URL: ${{ env.DOCKER_REPO }}:${{ steps.prepare.outputs.tag }}
106+
VERSION: ${{ steps.prepare.outputs.tag }}
107+
ENV: dev
108+
109+
- name: Change path for the test
110+
run: |
111+
awk '{gsub(/cloud.mongodb.com/, "cloud-qa.mongodb.com", $0); print}' bundle/manifests/mongodb-atlas-kubernetes.clusterserviceversion.yaml > tmp && mv tmp bundle/manifests/mongodb-atlas-kubernetes.clusterserviceversion.yaml
112+
113+
- name: Push bundle-image for the test
114+
if: ${{ matrix.test == 'openshift' || matrix.test == 'bundle-test' && !env.ACT }}
115+
uses: docker/build-push-action@v1
116+
with:
117+
username: ${{ secrets.DOCKER_USERNAME }}
118+
password: ${{ secrets.DOCKER_PASSWORD }}
119+
repository: ${{ env.DOCKER_BUNDLES_REPO }}
120+
registry: ${{ env.DOCKER_REGISTRY }}
121+
tags: ${{ steps.prepare.outputs.tag }}
122+
dockerfile: bundle.Dockerfile
123+
124+
- name: Set properties
125+
id: properties
126+
run: |
127+
version=$(echo ${{ matrix.k8s }} | awk -F "-" '{print $1}')
128+
platform=$(echo ${{ matrix.k8s }} | awk -F "-" '{print $2}')
129+
echo "::set-output name=k8s_version::$version"
130+
echo "::set-output name=k8s_platform::$platform"
131+
132+
- name: Create k8s Kind Cluster
133+
if: ${{ steps.properties.outputs.k8s_platform == 'kind' && !env.ACT }}
134+
uses: helm/[email protected]
135+
with:
136+
version: v0.11.1
137+
config: test/e2e/config/kind.yaml
138+
node_image: kindest/node:${{ steps.properties.outputs.k8s_version }}
139+
cluster_name: ${{ matrix.test }}
140+
wait: 180s
141+
142+
- name: Setup Go
143+
uses: actions/setup-go@v2
144+
with:
145+
go-version: "1.17"
146+
147+
- name: Download tools for openshift ui tests
148+
if: ${{ steps.properties.outputs.k8s_platform == 'openshift' && !env.ACT }}
149+
run: |
150+
wget https://mirror.openshift.com/pub/openshift-v4/x86_64/clients/ocp/latest-4.6/opm-linux.tar.gz -O opm.tar.gz -q
151+
tar xvf opm.tar.gz
152+
chmod +x opm && sudo mv opm /usr/local/bin/opm
153+
wget https://mirror.openshift.com/pub/openshift-v4/x86_64/clients/ocp/latest-4.6/openshift-client-linux.tar.gz -O openshift.tar.gz -q
154+
tar xvf openshift.tar.gz
155+
chmod +x oc && sudo mv oc /usr/local/bin/oc
156+
157+
opm version
158+
oc version
159+
podman --version
160+
161+
- name: Install MongoCLI
162+
run: |
163+
wget https://github.com/mongodb/mongocli/releases/download/v1.14.0/mongocli_1.14.0_linux_x86_64.deb -O mongocli.deb -q
164+
sudo dpkg -i mongocli.deb
165+
mongocli --version
166+
167+
- name: Install operator-sdk-v1.16.0
168+
run: |
169+
wget https://github.com/operator-framework/operator-sdk/releases/download/v1.16.0/operator-sdk_linux_amd64 -q
170+
chmod +x operator-sdk_linux_amd64 && sudo mv operator-sdk_linux_amd64 /usr/local/bin/operator-sdk
171+
operator-sdk version
172+
173+
- name: Run e2e test
174+
env:
175+
MCLI_PUBLIC_API_KEY: ${{ secrets.ATLAS_PUBLIC_KEY }}
176+
MCLI_PRIVATE_API_KEY: ${{ secrets.ATLAS_PRIVATE_KEY }}
177+
MCLI_ORG_ID: ${{ secrets.ATLAS_ORG_ID}}
178+
MCLI_OPS_MANAGER_URL: "https://cloud-qa.mongodb.com/"
179+
IMAGE_URL: ${{ env.DOCKER_REPO }}:${{ steps.prepare.outputs.tag }}
180+
BUNDLE_IMAGE: "${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_BUNDLES_REPO}}:${{ steps.prepare.outputs.tag }}"
181+
K8S_PLATFORM: "${{ steps.properties.outputs.k8s_platform }}"
182+
K8S_VERSION: "${{ steps.properties.outputs.k8s_version }}"
183+
TEST_NAME: "${{ matrix.test }}"
184+
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
185+
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
186+
OPENSHIFT_USER: ${{ secrets.OPENSHIFT_USER }}
187+
OPENSHIFT_PASS: ${{ secrets.OPENSHIFT_PASS }}
188+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
189+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
190+
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
191+
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
192+
AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
193+
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
194+
GCP_SA_CRED: ${{ secrets.GCP_SA_CRED }}
195+
DATADOG_KEY: ${{ secrets.DATADOG_KEY }}
196+
run: |
197+
helm version
198+
go version
199+
200+
go install github.com/onsi/ginkgo/v2/[email protected] && \
201+
go install github.com/onsi/gomega/...
202+
203+
# no `long-run`, no `broken` tests. `Long-run` tests run as a separate job
204+
[[ $test == 'long-run' ]] && filter='long-run && !broken' || filter="$test"' && !long-run && !broken'
205+
ginkgo --label-filter=\'"${filter}"\' --timeout 120m --nodes=10 -v test/e2e/
206+
207+
- name: Upload operator logs
208+
if: ${{ failure() }}
209+
uses: actions/upload-artifact@v2
210+
with:
211+
name: logs
212+
path: test/e2e/output/**

0 commit comments

Comments
 (0)