-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathaction.yml
93 lines (80 loc) · 2.95 KB
/
action.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
name: "Helm Unit Tests"
description: "Run Helm chart unit tests with quintush/helm-unittest"
branding:
icon: check-square
color: green
inputs:
helm-version:
description: "Which version of Helm to install"
required: true
default: "latest"
unittest-version:
description: "Which version of helm-unittest to install"
required: false
default: ""
github-token:
description: "GitHub token, necessary to overcome API rate limits"
required: false
flags:
description: "Flags to pass to helm unittest"
required: false
default: "--color"
charts:
description: "Charts to run tests for, separated by spaces"
required: false
default: ""
install-mode:
description: >-
Whether to force install helm-unittest ("force"), try a simple install
(empty) or skip if the plugin is present ("if-not-present")
required: false
default: ""
runs:
using: "composite"
steps:
- name: Install Helm
uses: azure/[email protected]
with:
version: ${{ inputs.helm-version }}
token: ${{ inputs.github-token }}
- name: Uninstall helm-unittest if present
if: inputs.install-mode == 'force'
run: |
helm plugin uninstall unittest >/dev/null 2>/dev/null \
|| echo "Failed to uninstall plugin, assuming it's not present."
shell: bash
- name: Install helm-unittest
run: |
if helm plugin list | sed 1d | awk '{print $1}' | grep -q '^unittest$'; then
if [ "${{ inputs.install-mode }}" = "if-not-present" ]; then
echo "Plugin already installed, skipping installation step."
exit 0
elif [ "${{ inputs.install-mode }}" != "force" ]; then
echo "Plugin already installed, aborting."
exit 1
fi
fi
helm_ut_plugin_version="${{ inputs.unittest-version }}"
if [ -n "$helm_ut_plugin_version" ] && [ "$helm_ut_plugin_version" != "latest" ]; then
echo "Installing version $helm_ut_plugin_version of helm-unittest"
helm plugin install --version "$helm_ut_plugin_version" https://github.com/helm-unittest/helm-unittest >/dev/null 2>/dev/null
else
echo "Installing latest version of helm-unittest"
helm plugin install https://github.com/helm-unittest/helm-unittest >/dev/null 2>/dev/null
fi
shell: bash
- name: Assemble list of chart directories to test
run: |
tr ' ' '\n' <<< "${{ inputs.charts }}" | grep -v '^$' > charts-to-test || true
find . -type f -name 'Chart.yaml' -exec dirname {} \; > all-charts
[ -z "${{ inputs.charts }}" ] && mv all-charts charts-to-test || true
shell: bash
- name: Fetch chart dependencies
run: |
for chart in $(cat charts-to-test); do
helm dependency update "$chart" >/dev/null
done
shell: bash
- name: Run unit tests
run: helm unittest ${{ inputs.flags }} $(cat charts-to-test)
shell: bash