-
-
Notifications
You must be signed in to change notification settings - Fork 16
183 lines (159 loc) · 5.82 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
name: Chart Lint
on: [push, pull_request]
jobs:
chart-lint:
runs-on: ubuntu-latest
# Multiple KinD version
strategy:
fail-fast: false
matrix:
helm_version: [v3.4.0]
k8s_version: [v1.20.15, v1.22.5]
steps:
- name: Checkout
uses: actions/checkout@v3.5.2
- name: Fetch history
run: git fetch --prune --unshallow
- name: Set up Helm
uses: azure/setup-helm@v3.5
with:
version: ${{ matrix.helm_version }}
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.7
- name: Set up chart-testing
uses: helm/chart-testing-action@v2.4.0
- 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@v3
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 'CT_LINT<<EOF' >> $GITHUB_ENV
ct lint --config .github/ct-lint.yaml 2>&1 >> $GITHUB_ENV
exit_code=$?
echo 'EOF' >> $GITHUB_ENV
echo $GITHUB_ENV
exit $exit_code
- name: Comment (after ct lint successfully)
uses: peter-evans/create-or-update-comment@v3
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.</summary>
```
${{ env.CT_LINT }}
```
</details>
- name: Comment (after ct lint failure)
uses: peter-evans/create-or-update-comment@v3
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!</summary>
```
${{ env.CT_LINT }}
```
</details>
- name: Comment (before create KinD cluster)
uses: peter-evans/create-or-update-comment@v3
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/kind-action@v1.7.0
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@v3
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 'CT_TEST<<EOF' >> $GITHUB_ENV
ct install --config .github/ct-install.yaml 2>&1 >> $GITHUB_ENV
exit_code=$?
echo 'EOF' >> $GITHUB_ENV
echo $GITHUB_ENV
exit $exit_code
- name: Run kubeconform
uses: nlamirault/helm-kubeconform-action@v0.2.0
id: kubeconform
with:
charts: .
- name: Comment (after test success)
uses: peter-evans/create-or-update-comment@v3
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 successfully.</summary>
```
${{ env.CT_TEST }}
```
</details>
- name: Comment (after test failure)
uses: peter-evans/create-or-update-comment@v3
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!</summary>
```
${{ env.CT_TEST }}
```
</details>