-
Notifications
You must be signed in to change notification settings - Fork 9
121 lines (107 loc) · 4.22 KB
/
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
name: Lint and test charts - current
on: pull_request
jobs:
yamllint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Helm
run: |
cd /tmp
curl -fsSLo get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3
chmod 700 get_helm.sh
./get_helm.sh
- name: Add dependency chart repos
run: |
helm repo add banzaicloud-stable https://kubernetes-charts.banzaicloud.com
helm repo add lagoon https://uselagoon.github.io/lagoon-charts/
helm repo add amazeeio https://amazeeio.github.io/charts/
helm repo add nats https://nats-io.github.io/k8s/helm/charts/
helm repo add kube-logging https://kube-logging.github.io/helm-charts
- name: Generate helm templates
run: |
cd charts
# hacky workaround for lagoon-test templated values
tests=[foo,bar] envsubst '$tests' < lagoon-test/ci/linter-values.yaml.tpl > lagoon-test/ci/linter-values.yaml
for chart in *; do
helm dependency build $chart
mkdir -p /tmp/charts/$chart
helm template $chart $chart \
--values $chart/ci/linter-values.yaml \
--output-dir /tmp/charts/$chart
done
# workaround until logging-operator templates are fixed:
# https://github.com/banzaicloud/logging-operator/pull/792
rm -rf /tmp/charts/lagoon-logging/lagoon-logging/charts/logging-operator
# workaround until nats templates are fixed
rm -rf /tmp/charts/lagoon-remote/lagoon-remote/charts/nats
rm -rf /tmp/charts/lagoon-core/lagoon-core/charts/nats
- name: Install YAMLlint
run: sudo apt-get -y install yamllint
- name: Lint the templates
run: |
set -euo pipefail
cat > .yamllint <<EOF
extends: default
rules:
indentation:
indent-sequences: consistent
line-length: disable
EOF
yamllint -f parsable /tmp/charts | awk -F: '{print; system("sed \"" $2 "q;d\" " $1)}'
# runs for all charts other than lagoon-test, which is excluded in
# default.ct.yaml
lint-test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: "0"
- name: Set up chart-testing dependencies
run: sudo apt-get -y install python3-wheel
- name: Set up chart-testing
uses: helm/[email protected]
- name: Run chart-testing (list-changed)
id: list-changed
run: |
changed=$(ct list-changed --config ./default.ct.yaml)
if [[ "$changed" ]]; then
echo "changed=true" >> $GITHUB_OUTPUT
echo "$changed"
fi
- name: Run chart-testing (lint)
run: ct lint --config ./default.ct.yaml
- name: Create kind cluster
uses: helm/[email protected]
with:
version: v0.20.0
node_image: kindest/node:v1.27.3@sha256:3966ac761ae0136263ffdb6cfd4db23ef8a83cba8a463690e98317add2c9ba72
kubectl_version: v1.27.3
if: |
(steps.list-changed.outputs.changed == 'true') ||
(contains(github.event.pull_request.labels.*.name, 'needs-testing'))
- name: Run chart-testing (install)
run: ct install --config ./default.ct.yaml
artifacthub-changelog:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: "0"
- name: Install gojq
run: |
cd /tmp
curl -sSLO https://github.com/itchyny/gojq/releases/download/v0.12.13/gojq_v0.12.13_linux_amd64.tar.gz
tar -xf ./gojq_v0.12.13_linux_amd64.tar.gz
sudo cp /tmp/gojq_v0.12.13_linux_amd64/gojq /usr/local/bin/gojq
- name: Run artifacthub.io changelog check
run: |
for chartyaml in $(git diff --name-only origin/main | awk -F/ '/^charts\// { printf "%s/%s/%s\n",$1,$2,"Chart.yaml" }' | sort -u); do
if diff <(gojq -r --yaml-input '.annotations."artifacthub.io/changes"' <(git show HEAD:$chartyaml)) <(gojq -r --yaml-input '.annotations."artifacthub.io/changes"' <(git show origin/main:$chartyaml)); then
echo "$chartyaml artifacthub.io changelog needs an update!"
exit 1
fi
done