-
Notifications
You must be signed in to change notification settings - Fork 0
266 lines (228 loc) · 9.04 KB
/
helm-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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
name: Helm Charts
on:
push:
branches:
- main
- releases/**
pull_request:
workflow_dispatch:
jobs:
vars:
name: Variables
# This is a work-around to be able to properly use variables.
# This job should be made a dependency in order to be able to use its outputs.
runs-on: ubuntu-24.04
outputs:
is_main_branch: ${{ github.ref_type == 'branch' && github.ref_name == 'main' }}
is_release_branch: ${{ github.ref_type == 'branch' && startsWith(github.ref_name, 'releases/') }}
is_pull_request: ${{ github.event_name == 'pull_request' }}
target_branch: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref || github.ref_name }}
lib_charts: ${{ steps.list-charts.outputs.lib_charts }}
charts_to_lint: ${{ steps.list-charts.outputs.charts_to_lint }}
charts_to_test: ${{ steps.list-charts.outputs.charts_to_test }}
charts_to_test_matrix: ${{ steps.list-charts.outputs.charts_to_test_matrix }}
# renovate: github_repository=metallb/metallb versioning=semver
metallb_version: v0.14.9
# renovate: github_repository=halkeye/helm-repo-html versioning=semver
helm_repo_html_version: v0.2.1
timeout-minutes: 1
steps:
- name: Expose variables
run: echo "Exposing variables for proper usage"
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: ${{ github.event_name == 'pull_request' && '0' || '1' }}
- name: Set up python
uses: actions/setup-python@v5
with:
python-version: '3.9'
check-latest: true
- name: Set up chart-testing
if: ${{ github.event_name == 'pull_request' }}
uses: helm/[email protected]
- name: List charts
id: list-charts
run: |
echo "lib_charts=$(./bin/list-charts ${{ github.event_name == 'pull_request' && format('--changed-only --target-branch={0}', github.base_ref) || '' }} --list --delimiter=, --path lib)" | tee -a $GITHUB_OUTPUT
echo "charts_to_lint=$(./bin/list-charts ${{ github.event_name == 'pull_request' && format('--changed-only --target-branch={0}', github.base_ref) || '' }} --list --delimiter=, --path lint)" | tee -a $GITHUB_OUTPUT
echo "charts_to_test=$(./bin/list-charts ${{ github.event_name == 'pull_request' && format('--changed-only --target-branch={0}', github.base_ref) || '' }} --list --delimiter=, --path test)" | tee -a $GITHUB_OUTPUT
echo "charts_to_test_matrix=$(./bin/list-charts ${{ github.event_name == 'pull_request' && format('--changed-only --target-branch={0}', github.base_ref) || '' }} --matrix test)" | tee -a $GITHUB_OUTPUT
lint-charts:
name: Lint Charts
needs:
- vars
runs-on: ubuntu-24.04
if: ${{ needs.vars.outputs.charts_to_lint != '' }}
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Set up Helm
uses: azure/[email protected]
- name: Set up python
uses: actions/setup-python@v5
with:
python-version: '3.9'
check-latest: true
- name: Set up chart-testing
uses: helm/[email protected]
- name: Add helm repositories
run: ./bin/add-repos
- name: Prepare library charts
run: |
lib_charts="${{ needs.vars.outputs.lib_charts }}"
for lc in ${lib_charts//,/ } ; do
# Add values.yaml file so the linter doesn't complain
echo "${lc}/values.yaml"
touch "${lc}/values.yaml"
done
- name: Lint charts
run: >-
ct
lint
--config etc/ct.yaml
--charts ${{ needs.vars.outputs.charts_to_lint }}
test-charts:
name: Test Charts
needs:
- vars
if: ${{ needs.vars.outputs.charts_to_test != '' }}
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.vars.outputs.charts_to_test_matrix) }}
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Set up Helm
uses: azure/[email protected]
- name: Set up python
uses: actions/setup-python@v5
with:
python-version: '3.9'
check-latest: true
- name: Set up chart-testing
uses: helm/[email protected]
- name: Add helm repositories
run: ./bin/add-repos
- name: Create kind cluster
uses: helm/[email protected]
- name: Install metallb for loadbalancer services
run: |
kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/${{ needs.vars.outputs.metallb_version }}/config/manifests/metallb-native.yaml
kubectl wait --namespace metallb-system \
--for=condition=ready pod \
--selector=app=metallb \
--timeout=90s
subnets=$(docker network inspect -f '{{range .IPAM.Config}}{{printf "%s\n" .Subnet}}{{end}}' kind)
printf "subnets:\n%s\n" "${subnets}"
ipv4_subnets=$(echo "$subnets" | grep -E '(([0-9]{1,3})\.){3}([0-9]{1,3})\/([0-9]|[1-2][0-9]|3[0-2])')
printf "ipv4_subnets:\n%s\n" "${ipv4_subnets}"
subnet=$(echo "$ipv4_subnets" | head -n 1)
printf "subnet: '%s'\n" "${subnet}"
net_ip=$(echo "$subnet" | cut -d/ -f1)
printf "net_ip: '%s'\n" "${net_ip}"
cidr=$(echo "$subnet" | cut -d/ -f2)
printf "cidr: '%s'\n" "${cidr}"
if [ $cidr -gt 24 ]; then
echo "CIDR of $subnet needs to be 24 or smaller" 1>&2
exit 1
fi
net_ip_prefix=$(echo $net_ip | cut -d. -f 1-3)
ip_range=$net_ip_prefix.200-$net_ip_prefix.250
printf "ip_range: '%s'\n" "${ip_range}"
cat <<EOF | kubectl apply -f -
apiVersion: metallb.io/v1beta1
kind: IPAddressPool
metadata:
name: example
namespace: metallb-system
spec:
addresses:
- $ip_range
---
apiVersion: metallb.io/v1beta1
kind: L2Advertisement
metadata:
name: empty
namespace: metallb-system
EOF
- name: Create accelleran pull secret
run: >-
kubectl create secret docker-registry
--namespace default
accelleran-secret
--docker-username=${{ secrets.DOCKER_LOGIN }}
--docker-password=${{ secrets.DOCKER_ACCESS_TOKEN }}
- name: Create accelleran license
run: |-
cat <<EOF > license.crt
${{ secrets.ACCELLERAN_LICENSE }}
EOF
kubectl create secret generic \
--namespace default \
accelleran-license \
--from-file=license.crt
- name: Test charts
run: >-
ct
install
--namespace default
--config etc/ct.yaml
--charts ${{ matrix.chart_path }}
--helm-extra-set-args "--set=kafka.provisioning.useHelmHooks=false"
release-charts:
name: Release Charts
if: ${{ needs.vars.outputs.is_main_branch == 'true' || needs.vars.outputs.is_release_branch == 'true' }}
needs:
- vars
- lint-charts
- test-charts
runs-on: ubuntu-24.04
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- name: Set git user
uses: git-actions/set-user@v1
- name: Install Helm
uses: azure/[email protected]
- name: Install helm repo html plugin
if: ${{ needs.vars.outputs.is_main_branch == 'true' }}
run: helm plugin install https://github.com/halkeye/helm-repo-html --version ${{ needs.vars.outputs.helm_repo_html_version }}
- name: Add helm repositories
run: ./bin/add-repos
- name: Run chart releaser
uses: helm/[email protected]
with:
config: etc/cr.yaml
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- name: Generate repo html index
if: ${{ needs.vars.outputs.is_main_branch == 'true' }}
run: |-
git checkout gh-pages
git pull # pull index.yaml commit from chart releaser
helm repo-html
if ! git diff --exit-code index.html > /dev/null 2>&1 ; then
git add index.html
git commit -s -m "Update index.html"
git push
fi
git checkout -
release-please:
name: Release
if: ${{ needs.vars.outputs.is_main_branch == 'true' || needs.vars.outputs.is_release_branch == 'true' }}
# Run after release-charts so that the tag exists in case of release commits.
# Otherwise release please will create a new PR
# as it doesn't yet have the release to compare changes with.
needs:
- vars
- release-charts
permissions:
contents: write
pull-requests: write
uses: ./.github/workflows/release-please.yaml