Skip to content

Commit 17df56b

Browse files
committed
Added spring boot IT as part of the release workflow
1 parent 6cfd48b commit 17df56b

File tree

1 file changed

+72
-1
lines changed

1 file changed

+72
-1
lines changed

.github/workflows/master-snapshot-release.yml

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

0 commit comments

Comments
 (0)