Skip to content

Commit 117e5c4

Browse files
committed
feat: adding helm reusable actions
1 parent 681b07e commit 117e5c4

3 files changed

Lines changed: 178 additions & 0 deletions

File tree

.github/workflows/helm-lint.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Helm Lint
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
path:
7+
description: 'Path to the Helm chart directory'
8+
required: true
9+
type: string
10+
runner:
11+
description: 'Runner label'
12+
required: false
13+
default: 'self-hosted'
14+
type: string
15+
16+
jobs:
17+
helm-lint:
18+
runs-on: ${{ inputs.runner }}
19+
defaults:
20+
run:
21+
working-directory: ${{ inputs.path }}
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
25+
with:
26+
fetch-depth: 0
27+
28+
- name: Install Helm
29+
uses: azure/setup-helm@dda3372f752e03dde6b3237bc9431cdc2f7a02a2 # v5.0.0
30+
31+
- name: Helm lint
32+
run: helm lint .
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Helm Template
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
path:
7+
description: 'Path to the Helm chart directory'
8+
required: true
9+
type: string
10+
values:
11+
description: 'Inline values YAML passed as -f (written to a temp file)'
12+
required: false
13+
default: ''
14+
type: string
15+
set:
16+
description: 'Additional --set overrides. Format: "key=value" per line.'
17+
required: false
18+
default: ''
19+
type: string
20+
release_name:
21+
description: 'Helm release name used during templating'
22+
required: false
23+
default: 'release'
24+
type: string
25+
namespace:
26+
description: 'Kubernetes namespace used during templating'
27+
required: false
28+
default: 'default'
29+
type: string
30+
update_dependencies:
31+
description: 'Run helm dependency update before templating'
32+
required: false
33+
default: false
34+
type: boolean
35+
runner:
36+
description: 'Runner label'
37+
required: false
38+
default: 'self-hosted'
39+
type: string
40+
41+
jobs:
42+
helm-template:
43+
runs-on: ${{ inputs.runner }}
44+
defaults:
45+
run:
46+
working-directory: ${{ inputs.path }}
47+
steps:
48+
- name: Checkout
49+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
50+
with:
51+
fetch-depth: 0
52+
53+
- name: Install Helm
54+
uses: azure/setup-helm@dda3372f752e03dde6b3237bc9431cdc2f7a02a2 # v5.0.0
55+
56+
- name: Update chart dependencies
57+
if: inputs.update_dependencies
58+
run: helm dependency update .
59+
60+
- name: Helm template
61+
env:
62+
VALUES: ${{ inputs.values }}
63+
SET_OVERRIDES: ${{ inputs.set }}
64+
run: |
65+
ARGS=("${{ inputs.release_name }}" . --namespace "${{ inputs.namespace }}")
66+
67+
if [ -n "${VALUES}" ]; then
68+
printf '%s' "${VALUES}" > /tmp/helm-values.yaml
69+
ARGS+=(-f /tmp/helm-values.yaml)
70+
fi
71+
72+
if [ -n "${SET_OVERRIDES}" ]; then
73+
while IFS= read -r line; do
74+
[ -z "$line" ] && continue
75+
ARGS+=(--set "${line}")
76+
done < <(printf '%s\n' "${SET_OVERRIDES}")
77+
fi
78+
79+
helm template "${ARGS[@]}"
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Helm Unit Tests
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
path:
7+
description: 'Path to the Helm chart directory'
8+
required: true
9+
type: string
10+
test_files:
11+
description: 'Glob pattern for test files relative to the chart directory'
12+
required: false
13+
default: 'unittests/**/*.yaml'
14+
type: string
15+
strict:
16+
description: 'Run helm-unittest with --strict flag'
17+
required: false
18+
default: true
19+
type: boolean
20+
helm_unittest_version:
21+
description: 'Version of the helm-unittest plugin to install'
22+
required: false
23+
default: 'v1.1.0' # renovate: datasource=github-releases depName=helm-unittest/helm-unittest
24+
type: string
25+
update_dependencies:
26+
description: 'Run helm dependency update before running tests'
27+
required: false
28+
default: false
29+
type: boolean
30+
runner:
31+
description: 'Runner label'
32+
required: false
33+
default: 'self-hosted'
34+
type: string
35+
36+
jobs:
37+
helm-unittest:
38+
runs-on: ${{ inputs.runner }}
39+
defaults:
40+
run:
41+
working-directory: ${{ inputs.path }}
42+
steps:
43+
- name: Checkout
44+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
45+
with:
46+
fetch-depth: 0
47+
48+
- name: Install Helm
49+
uses: azure/setup-helm@dda3372f752e03dde6b3237bc9431cdc2f7a02a2 # v5.0.0
50+
51+
- name: Update chart dependencies
52+
if: inputs.update_dependencies
53+
run: helm dependency update .
54+
55+
- name: Install helm-unittest plugin
56+
env:
57+
HELM_UNITTEST_VERSION: ${{ inputs.helm_unittest_version }}
58+
run: helm plugin install --verify=false --version "${HELM_UNITTEST_VERSION}" https://github.com/helm-unittest/helm-unittest
59+
60+
- name: Run helm unit tests
61+
env:
62+
STRICT: ${{ inputs.strict }}
63+
TEST_FILES: ${{ inputs.test_files }}
64+
run: |
65+
ARGS=()
66+
[ "${STRICT}" == "true" ] && ARGS+=("--strict")
67+
helm unittest "${ARGS[@]}" --file "${TEST_FILES}" .

0 commit comments

Comments
 (0)