forked from insights-onprem/ros-ocp-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.tests
More file actions
37 lines (27 loc) · 1.15 KB
/
Copy pathDockerfile.tests
File metadata and controls
37 lines (27 loc) · 1.15 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
FROM registry.access.redhat.com/ubi9/go-toolset:1.23
WORKDIR /go/src/app
# Copy source code
COPY . .
# Switch to root for installations
USER 0
# Set environment variables for test binaries
ENV LOCALBIN=/go/src/app/bin
ENV ENVTEST_K8S_VERSION=1.32.0
ENV ENVTEST_BIN_DIR=/go/src/app/bin
ENV GINKGO_ARGS=-mod=mod
# Create bin directory
RUN mkdir -p ${LOCALBIN}
# Install setup-envtest tool
RUN GOBIN=${LOCALBIN} go install sigs.k8s.io/controller-runtime/tools/setup-envtest@release-0.20
# Install Ginkgo test framework
RUN GOBIN=${LOCALBIN} go install github.com/onsi/ginkgo/v2/ginkgo@latest
# Download Kubernetes test binaries (etcd, kube-apiserver, kubectl)
RUN ${LOCALBIN}/setup-envtest use ${ENVTEST_K8S_VERSION} --bin-dir ${ENVTEST_BIN_DIR} -p path
# Set KUBEBUILDER_ASSETS environment variable for tests
ENV KUBEBUILDER_ASSETS=/go/src/app/bin/k8s/${ENVTEST_K8S_VERSION}-linux-amd64
# Run tests using Ginkgo
# Run tests during build - build will fail if tests fail
RUN set -e && \
echo "Running tests..." && \
${LOCALBIN}/ginkgo ${GINKGO_ARGS} -v ./... || (echo "❌ TESTS FAILED - Build stopped" && exit 1)
RUN echo "✅ TESTS PASSED - Build completed"