-
Notifications
You must be signed in to change notification settings - Fork 80
115 lines (101 loc) · 3.88 KB
/
call-lint-chart.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
name: Auto Chart Lint
# validate any chart changes under charts directory
env:
HELM_VERSION: v3.8.1
KIND_VERSION: v0.12.0
DEFAULT_BRANCH: main
on:
# pull_request:
# paths:
# - "charts/**"
workflow_call:
inputs:
ref:
required: true
type: string
workflow_dispatch:
inputs:
ref:
description: 'sha, tag, branch'
required: true
default: main
jobs:
chart-lint-test:
runs-on: ubuntu-latest
steps:
- name: Get Ref
id: get_ref
run: |
if ${{ inputs.ref != '' }} ; then
echo "trigger by workflow_call"
echo "ref=${{ inputs.ref }}" >> $GITHUB_ENV
elif ${{ github.event_name == 'workflow_dispatch' }} ; then
echo "trigger by workflow_dispatch"
echo "ref=${{ github.event.inputs.ref }}" >> $GITHUB_ENV
elif ${{ github.event_name == 'pull_request' }} ; then
echo "trigger by pull_request"
echo "ref=${{ github.event.pull_request.head.sha }}" >> $GITHUB_ENV
else
echo "error, trigger by unknown event ${{ github.event_name }}"
exit 1
fi
# https://github.com/actions/checkout
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ env.ref }}
- name: Lint Chart
run: |
make lint_chart_trivy
- name: check version
run: |
chart_version=`cat VERSION | tr -d ' ' | tr -d 'v' `
[ -z "$chart_version" ] && echo "error, failed to find version" && exit 1
echo "check version $chart_version for chart"
! egrep "^version: \"*${chart_version}\"*" charts/spiderpool/Chart.yaml &>/dev/null && echo "error, version in Chart.yaml is not $chart_version" && exit 1
! egrep "^appVersion: \"*${chart_version}\"*" charts/spiderpool/Chart.yaml &>/dev/null && echo "error, appVersion in Chart.yaml is not $chart_version" && exit 1
exit 0
# The cached helm binary path is prepended to the PATH environment variable as well as stored in the helm-path output variable
# https://github.com/Azure/setup-helm
- name: Set up Helm
uses: azure/setup-helm@v4
with:
version: ${{ env.HELM_VERSION }}
# https://github.com/actions/setup-python
- name: Set up Python
uses: actions/[email protected]
with:
python-version: 3.8
architecture: x64
# https://github.com/helm/chart-testing-action
# Pre-requisites: A GitHub repo containing a directory with your Helm charts (e.g: charts)
- name: Set up chart-testing
uses: helm/[email protected]
with:
# CT version
version: v3.6.0
- name: Run chart-testing (list-changed)
id: list-changed
run: |
# https://github.com/helm/chart-testing-action/issues/25
# if the default branch is not master , the CLI exits with error
changed=$( ct list-changed --target-branch ${{ env.DEFAULT_BRANCH }} )
if [[ -n "$changed" ]]; then
echo "changed=true" >> $GITHUB_ENV
fi
# version checking, YAML schema validation on 'Chart.yaml', YAML linting on 'Chart.yaml'
# and 'values.yaml', and maintainer validation
- name: Run chart-testing (lint)
run: ct lint --debug --target-branch=${{ env.DEFAULT_BRANCH }} --check-version-increment=false
# https://github.com/helm/kind-action
- name: Create Kind cluster
if: ${{ env.changed == 'true' }}
uses: helm/[email protected]
with:
wait: 120s
# It automatically detects charts changed
- name: Run chart-testing (install)
run: |
ct install --debug --target-branch ${{ env.DEFAULT_BRANCH }} --namespace kube-system \
--helm-extra-args "--timeout 400s"