Skip to content

Commit 9f77685

Browse files
authored
ci(e2e): start envtest cluster for e2e tests (#565)
* ci: start envtest for e2e tests Signed-off-by: Philippe Martin <phmartin@redhat.com> * fix: correct wait end of process Signed-off-by: Philippe Martin <phmartin@redhat.com> --------- Signed-off-by: Philippe Martin <phmartin@redhat.com>
1 parent 9a21528 commit 9f77685

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

.github/workflows/e2e-tests.yaml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,62 @@ jobs:
137137
name: extension-plugin
138138
path: tests/playwright/tests/playwright/output/kubernetes-dashboard-tests/plugins/
139139

140+
# Run envtest cluster
141+
- uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0
142+
with:
143+
go-version: '1.25'
144+
145+
- name: install envtest-start and setup-envtest binaries
146+
shell: bash
147+
run: |
148+
go install github.com/feloy/envtest-start@563d135d56015062c35bd20f8c14ab5fcbee38ae
149+
go install sigs.k8s.io/controller-runtime/tools/setup-envtest@release-0.22
150+
151+
- name: install envtest with latest kubernetes version with setup-envtest
152+
id: setup-envtest
153+
shell: bash
154+
run: |
155+
export KUBEBUILDER_ASSETS=$(setup-envtest use -p path)
156+
echo "KUBEBUILDER_ASSETS=$KUBEBUILDER_ASSETS" >> $GITHUB_OUTPUT
157+
158+
- name: run envtest-start to start the envtest cluster
159+
id: run-envtest
160+
env:
161+
KUBEBUILDER_ASSETS: ${{ steps.setup-envtest.outputs.KUBEBUILDER_ASSETS }}
162+
shell: bash
163+
run: |
164+
KUBECONFIG=${{ runner.temp }}/envtest-kubeconfig
165+
envtest-start $KUBECONFIG &
166+
ENVTEST_START_PID=$!
167+
echo "ENVTEST_START_PID=$ENVTEST_START_PID" >> $GITHUB_OUTPUT
168+
echo "KUBECONFIG=$KUBECONFIG" >> $GITHUB_OUTPUT
169+
170+
- name: check cluster is accessible, should show a service named "kubernetes"
171+
env:
172+
KUBEBUILDER_ASSETS: ${{ steps.setup-envtest.outputs.KUBEBUILDER_ASSETS }}
173+
KUBECONFIG: ${{ steps.run-envtest.outputs.KUBECONFIG }}
174+
shell: bash
175+
run: |
176+
$KUBEBUILDER_ASSETS/kubectl get all | grep "service/kubernetes"
177+
178+
# Run tests
140179
- name: Run E2E Smoke tests
141180
shell: bash
142181
run: pnpm test:e2e:smoke
143182
env:
144183
NODE_OPTIONS: --no-experimental-strip-types
184+
KUBEBUILDER_ASSETS: ${{ steps.setup-envtest.outputs.KUBEBUILDER_ASSETS }}
185+
KUBECONFIG: ${{ steps.run-envtest.outputs.KUBECONFIG }}
186+
187+
- name: stop envtest cluster
188+
if: always()
189+
env:
190+
ENVTEST_START_PID: ${{ steps.run-envtest.outputs.ENVTEST_START_PID }}
191+
shell: bash
192+
# These commands are working on both Linux and Windows, change carefully
193+
run: |
194+
kill ${ENVTEST_START_PID}
195+
timeout 10s bash -c "while ps | grep envtest-start > /dev/null; do sleep 1; done"
145196
146197
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
147198
if: always()

0 commit comments

Comments
 (0)