-
Notifications
You must be signed in to change notification settings - Fork 0
200 lines (165 loc) · 5.06 KB
/
ci.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
name: Lint and Test Charts
on:
push:
branches:
- '*'
- '!main'
pull_request:
paths:
- 'charts/**'
jobs:
lint:
name: Lint charts
runs-on: ubuntu-latest
# strategy:
# matrix:
# k8s:
# - v1.16.8
# - v1.17.4
# - v1.18.20
# - v1.19.16
# - v1.20.15
# - v1.21.10
# - v1.22.7
# - v1.23.4
# - v1.24.14
# - v1.25.10
# - v1.26.5
# - v1.27.2
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Set up Helm
uses: azure/setup-helm@v3
with:
version: v3.11.2
- uses: actions/setup-python@v5
with:
python-version: '3.9'
check-latest: true
- name: Set up chart-testing
uses: helm/[email protected]
- name: Run chart-testing (list-changed)
id: list-changed
run: |
changed=$(ct list-changed --target-branch main)
if [[ -n "$changed" ]]; then
echo "changed=true" >> "$GITHUB_OUTPUT"
fi
- name: Run chart-testing (lint)
if: steps.list-changed.outputs.changed == 'true'
run: ct lint --target-branch main
- name: Create kind cluster
if: steps.list-changed.outputs.changed == 'true'
uses: helm/[email protected]
# with:
# kubectl_version: ${{ matrix.k8s }}
- name: Run chart-testing (install)
if: steps.list-changed.outputs.changed == 'true'
run: |
ct install --target-branch main --excluded-charts cloudflared
- name: Show kubernetes resources (debug)
if: steps.list-changed.outputs.changed == 'true' || failure()
run: |
kubectl get pods --all-namespaces
kubectl get pvc --all-namespaces
kubectl get pv --all-namespaces
prepare-tests:
name: Prepare tests
needs: lint
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Set up Helm
uses: azure/setup-helm@v3
with:
version: v3.11.2
- uses: actions/setup-python@v5
with:
python-version: '3.9'
check-latest: true
- name: Set up chart-testing
uses: helm/[email protected]
- name: Run chart-testing (list-changed)
id: list-changed
run: |
changed=$(ct list-changed --target-branch main)
if [[ -n "$changed" ]]; then
echo "changedCharts=$changed" >> "$GITHUB_OUTPUT"
echo "changed=true" >> "$GITHUB_OUTPUT"
fi
- name: Set matrix for build
id: set-matrix
run: |
# See https://stackoverflow.com/a/62953566/11948346
CHARTS="${{ steps.list-changed.outputs.changedCharts }}"
JSON="{\"include\":["
# Loop by lines
while read chart; do
# Set $os. "ubuntu-latest" by default.
os="ubuntu-latest"
# Add build to the matrix only if it is not already included
JSONline="{\"directory\": \"$chart\", \"os\": \"$os\"},"
if [[ "$JSON" != *"$JSONline"* ]]; then
JSON="$JSON$JSONline"
fi
done <<< "$CHARTS"
# Remove last "," and add closing brackets
if [[ $JSON == *, ]]; then
JSON="${JSON%?}"
fi
JSON="$JSON]}"
echo $JSON
# Set output
echo "matrix=$( echo "$JSON" )" >> $GITHUB_OUTPUT
test:
name: Test "${{ matrix.directory }}"
needs: prepare-tests
runs-on: ${{ matrix.os }}
strategy:
matrix: ${{fromJson(needs.prepare-tests.outputs.matrix)}}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Sops Binary Installer
uses: mdgreenwald/[email protected]
id: install
- name: Decrypt secrets
run: |
sops --output-type json --decrypt test/tunnel-credentials.json.enc > test/tunnel-credentials.json
env:
SOPS_AGE_KEY: ${{ secrets.SOPS_AGE_KEY }}
- name: Set up Helm
uses: azure/setup-helm@v3
with:
version: v3.11.2
- uses: actions/setup-python@v5
with:
python-version: '3.9'
check-latest: true
- name: Set up chart-testing
uses: helm/[email protected]
- name: Setup Docker
uses: docker/setup-buildx-action@v3
- name: Install KinD Kubernetes
uses: helm/[email protected]
with:
install_only: true
- uses: zufardhiyaulhaq/[email protected]
with:
version: 1.17.2
- name: Run bats tests
run: |
./test/helpers/bats/bin/bats ${{ matrix.directory }}/test/test.bats --print-output-on-failure