-
Notifications
You must be signed in to change notification settings - Fork 4
124 lines (107 loc) · 3.38 KB
/
ci.yaml
File metadata and controls
124 lines (107 loc) · 3.38 KB
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
name: CI
on:
push:
branches:
- main
pull_request:
merge_group:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions: {}
env:
# renovate: datasource=node-version depName=node
NODE_VERSION: 24.15.0
jobs:
discovery:
name: Discovery
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Build matrix from charts/* containing Chart.yaml
id: set-matrix
shell: bash
run: |
set -euo pipefail
mapfile -t dirs < <(find charts -mindepth 1 -maxdepth 2 -type f -name Chart.yaml -print0 | xargs -0 -n1 dirname | sort -u)
json='{"include":['
first=1
for d in "${dirs[@]}"; do
if [[ $first -eq 1 ]]; then first=0; else json+=","; fi
json+="{\"working-directory\":\"$d\"}"
done
json+="]}"
echo "matrix=$json" >> "$GITHUB_OUTPUT"
echo "Discovered charts matrix: $json"
vitest:
name: Run Vitest
runs-on: ubuntu-24.04
needs: discovery
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install pnpm
uses: pnpm/action-setup@903f9c1a6ebcba6cf41d87230be49611ac97822e # v6.0.3
- name: Setup Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: ${{ env.NODE_VERSION }}
cache: pnpm
- name: Install dev dependencies
run: pnpm install --frozen-lockfile
- name: Prettier check
run: pnpm run prettier:check
- name: Run unit tests (vitest)
run: pnpm run test
helm-tests:
name: Helm Chart Unit Tests
needs: discovery
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.discovery.outputs.matrix) }}
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up Helm
uses: azure/setup-helm@dda3372f752e03dde6b3237bc9431cdc2f7a02a2 # v5.0.0
with:
# renovate: datasource=github-releases depName=helm/helm
version: v3.18.6
- name: Install helm-unittest plugin
run: helm plugin install https://github.com/helm-unittest/helm-unittest
- name: Run Helm chart unit tests
working-directory: ${{ matrix.working-directory }}
run: |
helm unittest -f "templates/tests/**/*.yaml" .
gather-results:
name: Result
runs-on: ubuntu-latest
needs:
- vitest
- helm-tests
if: always()
steps:
- name: Evaluate job results
shell: bash
run: |
declare -A results
results[vitest]="${{ needs.vitest.result }}"
results[helm-tests]="${{ needs.helm-tests.result }}"
echo "Results: ${results[@]}"
failed=0
for k in "${!results[@]}"; do
v="${results[$k]}"
echo "$k => $v"
if [[ "$v" != "success" ]]; then
failed=1
fi
done
if [[ $failed -ne 0 ]]; then
echo "One or more jobs failed. Failing gather-results."
exit 1
fi
echo "All jobs succeeded."