-
-
Notifications
You must be signed in to change notification settings - Fork 16
193 lines (168 loc) · 6.22 KB
/
chart-lint.yml
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
name: Chart Lint
on: [push, pull_request]
jobs:
chart-lint:
runs-on: ubuntu-latest
env:
# Force running all charts on master branch
# --all Disables changed charts detection and version increment checking
CT_ALL: ${{ github.ref == 'refs/heads/master' }}
# Multiple KinD version
strategy:
fail-fast: false
matrix:
helm_version: [v3.4.0]
k8s_version: [v1.20.15, v1.22.5, v1.23.17, v1.24.15, v1.26.6, v1.27.3, v1.28.0]
steps:
- name: Checkout
uses: actions/[email protected]
- name: Fetch history
run: git fetch --prune --unshallow
- name: Set up Helm
uses: azure/[email protected]
with:
version: ${{ matrix.helm_version }}
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: 3.7
- name: Set up chart-testing
uses: helm/[email protected]
- name: Run chart-testing (list-changed)
id: list-changed
run: |
changed=$(ct list-changed)
echo "list_changed=$changed" >> $GITHUB_ENV
if [[ -n "$changed" ]]; then
echo "::set-output name=changed::true"
echo "::set-output name=list::$changed"
fi
- name: Comment
uses: peter-evans/create-or-update-comment@v4
id: comment
if: ${{ github.event.pull_request.number }}
with:
token: ${{ secrets.BOT_TOKEN }}
issue-number: ${{ github.event.pull_request.number }}
body: |
Testing on Kubernetes **${{ matrix.k8s_version }}**, Helm **${{ matrix.helm_version }}** ... [(Run ${{ github.run_id }})](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
${{ env.list_changed }}
- name: Run chart-testing (lint)
id: lint
run: |
echo 'LINT_STATUS<<EOF' >> $GITHUB_ENV
ct lint --config .github/ct-lint.yaml || {
echo "$(cat)"
echo "$(cat)" >> $GITHUB_ENV;
echo "$(cat)" >> $GITHUB_STEP_SUMMARY;
STATUS=$(cat);
exit_code=$?; }
echo >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
exit $exit_code
- name: Comment (after ct lint successfully)
uses: peter-evans/create-or-update-comment@v4
if: ${{ success() && github.event.pull_request.number }}
with:
token: ${{ secrets.BOT_TOKEN }}
issue-number: ${{ github.event.pull_request.number }}
comment-id: ${{ steps.comment.outputs.comment-id }}
edit-mode: append
body: |
<details>
<summary>Linting chart successfully :rocket:.</summary>
```
${{ env.LINT_STATUS }}
```
</details>
- name: Comment (after ct lint failure)
uses: peter-evans/create-or-update-comment@v4
if: ${{ failure() && github.event.pull_request.number }}
with:
token: ${{ secrets.BOT_TOKEN }}
issue-number: ${{ github.event.pull_request.number }}
comment-id: ${{ steps.comment.outputs.comment-id }}
edit-mode: append
reactions: -1
body: |
<details>
<summary>Linting chart failure! :no_good:</summary>
```
${{ env.LINT_STATUS }}
```
</details>
- name: Comment (before create KinD cluster)
uses: peter-evans/create-or-update-comment@v4
if: ${{ github.event.pull_request.number }}
with:
token: ${{ secrets.BOT_TOKEN }}
issue-number: ${{ github.event.pull_request.number }}
comment-id: ${{ steps.comment.outputs.comment-id }}
edit-mode: append
body: |
Creating KinD cluster ${{ matrix.kubectl_version }} ...<br />
- name: Create KinD cluster
uses: helm/[email protected]
with:
kubectl_version: ${{ matrix.k8s_version }}
node_image: kindest/node:${{ matrix.k8s_version }}
# if: steps.list-changed.outputs.changed == 'true'
- name: Comment (after create KinD successfully)
uses: peter-evans/create-or-update-comment@v4
if: ${{ success() && github.event.pull_request.number }}
with:
token: ${{ secrets.BOT_TOKEN }}
issue-number: ${{ github.event.pull_request.number }}
comment-id: ${{ steps.comment.outputs.comment-id }}
edit-mode: append
reactions: rocket
body: |
Created KinD cluster ${{ matrix.k8s_version }} successfully.<br />
Installing charts and validating ...<br /><br />
- name: Run chart-testing (install)
id: ct
run: |
{
echo 'TEST_STATUS<<EOF'
ct install --config .github/ct-install.yaml 2>&1 || echo 'failed'
echo
echo 'EOF'
} >> "$GITHUB_ENV"
echo $GITHUB_ENV
- name: Run kubeconform
uses: nlamirault/[email protected]
id: kubeconform
with:
charts: .
- name: Comment (after test success)
uses: peter-evans/create-or-update-comment@v4
if: ${{ success() && github.event.pull_request.number }}
with:
token: ${{ secrets.BOT_TOKEN }}
issue-number: ${{ github.event.pull_request.number }}
comment-id: ${{ steps.comment.outputs.comment-id }}
edit-mode: append
reactions: hooray
body: |
<details>
<summary>Testing chart result </summary>
```
${{ env.TEST_STATUS }}
```
</details>
- name: Comment (after test failure)
uses: peter-evans/create-or-update-comment@v4
if: ${{ failure() && github.event.pull_request.number }}
with:
token: ${{ secrets.BOT_TOKEN }}
issue-number: ${{ github.event.pull_request.number }}
comment-id: ${{ steps.comment.outputs.comment-id }}
edit-mode: append
reactions: -1
body: |
<details>
<summary>Testing chart failure! :no_good:</summary>
```
${{ env.TEST_STATUS }}
```
</details>