-
Notifications
You must be signed in to change notification settings - Fork 210
174 lines (149 loc) · 5.37 KB
/
lint_test_charts.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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
name: Lint and Test Charts
on: pull_request
jobs:
codespell:
name: Check spelling
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: codespell-project/actions-codespell@master
with:
check_filenames: true
check_hidden: true
skip: ./.git
ignore_words_list: enver,NotIn,aks
lint-test:
name: Lint and test charts
runs-on: ubuntu-latest
outputs:
charts-changed: ${{ steps.changed.outputs.charts }}
bundle-changed: ${{ steps.changed.outputs.bundle }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
- uses: helm/chart-testing-action@v2.6.1
- uses: azure/setup-helm@v4
with:
version: 'v3.0.0'
- name: Set up helm-unittest
run: helm plugin install https://github.com/helm-unittest/helm-unittest
- name: Lint charts
run: ct lint --config .github/ct-lint.yaml
- name: Run unit tests
run: |
for chart in $(ct list-changed --config .github/ct-lint.yaml); do
if [ -d "$chart/tests/" ]; then
helm unittest $chart
fi
done
- name: Check for changed installable charts
id: changed
run: |
set -x
charts=$(ct list-changed --config .github/ct-install.yaml)
if [[ -n "$charts" ]]; then
echo "::set-output name=charts::true"
fi
if [[ -n "$(echo -n "$charts" | grep charts/nri-bundle)" ]]; then
echo "::set-output name=bundle::true"
fi
install-test:
name: Test chart installability
runs-on: ubuntu-latest
if: ${{ needs.lint-test.outputs.charts-changed == 'true' }}
needs: [ lint-test ]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
- uses: helm/chart-testing-action@v2.6.1
- uses: azure/setup-helm@v4
with:
version: 'v3.0.0'
- name: Install Minikube
uses: manusa/actions-setup-minikube@v2.11.0
with:
minikube version: v1.33.1
kubernetes version: v1.28.11
github token: ${{ secrets.GITHUB_TOKEN }}
driver: docker
start args: "--container-runtime=containerd"
- name: Create certificate manager
run: |
helm repo add jetstack https://charts.jetstack.io
kubectl create ns cert-manager
helm install cert-manager jetstack/cert-manager \
--namespace cert-manager \
--set crds.enabled=true
- name: Test install charts
run: ct install --config .github/ct-install.yaml
- name: Test upgrade charts
run: ct install --config .github/ct-install.yaml --upgrade
bundle-integrity:
name: Test nri-bundle dependencies has the same version of the common-library
runs-on: ubuntu-latest
if: ${{ needs.lint-test.outputs.bundle-changed == 'true' }}
needs: [ lint-test ]
steps:
- uses: actions/checkout@v4
- uses: azure/setup-helm@v4
with:
version: 'v3.0.0'
- name: Add helm repositories
run: |
yq '.chart-repos[]' .github/ct-lint.yaml | while read line; do
repo_name=$(cut -d= -f1 <<<"$line");
repo_url=$(cut -d= -f2- <<<"$line");
helm repo add "$repo_name" "$repo_url";
done
- name: Build nri-bundle dependencies
run: helm dependency update ./charts/nri-bundle
- name: Decompress nri-bundle and all its dependencies recursively
run: |
while [ `find charts/nri-bundle -name \*.tgz -or -name \*.tar.gz | wc -l` -gt 0 ]; do
find charts/nri-bundle -name \*.tgz -or -name \*.tar.gz | while read line; do
echo "Decompressing $line..."
tar xzf "$line" -C $(dirname "$line")
echo "Removing $line..."
rm "$line"
done
done
- name: Find versions of the common library
run: |
(
echo CHART NAME: common-library VERSION
find charts/nri-bundle -name Chart.yaml | \
xargs yq eval-all --no-doc '{ .name: (.dependencies | map(select(contains({"name": "common-library"}))) | .[].version ) }' | \
tee versions.txt;
) | column -t -s:
echo ""
echo Versions of the common library detected:
cut -d\ -f2 versions.txt | sort -u
[ $(cut -d\ -f2 versions.txt | sort -u | wc -l) -eq 1 ] || exit 1
bundle-dependencies-check:
name: Test the bundle dependency conditions
runs-on: ubuntu-latest
if: ${{ needs.lint-test.outputs.bundle-changed == 'true' }}
needs: [ lint-test ]
steps:
- uses: actions/checkout@v4
- uses: azure/setup-helm@v4
with:
version: 'v3.0.0'
- name: Add helm repositories
run: |
yq '.chart-repos[]' .github/ct-lint.yaml | while read line; do
repo_name=$(cut -d= -f1 <<<"$line");
repo_url=$(cut -d= -f2- <<<"$line");
helm repo add "$repo_name" "$repo_url";
done
- name: Build nri-bundle dependencies
run: helm dependency update ./charts/nri-bundle
- name: Run dependencies check
run: ./scripts/check-bundle-dependencies.sh