-
Notifications
You must be signed in to change notification settings - Fork 3
151 lines (138 loc) · 6.17 KB
/
lint-test-matrix.yaml
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
name: K8S Matrix - Helm Lint and Test Charts
on: pull_request
jobs:
lint-test:
strategy:
# max-parallel: 5
matrix:
# k8sVersion: [v1.24.0, v1.23.5, v1.22.7, v1.21.10, v1.20.15, v1.19.16, v1.17.17, v1.16.15, v1.15.12, v1.14.10 ]
# k8sVersion: [v1.24.0, v1.23.5, v1.22.7, v1.21.10, v1.20.15, v1.19.16, v1.18.20, v1.17.17, v1.16.15, v1.15.12, v1.14.10, v1.13.12]
k8sVersion: [ v1.27.3, v1.26.3, v1.25.8, v1.24.12, v1.23.17, v1.22.17, v1.21.14, v1.20.15 ]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Helm
uses: azure/setup-helm@v3
with:
version: v3.10.3
- uses: actions/setup-python@v4
with:
python-version: 3.11
- name: Set up chart-testing
uses: helm/[email protected]
- name: Setup go
uses: actions/setup-go@v3
with:
go-version: 1.19
- name: install masterminds/vert
run: go install github.com/Masterminds/vert@latest
- name: setup yq
run: sudo snap install yq
- name: Run chart-testing (list-changed)
id: list-changed
run: |
touch changed.txt
ct list-changed --config ct.yaml > changed.txt || echo "no chart changes"
changed=$(ct list-changed --config ct.yaml)
if [[ -n "$changed" ]]; then
echo "::set-output name=changed::true"
fi
otherschanged=$(egrep -v "argus" changed.txt || echo "")
if [[ -n "$otherschanged" ]]; then
echo "::set-output name=otherschanged::true"
fi
arguschanged=$(egrep "argus" changed.txt || echo "")
if [[ -n "$arguschanged" ]]; then
echo "::set-output name=arguschanged::true"
fi
lmutilchanged=$(grep "lmutil" changed.txt || echo "")
if [[ -n "$lmutilchanged" ]]; then
echo "::set-output name=lmutilchanged::true"
fi
- name: Run chart-testing (lint)
run: ct lint --config ct.yaml --excluded-charts lmutil
- name: Run chart-testing (lint) - lmutil
if: steps.list-changed.outputs.lmutilchanged == 'true'
run: ct lint --validate-yaml=false --config ct.yaml --charts charts/lmutil
- name: Create kind cluster
uses: helm/[email protected]
with:
config: kind-conf.yaml
node_image: kindest/node:${{ matrix.k8sVersion }}
if: steps.list-changed.outputs.changed == 'true'
#- name: Pull images beforehand ct install
# run: |
# ksmVersion=$(yq charts/argus/Chart.yaml -o json | jq ".dependencies[] | select(. | .name == \"kube-state-metrics\")" | jq .version | tr -d '"')
# version=$(helm search repo -r prometheus/kube-state-metrics --version $ksmVersion -o json | jq ".[0].app_version" | tr -d '"')
# docker pull k8s.gcr.io/kube-state-metrics/kube-state-metrics:v$version
# cnm=$(kind get clusters)
# kind load docker-image k8s.gcr.io/kube-state-metrics/kube-state-metrics:v$version --name $cnm
# cscVersion=$(yq charts/collectorset-controller/Chart.yaml -o json | jq .appVersion | tr -d '"')
# argusVersion=$(yq charts/argus/Chart.yaml -o json | jq .appVersion | tr -d '"')
# docker pull logicmonitor/collectorset-controller:$cscVersion
# kind load docker-image logicmonitor/collectorset-controller:$cscVersion --name $cnm
# docker pull logicmonitor/argus:$argusVersion
# kind load docker-image logicmonitor/argus:$argusVersion --name $cnm
- name: Run chart-testing (install) - except argus
if: steps.list-changed.outputs.otherschanged == 'true'
run: |
export K8SVERSION=${{ matrix.k8sVersion }}
while read -r line ; do
echo "installing chart $line"
ct install --config ct.yaml --charts=$line && EXIT_CODE=$(echo $?) || EXIT_CODE=$(echo $?)
if [[ $EXIT_CODE -eq 0 ]]
then
echo "$line is installable on mentioned kubernetes version $K8SVERSION"
else
vc=$(yq $line/Chart.yaml -o json | jq ".kubeVersion" | tr -d '"' | tr -d "'")
echo $vc
v=$(vert "$vc" "$K8SVERSION" || echo "")
if [[ "v$v" == "$K8SVERSION" ]]
then
echo "Error: kubeVersion constraint expects chart to be installed on $K8SVERSION, but it failed to install"
sync
exit 2
else
echo "installation failed as per constraint"
fi
fi
done < <(ct list-changed --config ct.yaml | egrep -v "argus|lmutil")
- name: Run chart-testing (install) - only argus
if: steps.list-changed.outputs.arguschanged == 'true'
run: |
export K8SVERSION=${{ matrix.k8sVersion }}
vcs=$(vert ">= 1.16.0-0" "$K8SVERSION" || echo "")
if [[ "v$vcs" == "$K8SVERSION" ]]
then
kubectl apply -f charts/collectorset-controller/crds/collectorset.yaml
else
kubectl apply -f v1beta1-cs-crd.yaml
fi
while read -r line ; do
ct install --config ct.yaml --charts=$line && EXIT_CODE=$(echo $?) || EXIT_CODE=$(echo $?)
if [[ $EXIT_CODE -eq 0 ]]
then
echo "$line is installable on mentioned kubernetes version $K8SVERSION"
else
vc=$(yq $line/Chart.yaml -o json | jq ".kubeVersion" | tr -d '"' | tr -d "'")
echo $vc
v=$(vert "$vc" "$K8SVERSION" || echo "")
if [[ "v$v" == "$K8SVERSION" ]]
then
echo "Error: kubeVersion constraint expects chart to be installed on $K8SVERSION, but it failed to install"
sync
exit 3
else
echo "installation failed as per constraint"
fi
fi
done < <(echo "charts/argus")
if [[ "v$vcs" == "$K8SVERSION" ]]
then
kubectl delete -f charts/collectorset-controller/crds/collectorset.yaml
else
kubectl delete -f v1beta1-cs-crd.yaml
fi