-
Notifications
You must be signed in to change notification settings - Fork 0
103 lines (92 loc) · 3.49 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
# validate any chart changes under charts directory
name: Auto Chart Lint
env:
HELM_VERSION: v3.8.1
KIND_VERSION: v0.12.0
K8S_VERSION: v1.23.4
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 ::set-output name=ref::${{ inputs.ref }}
elif ${{ github.event_name == 'workflow_dispatch' }} ; then
echo "trigger by workflow_dispatch"
echo ::set-output name=ref::${{ github.event.inputs.ref }}
elif ${{ github.event_name == 'pull_request' }} ; then
echo "trigger by pull_request"
echo ::set-output name=ref::${{ github.event.pull_request.head.sha }}
else
echo "error, trigger by unknown event ${{ github.event_name }}"
exit 1
fi
# https://github.com/actions/checkout
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ steps.get_ref.outputs.ref }}
# 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/[email protected]
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 "::set-output name=changed::true"
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: steps.list-changed.outputs.changed == 'true'
uses: helm/[email protected]
with:
wait: 120s
kubectl_version: ${{ env.K8S_VERSION }}
# It automatically detects charts changed
- name: Run chart-testing (install)
run: ct install --debug --target-branch ${{ env.DEFAULT_BRANCH }}
# https://github.com/helm/helm/issues/8036 do below before ct install
# if [ -f "./Chart.lock" ]; then cat ./Chart.lock | grep repository | awk '{print $2}' | while read -r line ; do helm repo add $line $line; done; fi