-
Notifications
You must be signed in to change notification settings - Fork 1
186 lines (158 loc) · 5.98 KB
/
lint-test.yaml
File metadata and controls
186 lines (158 loc) · 5.98 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
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
## Reference: https://github.com/helm/chart-testing-action
## Reference: https://github.com/quintush/helm-unittest
name: Lint and Test Charts
on:
pull_request:
branches:
- master
types:
- opened
- edited
- reopened
- ready_for_review
- synchronize
paths:
- "charts/**"
concurrency:
group: ${{ github.head_ref }}-lint-test
cancel-in-progress: true
permissions:
contents: read
jobs:
lint-charts:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.list-changed.outputs.matrix }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Helm
uses: azure/setup-helm@v4.2.0
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: 'Set up jq'
uses: dcarbone/install-jq-action@v1.0.1
- name: Set up chart-testing
uses: helm/chart-testing-action@v2.7.0
- name: Run chart-testing (list-changed)
id: list-changed
run: |
set -o xtrace
changed=$(ct list-changed --config ct.yaml)
charts=$(echo "$changed" | tr '\n' ' ' | xargs)
if [[ -n "$changed" ]]; then
echo "changed=true" >> $GITHUB_OUTPUT
echo "changed_charts=$charts" >> $GITHUB_OUTPUT
echo "matrix=$(echo $charts | jq -R 'split(" ")' | jq '. | if index("charts/cf-common-test") then . else . += ["charts/cf-common-test"] end' | jq -c .)" >> $GITHUB_OUTPUT
echo $matrix
fi
- name: Run chart-testing (lint)
run: ct lint --config "ct.yaml" --lint-conf "lintconf.yaml" --debug --excluded-charts "cf-common-test"
- name: Run docs-testing (helm-docs)
id: helm-docs
run: |
./scripts/helm-docs.sh
if [[ $(git diff --stat) != '' ]]; then
echo -e '\033[0;31mDocumentation outdated!\033[0m ❌ Run ./scripts/helm-docs.sh before commit!'
git diff --color
exit 1
else
echo -e '\033[0;32mDocumentation up to date\033[0m ✔'
fi
- name: Run templates version check
id: tpl-versions
run: |
./scripts/update-tpl-version.sh
if [[ $(git diff --stat) != '' ]]; then
echo -e '\033[0;31mNamed templates versions outdated!\033[0m ❌ Run ./scripts/update-tpl-version.sh before commit!'
git diff --color
exit 1
else
echo -e '\033[0;32mNamed templates versions up to date\033[0m ✔'
fi
- name: Create kind cluster
uses: helm/kind-action@v1.13.0
- name: Run chart-testing (install)
run: |
changed=$(ct list-changed --config "ct.yaml")
if [[ "$changed" =~ "charts/cf-common" || "$changed" =~ "charts/builder" || "$changed" =~ "charts/runner" ]]; then
# Do not run `ct install` for cf-common (library chart) or builder/runner
exit 0
fi
if [[ "$changed" =~ "charts/cf-vcluster" ]]; then
# install prometheus CRDs for cf-vcluster to pass installation with plugin enabled
helm install prom-crds --repo https://prometheus-community.github.io/helm-charts prometheus-operator-crds --wait
fi
ct install --config "ct.yaml"
unittest-charts:
needs:
- lint-charts
runs-on: ubuntu-latest
# There are no Unit Test suites in `charts/cf-common`. They are located in `charts/cf-common-test`. So `charts/cf-common` is excluded from this job.
if: ${{ needs.lint-charts.outputs.matrix != '[]' && needs.lint-charts.outputs.matrix != '["charts/cf-common"]' }}
strategy:
matrix:
chart: ${{ fromJSON(needs.lint-charts.outputs.matrix) }}
exclude:
- chart: charts/cf-common
fail-fast: true
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Helm
uses: azure/setup-helm@v4.2.0
with:
version: v3.19.0
- name: Run unit tests
run: |
echo ${{ matrix.chart }}
helm plugin install https://github.com/helm-unittest/helm-unittest --version v0.6.3
helm dep update ${{ matrix.chart }}
helm unittest --color --debug -f "tests/**/*_test.yaml" ${{ matrix.chart }}
push-charts-dev-cm:
needs:
- lint-charts
- unittest-charts
runs-on: ubuntu-latest
strategy:
matrix:
chart: ${{ fromJSON(needs.lint-charts.outputs.matrix) }}
fail-fast: true
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Helm
uses: azure/setup-helm@v4.2.0
- name: Set up yq
uses: chrisdickinson/setup-yq@latest
- name: Set short SHA
run: echo "GITHUB_SHORT_SHA=`echo ${GITHUB_SHA} | cut -c1-8`" >> $GITHUB_ENV
- name: Normalize git branch name
id: git-branch-name
uses: ohueter/normalize-git-branch-name@v1
with:
ref: ${{ github.ref }}
head-ref: ${{ github.head_ref }}
- name: Print normalized branch name and checksum
run: |
echo "Original branch name: ${{ steps.git-branch-name.outputs.original_name }}"
echo "Normalized branch name: ${{ steps.git-branch-name.outputs.name }}"
echo "SHA1 checksum of branch name: ${{ steps.git-branch-name.outputs.hash }}"
echo "Short SHA1 checksum of branch name: ${{ steps.git-branch-name.outputs.short_hash }}"
- name: Push Helm Chart to Dev OCI quay.io
run: |
set -o xtrace
CHART_NAME=$(yq read ${{ matrix.chart }}/Chart.yaml name)
CHART_VERSION=$(yq read ${{ matrix.chart }}/Chart.yaml version)
helm registry login quay.io -u ${{ secrets.QUAY_USERNAME }} -p ${{ secrets.QUAY_PASSWORD }}
helm dependency update ${{ matrix.chart }}
helm package ${{ matrix.chart }} --version $CHART_VERSION
helm push $CHART_NAME-$CHART_VERSION.tgz oci://quay.io/codefresh/charts/dev