-
-
Notifications
You must be signed in to change notification settings - Fork 129
381 lines (330 loc) · 12.3 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
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
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
---
name: CI
env:
WSLENV: "HELM_SECRETS_BACKEND:BATS_REPORT_FILENAME:BATS_TEST_NAME_PREFIX"
VERSION_HELM: v3.15.3
VERSION_SOPS: v3.9.0
VERSION_VALS: v0.37.3
on:
pull_request:
push:
branches:
- main
paths-ignore:
- 'docs/**'
jobs:
lint:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '[ci skip]')"
steps:
- uses: actions/checkout@v4
- name: Run the sh-checker
uses: luizm/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SHELLCHECK_OPTS: -x
with:
sh_checker_comment: true
sh_checker_exclude: "tests/assets tests/bats"
- name: Run the sh-checker
uses: luizm/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SHELLCHECK_OPTS: -x
with:
sh_checker_comment: true
sh_checker_exclude: "tests/"
sh_checker_shfmt_disable: true
sh_checker_shellcheck_disable: true
sh_checker_checkbashisms_enable: true
unit-tests:
runs-on: ${{ matrix.os }}
container: ${{ matrix.container }}
env:
HELM_SECRETS_WINDOWS_SHELL: ${{ matrix.shell == 'wsl' && 'wsl' || 'bash' }}
if: "!contains(github.event.head_commit.message, '[ci skip]')"
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
container: [""]
shell: [dash]
jobs: [4]
include:
- os: windows-latest
shell: bash
jobs: 1
- os: windows-latest
shell: cygwin
jobs: 1
- os: windows-latest
shell: wsl
jobs: 4
- os: macos-latest
shell: bash 3.2
jobs: 4
- os: macos-latest
shell: bash 3.2 with coreutils
jobs: 4
#- os: ubuntu-latest
# container: centos:7
# shell: bash 4.2
# jobs: 4
- os: ubuntu-latest
container: registry.access.redhat.com/ubi8/ubi-minimal
shell: bash 4.4
jobs: 4
- os: ubuntu-latest
container: alpine
shell: zsh
jobs: 4
- os: ubuntu-latest
container: alpine
shell: ash
jobs: 4
- os: ubuntu-latest
container: ubuntu:22.04
shell: posh
jobs: 4
steps:
- name: Install dependencies
if: "matrix.container"
run: |-
if command -v apk > /dev/null; then
apk add --no-cache bash git gnupg parallel
elif command -v apt-get > /dev/null; then
apt-get update -qqy
apt-get install -qqy git unzip gnupg curl parallel
elif command -v yum > /dev/null; then
if [ "$(rpm -E %{rhel})" == "7" ]; then
yum-config-manager --add-repo='https://download.copr.fedorainfracloud.org/results/jkroepke/git/epel-$releasever-x86_64/'
rpm --import https://download.copr.fedorainfracloud.org/results/jkroepke/git/pubkey.gpg
fi
echo -e '[epel]\nname=Extra Packages for Enterprise Linux $releasever - $basearch\nmetalink=https://mirrors.fedoraproject.org/metalink?repo=epel-$releasever&arch=$basearch&infra=$infra&content=$contentdir\nenabled=1\ngpgcheck=1\ngpgkey=https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-7' > /etc/yum.repos.d/epel.repo
yum install -y git-core unzip parallel
elif command -v microdnf > /dev/null; then
if [ "$(rpm -E %{rhel})" == "7" ]; then
echo -e '[copr:copr.fedorainfracloud.org:jkroepke:git]\nname=Copr repo for git owned by jkroepke\nbaseurl=https://download.copr.fedorainfracloud.org/results/jkroepke/git/epel-7-$basearch/\ntype=rpm-md\nenabled=0\ngpgcheck=1\ngpgkey=https://download.copr.fedorainfracloud.org/results/jkroepke/git/pubkey.gpg\nrepo_gpgcheck=0\nenabled=1\nenabled_metadata=1' > /etc/yum.repos.d/jkroepke-git.repo
fi
echo -e '[epel]\nname=Extra Packages for Enterprise Linux $releasever - $basearch\nmetalink=https://mirrors.fedoraproject.org/metalink?repo=epel-$releasever&arch=$basearch&infra=$infra&content=$contentdir\nenabled=1\ngpgcheck=1\ngpgkey=https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-8' > /etc/yum.repos.d/epel.repo
microdnf install --nodocs git-core unzip tar findutils diffutils parallel
# remove xargs from RHEL image to keep compatibility with OpenShift GitOps
rm -f "$(which xargs)"
fi
- name: Install zsh
if: "contains(matrix.shell, 'zsh')"
run: apk add zsh && ln -sf "$(command -v zsh)" /bin/sh
- name: Install posh
if: "contains(matrix.shell, 'posh')"
run: apt install -y posh && ln -sf "$(command -v posh)" /bin/sh
- name: Disable autocrlf
run: |-
git config --global core.autocrlf false
git config --global core.eol lf
if: "contains(matrix.os, 'windows-latest')"
# this is to fix https://github.com/actions/checkout/issues/760
- run: git config --global --add safe.directory /__w/helm-secrets/helm-secrets
- uses: actions/checkout@v4
with:
submodules: true
- name: Setup Helm
uses: azure/setup-helm@v4
with:
version: ${{ env.VERSION_HELM }}
- name: Setup Sops
uses: mdgreenwald/[email protected]
with:
version: ${{ env.VERSION_SOPS }}
- name: Setup vals
uses: jkroepke/[email protected]
with:
version: ${{ env.VERSION_VALS }}
- name: Setup Cygwin
if: "contains(matrix.shell, 'cygwin')"
uses: cygwin/cygwin-install-action@v4
with:
platform: x64
packages: gnupg2
- name: Setup WSL
if: "contains(matrix.shell, 'wsl')"
uses: Vampire/setup-wsl@v3
- name: Setup coreutils
if: "contains(matrix.shell, 'coreutils')"
run: |-
brew install coreutils
echo "/usr/local/opt/coreutils/libexec/gnubin" >> $GITHUB_PATH
- name: Setup parallel (mac OS)
if: "contains(matrix.os, 'macos-latest')"
run: brew install parallel
- name: Setup parallel (WSL)
if: "contains(matrix.shell, 'wsl')"
run: wsl bash -c 'apt-get update -qq && apt-get install -yqq parallel'
- name: Print Environment
continue-on-error: true
run: |-
bash -c 'echo "Shell: $(readlink /bin/sh || readlink /var/select/sh || echo unknown)"'
bash tests/bats/core/bin/bats -v
sops --version
gpg --version
vals version
- name: Run helm-secrets w/o bats
run: |-
helm plugin install "${{ github.event_name == 'pull_request'
&& format('{0}/{1}', github.server_url, github.event.pull_request.head.repo.full_name)
|| format('{0}/{1}', github.server_url, github.repository)
}}" --version "${{ github.event_name == 'pull_request'
&& github.head_ref
|| github.ref
}}"
helm secrets -v
- name: HELM_SECRETS_BACKEND=sops bats --tap -r tests/unit
run: ${{ contains(matrix.shell, 'wsl') && 'wsl' || '' }} bash tests/bats/core/bin/bats --jobs ${{ matrix.jobs }} --timing --tap --report-formatter junit -r tests/unit
env:
HELM_SECRETS_BACKEND: sops
BATS_TEST_NAME_PREFIX: "[${{ matrix.os }}|${{ matrix.shell }}|sops] "
BATS_REPORT_FILENAME: TEST-sops.xml
- name: HELM_SECRETS_BACKEND=vals bats --tap -r tests/unit
if: "!contains(matrix.shell, 'cygwin')"
run: ${{ contains(matrix.shell, 'wsl') && 'wsl' || '' }} bash tests/bats/core/bin/bats --jobs ${{ matrix.jobs }} --timing --tap --report-formatter junit -r tests/unit
env:
HELM_SECRETS_BACKEND: vals
BATS_TEST_NAME_PREFIX: "[${{ matrix.os }}|${{ matrix.shell }}|vals] "
BATS_REPORT_FILENAME: TEST-vals.xml
- name: Upload Test Report
uses: actions/upload-artifact@v4
if: always()
with:
name: junit-test-results-${{ strategy.job-index }}
path: 'TEST-*.xml'
retention-days: 1
coverage:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '[ci skip]')"
env:
BATSLIB_TEMP_PRESERVE: "0"
BATSLIB_TEMP_PRESERVE_ON_FAILURE: "0"
steps:
- uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
- name: Setup Ruby 3.0
uses: ruby/setup-ruby@v1
with:
ruby-version: "3.0"
- name: Setup Helm
uses: azure/setup-helm@v4
with:
version: ${{ env.VERSION_HELM }}
- name: Setup Sops
uses: mdgreenwald/[email protected]
with:
version: ${{ env.VERSION_SOPS }}
- name: Setup vals
uses: jkroepke/[email protected]
with:
version: ${{ env.VERSION_VALS }}
- name: Install bashcov
run: bundle install
- name: Print Environment
run: |-
bash -c 'echo "Shell: $(readlink /bin/sh || readlink /var/select/sh)"'
bash tests/bats/core/bin/bats -v
sops --version
gpg --version
vals version
- name: Prepare bashcov
run: grep -rl 'env sh' scripts | xargs sed -i 's/env sh/env bash/'
- name: bashcov bats --tap -r tests/unit
run: bashcov -- tests/bats/core/bin/bats --tap -r tests/unit
env:
HELM_SECRETS_BACKEND: sops
BASHCOV_COMMAND_NAME: helm-secrets:sops
- name: bashcov bats --tap -r tests/unit
run: bashcov -- tests/bats/core/bin/bats --tap -r tests/unit
env:
HELM_SECRETS_BACKEND: vals
BASHCOV_COMMAND_NAME: helm-secrets:vals
- uses: codecov/codecov-action@v4
with:
files: ./coverage/coverage.xml
fail_ci_if_error: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- run: rm -rf ./coverage/
- uses: helm/[email protected]
- name: bashcov bats --tap -r tests/it
run: bashcov -- tests/bats/core/bin/bats --tap -r tests/it
env:
BASHCOV_COMMAND_NAME: helm-secrets:it
- uses: codecov/codecov-action@v4
with:
files: ./coverage/coverage.xml
fail_ci_if_error: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
integration-tests:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '[ci skip]')"
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
container: [""]
shell: [dash]
jobs: [4]
steps:
- uses: helm/[email protected]
- run: kubectl cluster-info
- uses: actions/checkout@v4
with:
submodules: true
- name: Setup Helm
uses: azure/setup-helm@v4
with:
version: ${{ env.VERSION_HELM }}
- name: Setup Sops
uses: mdgreenwald/[email protected]
with:
version: ${{ env.VERSION_SOPS }}
- name: Setup vals
uses: jkroepke/[email protected]
with:
version: ${{ env.VERSION_VALS }}
- name: Print Environment
run: |-
echo "Shell: $(readlink /bin/sh || readlink /var/select/sh)"
bash tests/bats/core/bin/bats -v
sops --version
gpg --version
vals version
- name: helm plugin install
run: helm plugin install .
- run: bash tests/bats/core/bin/bats --jobs ${{ matrix.jobs }} --timing --tap --report-formatter junit -r tests/it
env:
BATS_TEST_NAME_PREFIX: "[${{ matrix.os }}|${{ matrix.shell }}|sops] "
BATS_REPORT_FILENAME: TEST-sops.xml
- name: Upload Test Report
uses: actions/upload-artifact@v4
if: always()
with:
name: junit-test-results-it-${{ strategy.job-index }}
path: 'TEST-*.xml'
retention-days: 1
if-no-files-found: error
report:
runs-on: ubuntu-latest
if: always()
needs:
- unit-tests
- integration-tests
steps:
- uses: actions/download-artifact@v4
with:
path: .
- name: Publish Test Report
uses: mikepenz/action-junit-report@v5
with:
report_paths: '**/TEST-*.xml'
detailed_summary: true