Skip to content

Commit 2ee1de5

Browse files
committed
ci: Add smoke test workflow
Add a new GitHub Actions workflow for smoke testing. This workflow triggers on pull requests to the main and release branches as well as direct pushes to the main branch. It sets up a Kind cluster, installs necessary tools, and runs a series of installation and verification steps for the Cluster API Operator, cert-manager, and provider components. The workflow includes steps for error handling and cleanup after tests. Signed-off-by: kahirokunn <[email protected]>
1 parent c773386 commit 2ee1de5

File tree

1 file changed

+201
-0
lines changed

1 file changed

+201
-0
lines changed

.github/workflows/smoke-test.yaml

Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
name: Smoke Test
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
- 'release-*'
8+
push:
9+
branches:
10+
- main
11+
workflow_dispatch:
12+
13+
permissions:
14+
contents: read
15+
16+
jobs:
17+
smoke-test:
18+
runs-on: ubuntu-latest
19+
timeout-minutes: 15
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 0
25+
26+
- name: Set up Go
27+
uses: actions/setup-go@v5
28+
with:
29+
go-version-file: 'go.mod'
30+
31+
- name: Install kubectl
32+
run: |
33+
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
34+
chmod +x kubectl
35+
sudo mv kubectl /usr/local/bin/
36+
37+
- name: Install Helm
38+
run: |
39+
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
40+
41+
- name: Build charts
42+
run: |
43+
make release-chart
44+
45+
# Extract HELM_CHART_TAG from Makefile
46+
HELM_CHART_TAG=$(make -s -f Makefile -p | grep '^HELM_CHART_TAG :=' | cut -d' ' -f3)
47+
echo "HELM_CHART_TAG=$HELM_CHART_TAG" >> $GITHUB_ENV
48+
echo "Detected HELM_CHART_TAG: $HELM_CHART_TAG"
49+
50+
- name: Create kind cluster
51+
run: |
52+
chmod +x ./hack/ensure-kind.sh
53+
./hack/ensure-kind.sh
54+
kind create cluster --name capi-operator-smoke-test --wait 5m
55+
kubectl cluster-info --context kind-capi-operator-smoke-test
56+
57+
- name: Add Helm repositories
58+
run: |
59+
helm repo add jetstack https://charts.jetstack.io
60+
helm repo update
61+
62+
- name: Install cert-manager
63+
run: |
64+
helm install cert-manager jetstack/cert-manager \
65+
--namespace cert-manager \
66+
--create-namespace \
67+
--set installCRDs=true \
68+
--wait \
69+
--timeout 5m
70+
71+
- name: Install Cluster API Operator
72+
run: |
73+
# Use exact chart filename based on HELM_CHART_TAG
74+
CHART_PACKAGE="out/package/cluster-api-operator-${HELM_CHART_TAG}.tgz"
75+
echo "Using chart package: $CHART_PACKAGE"
76+
77+
# Verify the file exists
78+
if [ ! -f "$CHART_PACKAGE" ]; then
79+
echo "Error: Chart package not found: $CHART_PACKAGE"
80+
ls -la out/package/
81+
exit 1
82+
fi
83+
84+
helm install capi-operator "$CHART_PACKAGE" \
85+
--create-namespace \
86+
-n capi-operator-system \
87+
--wait
88+
89+
- name: Wait for CAPI Operator to be ready
90+
run: |
91+
kubectl wait --for=condition=Available --timeout=300s -n capi-operator-system deployment/capi-operator-controller-manager
92+
93+
- name: Deploy providers using cluster-api-operator-providers chart
94+
run: |
95+
# Create values file for providers
96+
cat <<EOF > /tmp/providers-values.yaml
97+
core:
98+
cluster-api:
99+
namespace: capi-system
100+
createNamespace: false
101+
infrastructure:
102+
docker:
103+
namespace: capd-system
104+
createNamespace: false
105+
configSecret:
106+
name: credentials-secret
107+
namespace: default
108+
EOF
109+
110+
# Use exact providers chart filename based on HELM_CHART_TAG
111+
PROVIDERS_CHART_PACKAGE="out/package/cluster-api-operator-providers-${HELM_CHART_TAG}.tgz"
112+
echo "Using providers chart package: $PROVIDERS_CHART_PACKAGE"
113+
114+
# Verify the file exists
115+
if [ ! -f "$PROVIDERS_CHART_PACKAGE" ]; then
116+
echo "Error: Providers chart package not found: $PROVIDERS_CHART_PACKAGE"
117+
ls -la out/package/
118+
exit 1
119+
fi
120+
121+
helm install capi-providers "$PROVIDERS_CHART_PACKAGE" \
122+
-f /tmp/providers-values.yaml \
123+
--wait
124+
125+
- name: Wait for providers to be ready
126+
run: |
127+
echo "Waiting for Core Provider to be ready..."
128+
kubectl wait --for=condition=Ready --timeout=300s -n capi-system coreprovider/cluster-api || true
129+
130+
echo "Waiting for Infrastructure Provider to be ready..."
131+
kubectl wait --for=condition=Ready --timeout=300s -n capd-system infrastructureprovider/docker || true
132+
133+
# Additional wait for deployments
134+
kubectl wait --for=condition=Available --timeout=300s -n capi-system deployment/capi-controller-manager || true
135+
kubectl wait --for=condition=Available --timeout=300s -n capd-system deployment/capd-controller-manager || true
136+
137+
- name: Verify installation
138+
run: |
139+
echo "=== Cluster API Operator Status ==="
140+
kubectl get pods -n capi-operator-system
141+
142+
echo -e "\n=== Core Provider Status ==="
143+
kubectl get coreprovider -A -o wide
144+
kubectl describe coreprovider -n capi-system cluster-api || true
145+
146+
echo -e "\n=== Infrastructure Provider Status ==="
147+
kubectl get infrastructureprovider -A -o wide
148+
kubectl describe infrastructureprovider -n capd-system docker || true
149+
150+
echo -e "\n=== All Pods ==="
151+
kubectl get pods -A | grep -E "(capi-|capd-)"
152+
153+
echo -e "\n=== CRDs ==="
154+
kubectl get crds | grep -E "(cluster.x-k8s.io|operator.cluster.x-k8s.io)"
155+
156+
- name: Check provider health
157+
run: |
158+
# Check if core provider is ready
159+
CORE_READY=$(kubectl get coreprovider -n capi-system cluster-api -o jsonpath='{.status.conditions[?(@.type=="Ready")].status}')
160+
if [ "$CORE_READY" != "True" ]; then
161+
echo "Core provider is not ready"
162+
kubectl get coreprovider -n capi-system cluster-api -o yaml
163+
exit 1
164+
fi
165+
166+
# Check if infrastructure provider is ready
167+
INFRA_READY=$(kubectl get infrastructureprovider -n capd-system docker -o jsonpath='{.status.conditions[?(@.type=="Ready")].status}')
168+
if [ "$INFRA_READY" != "True" ]; then
169+
echo "Infrastructure provider is not ready"
170+
kubectl get infrastructureprovider -n capd-system docker -o yaml
171+
exit 1
172+
fi
173+
174+
echo "All providers are ready!"
175+
176+
- name: Collect debug information on failure
177+
if: failure()
178+
run: |
179+
echo "=== Events ==="
180+
kubectl get events -A --sort-by='.lastTimestamp' | tail -50
181+
182+
echo -e "\n=== CAPI Operator Logs ==="
183+
kubectl logs -n capi-operator-system deployment/capi-operator-controller-manager --tail=100 || true
184+
185+
echo -e "\n=== Core Provider Logs ==="
186+
kubectl logs -n capi-system deployment/capi-controller-manager --tail=100 || true
187+
188+
echo -e "\n=== Infrastructure Provider Logs ==="
189+
kubectl logs -n capd-system deployment/capd-controller-manager --tail=100 || true
190+
191+
echo -e "\n=== Describe Failed Pods ==="
192+
kubectl get pods -A | grep -v Running | grep -v Completed | tail -n +2 | while read namespace name ready status restarts age; do
193+
echo "Describing pod $name in namespace $namespace"
194+
kubectl describe pod -n $namespace $name
195+
echo "---"
196+
done
197+
198+
- name: Clean up
199+
if: always()
200+
run: |
201+
kind delete cluster --name capi-operator-smoke-test || true

0 commit comments

Comments
 (0)