-
Notifications
You must be signed in to change notification settings - Fork 6
152 lines (126 loc) · 4.85 KB
/
helm-e2e.yaml
File metadata and controls
152 lines (126 loc) · 4.85 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
name: Helm Integration Test
on:
push:
branches: [ "main", "master" ]
pull_request:
branches: [ "main", "master" ]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
detect-changes:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Detect changed charts
id: set-matrix
run: |
# Get changed files
if [ "${{ github.event_name }}" = "pull_request" ]; then
CHANGED_FILES=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }})
else
CHANGED_FILES=$(git diff --name-only HEAD~1 HEAD)
fi
echo "Changed files:"
echo "$CHANGED_FILES"
# Find changed charts
CHANGED_CHARTS=()
# Check if mw-kube-agent-v3 chart changed
if echo "$CHANGED_FILES" | grep -E "^charts/mw-kube-agent-v3/" > /dev/null; then
CHANGED_CHARTS+=("mw-kube-agent-v3")
fi
# Create matrix
if [ ${#CHANGED_CHARTS[@]} -eq 0 ]; then
echo "matrix={\"include\":[]}" >> "$GITHUB_OUTPUT"
echo "No charts changed"
else
# Build JSON matrix manually
MATRIX_JSON="{\"include\":["
for i in "${!CHANGED_CHARTS[@]}"; do
if [ $i -gt 0 ]; then
MATRIX_JSON="$MATRIX_JSON,"
fi
MATRIX_JSON="$MATRIX_JSON{\"chart\":\"${CHANGED_CHARTS[$i]}\"}"
done
MATRIX_JSON="$MATRIX_JSON]}"
echo "matrix=$MATRIX_JSON" >> "$GITHUB_OUTPUT"
echo "Changed charts: ${CHANGED_CHARTS[*]}"
fi
integration-test:
needs: detect-changes
if: needs.detect-changes.outputs.matrix != '{"include":[]}'
runs-on: ubuntu-latest
strategy:
matrix: ${{ fromJson(needs.detect-changes.outputs.matrix) }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Helm
uses: azure/setup-helm@v4
with:
version: v3.12.1
- name: Create kind cluster
uses: helm/kind-action@v1.10.0
- name: Update Helm dependencies
run: |
helm dependency update ./charts/${{ matrix.chart }}
- name: Install Helm Chart
run: |
helm install ${{ matrix.chart }}-test ./charts/${{ matrix.chart }} \
--set global.mw.apiKey=${{ secrets.MW_API_KEY }} \
--set global.mw.target=${{ secrets.MW_TARGET }} \
--set global.clusterMetadata.name=integration-test-cluster \
--namespace mw-agent-ns --create-namespace
env:
MW_API_KEY: ${{ secrets.MW_API_KEY }}
MW_TARGET: ${{ secrets.MW_TARGET }}
- name: Wait for Pods to be ready
run: sleep 120
- name: Check Pod status
run: |
kubectl get pods -n mw-agent-ns
- name: Print logs for chart pods
run: |
echo "=== Getting all pods in namespace mw-agent-ns ==="
PODS=$(kubectl get pods -n mw-agent-ns -o jsonpath='{.items[*].metadata.name}')
echo "Found pods: $PODS"
for POD in $PODS; do
echo ""
echo "=== Logs for pod $POD ==="
kubectl logs -n mw-agent-ns $POD --all-containers=true --ignore-errors=true || echo "Could not get logs for $POD"
done
- name: Check if pods are running
run: |
echo "Checking pod status in namespace: mw-agent-ns"
# Get all pods and their status
kubectl get pods -n mw-agent-ns -o wide
# Check for any non-running pods
FAILED_PODS=$(kubectl get pods -n mw-agent-ns -o jsonpath='{range .items[*]}{.metadata.name}{" "}{.status.phase}{" "}{.status.containerStatuses[0].ready}{"\n"}{end}' | awk '$2!="Running" && $2!="Succeeded" || $3=="false" {print $1}')
if [ -n "$FAILED_PODS" ]; then
echo "❌ The following pods are not healthy: $FAILED_PODS"
echo ""
echo "Pod details:"
for pod in $FAILED_PODS; do
echo "=== Pod: $pod ==="
kubectl describe pod -n mw-agent-ns $pod
echo ""
done
exit 1
else
echo "✅ All pods are healthy in namespace mw-agent-ns"
fi
- name: Sleep before cleanup
run: sleep 10
- name: Cleanup
if: always()
run: |
helm uninstall ${{ matrix.chart }}-test -n mw-agent-ns || echo "Failed to uninstall"
kubectl delete namespace mw-agent-ns || echo "Failed to delete namespace"