31
31
./mvnw ${MAVEN_ARGS} impsort:check --file pom.xml
32
32
- name : Run unit tests
33
33
run : ./mvnw ${MAVEN_ARGS} -B test --file pom.xml
34
+ spring-boot-integration-test :
35
+ runs-on : ubuntu-latest
36
+ needs : build
37
+ strategy :
38
+ matrix :
39
+ java : [ 11 ]
40
+ distribution : [ temurin ]
41
+ steps :
42
+ - uses : actions/checkout@v2
43
+ - name : Set up Java and Maven
44
+ uses : actions/setup-java@v2
45
+ with :
46
+ distribution : ${{ matrix.distribution }}
47
+ java-version : ${{ matrix.java }}
48
+ cache : ' maven'
49
+ - name : Build
50
+ run : ./mvnw ${MAVEN_ARGS} clean install -DskipTests
51
+ - name : Kubernetes KinD Cluster
52
+ uses : container-tools/kind-action@v1
53
+ with :
54
+ version : v0.11.1
55
+ registry : true
56
+ - name : Install Cert-Manager
57
+ run : |
58
+ OS=$(go env GOOS); ARCH=$(go env GOARCH); curl -sSL -o kubectl-cert-manager.tar.gz https://github.com/cert-manager/cert-manager/releases/download/v1.7.2/kubectl-cert_manager-$OS-$ARCH.tar.gz
59
+ tar xzf kubectl-cert-manager.tar.gz
60
+ sudo mv kubectl-cert_manager /usr/local/bin
61
+ kubectl cert-manager x install
62
+ - name : Run Integration Test
63
+ run : |
64
+ set -x
65
+
66
+ # Create namespace
67
+ kubectl create namespace test
68
+ kubectl config set-context --current --namespace=test
69
+
70
+ # Generate manifests and image
71
+ cd samples/spring-boot
72
+ ./mvnw ${MAVEN_ARGS} clean install -Ddekorate.jib.registry=$KIND_REGISTRY -Ddekorate.jib.group=tests -Ddekorate.jib.version=latest -Ddekorate.jib.autoPushEnabled=true -DskipTests
73
+
74
+ # Install manifests
75
+ kubectl apply -f target/classes/META-INF/dekorate/kubernetes.yml
76
+
77
+ # Wait until the service is started
78
+ kubectl wait --for=condition=available --timeout=600s deployment/spring-boot-sample
79
+
80
+ # First test: verify validating webhook works
81
+ ## Install webhook
82
+ kubectl apply -f k8s/validating-webhook-configuration.yml
83
+
84
+ ## Wait some time to let Cert-Manager to inject issuers
85
+ sleep 10
86
+
87
+ ## Test Pod with missing label: it should fail
88
+ K8S_MESSAGE=$(kubectl apply -f k8s/create-pod-with-missing-label-example.yml 2>&1 >/dev/null)
89
+ if [[ $K8S_MESSAGE != *"Missing label"* ]]; then
90
+ echo "The validation webhook didn't work. Message: $K8S_MESSAGE"
91
+ exit 1
92
+ fi
93
+
94
+ # Second test: verify mutating webhook works
95
+ ## Install webhook
96
+ kubectl apply -f k8s/mutating-webhook-configuration.yml
97
+
98
+ ## Test the same Pod can now be installed because the mutating webhook adds the missing label
99
+ kubectl apply -f k8s/create-pod-with-missing-label-example.yml
100
+ K8S_MESSAGE=`kubectl get pod pod-with-missing-label -o yaml | grep app.kubernetes.io/name`
101
+ if [[ $K8S_MESSAGE != *"mutation-test"* ]]; then
102
+ echo "The mutating webhook didn't work. Message: $K8S_MESSAGE"
103
+ exit 1
104
+ fi
0 commit comments