-
-
Notifications
You must be signed in to change notification settings - Fork 32
199 lines (171 loc) · 5.53 KB
/
charts-lint-test.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
---
name: "Charts: Lint and test"
on:
pull_request:
paths:
- 'charts/**'
- '!charts/**/README.md'
- '!charts/**/README.md.gotmpl'
jobs:
changes-lint:
if: "!contains(github.event.head_commit.message, '[ci-skip]')"
name: Detect changes for linting
runs-on: ubuntu-20.04
outputs:
matrix: |
{
"chart": ${{ steps.list-changed.outputs.charts }}
}
detected: ${{ steps.list-changed.outputs.detected }}
steps:
- name: Checkout
uses: actions/checkout@v2.7.0
with:
fetch-depth: 0
- name: Set up chart-testing
uses: helm/chart-testing-action@v2.7.0
- name: Install Dev tools
run: |
sudo wget https://github.com/mikefarah/yq/releases/download/v4.2.0/yq_linux_amd64 -O /usr/bin/yq
sudo chmod +x /usr/bin/yq
- name: Run chart-testing (list-changed)
id: list-changed
run: |
EXCLUDED=$(yq eval -j '.excluded-charts // []' .github/ct-lint.yaml)
CHARTS=$(ct list-changed --config .github/ct-lint.yaml)
CHARTS_JSON=$(echo "${CHARTS}" | jq -R -s -c 'split("\n")[:-1]')
OUTPUT_JSON=$(echo "{\"excluded\": ${EXCLUDED}, \"all\": ${CHARTS_JSON}}" | jq -c '.all-.excluded')
echo ::set-output name=charts::${OUTPUT_JSON}
if [[ $(echo ${OUTPUT_JSON} | jq -c '. | length') -gt 0 ]]; then
echo "::set-output name=detected::true"
fi
changes-install:
if: "!contains(github.event.head_commit.message, '[ci-skip]')"
name: Detect changes for install
runs-on: ubuntu-20.04
outputs:
matrix: |
{
"chart": ${{ steps.list-changed.outputs.charts }}
}
detected: ${{ steps.list-changed.outputs.detected }}
steps:
- name: Checkout
uses: actions/checkout@v2.7.0
with:
fetch-depth: 0
- name: Set up chart-testing
uses: helm/chart-testing-action@v2.7.0
- name: Install Dev tools
run: |
sudo wget https://github.com/mikefarah/yq/releases/download/v4.2.0/yq_linux_amd64 -O /usr/bin/yq
sudo chmod +x /usr/bin/yq
- name: Run chart-testing (list-changed)
id: list-changed
run: |
EXCLUDED=$(yq eval -j '.excluded-charts // []' .github/ct-install.yaml)
CHARTS=$(ct list-changed --config .github/ct-install.yaml)
CHARTS_JSON=$(echo "${CHARTS}" | jq -R -s -c 'split("\n")[:-1]')
OUTPUT_JSON=$(echo "{\"excluded\": ${EXCLUDED}, \"all\": ${CHARTS_JSON}}" | jq -c '.all-.excluded')
echo ::set-output name=charts::${OUTPUT_JSON}
if [[ $(echo ${OUTPUT_JSON} | jq -c '. | length') -gt 0 ]]; then
echo "::set-output name=detected::true"
fi
lint:
needs:
- changes-lint
if: "!contains(github.event.head_commit.message, '[ci-skip]') && needs.changes-lint.outputs.detected == 'true'"
name: Lint charts
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2.7.0
with:
fetch-depth: 0
- name: Install Helm
uses: azure/setup-helm@v1.1
with:
version: v3.5.3
- uses: actions/setup-python@v2.3.4
with:
python-version: 3.7
- name: Set up chart-testing
uses: helm/chart-testing-action@v2.7.0
- name: Run chart-testing (lint)
id: lint
run: ct lint --config .github/ct-lint.yaml
unittest:
needs:
- lint
if: "!contains(github.event.head_commit.message, '[ci-skip]')"
name: Run unit tests
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2.7.0
with:
fetch-depth: 0
- name: Install Dev tools
run: sudo apt-get update && sudo apt-get install -y jq libjq-dev
- name: Install Helm
uses: azure/setup-helm@v1.1
with:
version: v3.5.3
- name: Install Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7
- name: Install dependencies
env:
RUBYJQ_USE_SYSTEM_LIBRARIES: 1
run: |
bundle install
- name: Run tests
run: |
bundle exec m -r ./test/
install:
needs:
- changes-install
- lint
if: "!contains(github.event.head_commit.message, '[ci-skip]') && needs.changes-install.outputs.detected == 'true'"
name: Install charts
strategy:
matrix: ${{ fromJson(needs.changes-install.outputs.matrix) }}
fail-fast: true
max-parallel: 15
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2.7.0
with:
fetch-depth: 0
- name: Install Helm
uses: azure/setup-helm@v1.1
with:
version: v3.5.3
- uses: actions/setup-python@v2.3.4
with:
python-version: 3.7
- name: Set up chart-testing
uses: helm/chart-testing-action@v2.7.0
- name: Create k3d cluster
uses: nolar/setup-k3d-k3s@v1
with:
version: v1.19
- name: Remove node taints
run: |
kubectl taint --all=true nodes node.cloudprovider.kubernetes.io/uninitialized- || true
- name: Run chart-testing (install)
run: ct install --config .github/ct-install.yaml --charts ${{ matrix.chart }}
# Summarize matrix https://github.community/t/status-check-for-a-matrix-jobs/127354/7
install_success:
needs:
- changes-install
- install
if: ${{ always() }}
name: Install successful
runs-on: ubuntu-20.04
steps:
- name: Check install matrix status
if: ${{ !contains(github.event.head_commit.message, '[ci-skip]') && needs.changes-install.outputs.detected == 'true' && needs.install.result != 'success' }}
run: exit 1