-
Notifications
You must be signed in to change notification settings - Fork 51
Chore: Set up helmcov and helmdocs for charts. #232
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jordan-simonovski
wants to merge
7
commits into
main
Choose a base branch
from
jordansimonovski/setup-helmcov
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f7c102f
chore: Added helmcov for test coverage checking, and implemented helm…
jordan-simonovski 16269c6
chore: fixed up helmdocs values
jordan-simonovski 2953cca
chore: Address feedback and fix up high priority issues
jordan-simonovski c6d49ea
ci: use helmcov GitHub Action for PR coverage comments
jordan-simonovski b1f7a91
ci: pin helmcov action binary to v0.4.0
jordan-simonovski e1cfcd6
Merge branch 'main' into jordansimonovski/setup-helmcov
jordan-simonovski 5c0c7e6
Merge branch 'main' into jordansimonovski/setup-helmcov
jordan-simonovski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| repo_root="$(git rev-parse --show-toplevel)" | ||
| cd "$repo_root" | ||
|
|
||
| staged="$(git diff --cached --name-only --diff-filter=ACMR || true)" | ||
|
|
||
| if [[ -z "${staged}" ]]; then | ||
| exit 0 | ||
| fi | ||
|
|
||
| chart_changes=false | ||
| docs_changes=false | ||
|
|
||
| while IFS= read -r path; do | ||
| [[ -z "${path}" ]] && continue | ||
| case "${path}" in | ||
| charts/*) | ||
| chart_changes=true | ||
| case "${path}" in | ||
| charts/*/Chart.yaml|charts/*/values.yaml|charts/*/README.md.gotmpl|charts/*/templates/*|scripts/helmdocs.sh|scripts/install-helm-docs.sh) | ||
| docs_changes=true | ||
| ;; | ||
| esac | ||
| ;; | ||
| esac | ||
| done <<< "${staged}" | ||
|
|
||
| if [[ "${chart_changes}" == true ]]; then | ||
| make test | ||
| fi | ||
|
|
||
| if [[ "${docs_changes}" == true ]]; then | ||
| make docs | ||
| if ! git diff --quiet -- charts/clickstack/README.md charts/clickstack-operators/README.md; then | ||
| echo "Chart README(s) are out of date. Run 'make docs' and stage the updated README.md files." >&2 | ||
| exit 1 | ||
| fi | ||
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| name: Helm Template Coverage | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ main ] | ||
| paths: | ||
| - 'charts/**' | ||
| - 'Makefile' | ||
| - 'scripts/**' | ||
| - '.github/workflows/helmcov.yaml' | ||
| pull_request: | ||
| branches: [ main ] | ||
| paths: | ||
| - 'charts/**' | ||
| - 'Makefile' | ||
| - 'scripts/**' | ||
| - '.github/workflows/helmcov.yaml' | ||
|
|
||
| permissions: | ||
| contents: read | ||
| pull-requests: write | ||
|
|
||
| jobs: | ||
| helmcov: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Helm | ||
| uses: azure/setup-helm@v4 | ||
| with: | ||
| version: v3.12.0 | ||
|
|
||
| - name: Build chart dependencies | ||
| run: make chart-deps | ||
|
|
||
| - name: Run helmcov | ||
| uses: jordan-simonovski/helmcov@v1 | ||
| with: | ||
| chart: charts/clickstack | ||
| tests: charts/clickstack/tests | ||
| threshold: "30" | ||
| version: v0.4.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| SHELL := /bin/bash | ||
|
|
||
| include scripts/tool-versions.env | ||
| export HELM_DOCS_VERSION HELMCOV_IMAGE | ||
|
|
||
| CHART ?= charts/clickstack | ||
| HELM_UNITTEST_VERSION ?= v1.0.3 | ||
| HELM_UNITTEST_PLUGIN := https://github.com/helm-unittest/helm-unittest.git | ||
| COVERAGE_THRESHOLD ?= 30 | ||
|
|
||
| .PHONY: help setup hooks chart-deps install-helm-unittest install-helm-docs validate test coverage docs ci | ||
|
|
||
| help: | ||
| @echo "Targets:" | ||
| @echo " make setup Install helm-unittest, helm-docs, chart deps, and git hooks" | ||
| @echo " make test Run helm-unittest and example values validation" | ||
| @echo " make coverage Run helmcov template coverage via Docker (min $(COVERAGE_THRESHOLD)%)" | ||
| @echo " make docs Regenerate chart README files from values.yaml via helm-docs" | ||
| @echo " make ci Run test, coverage, and docs verification" | ||
| @echo "" | ||
| @echo "Variables:" | ||
| @echo " CHART=$(CHART)" | ||
| @echo " HELMCOV_IMAGE=$(HELMCOV_IMAGE)" | ||
| @echo " HELM_UNITTEST_VERSION=$(HELM_UNITTEST_VERSION)" | ||
| @echo " COVERAGE_THRESHOLD=$(COVERAGE_THRESHOLD)" | ||
|
|
||
| setup: hooks install-helm-unittest install-helm-docs chart-deps | ||
| @echo "Setup complete." | ||
|
|
||
| hooks: | ||
| ./scripts/install-hooks.sh | ||
|
|
||
| install-helm-docs: | ||
| ./scripts/install-helm-docs.sh | ||
|
|
||
| chart-deps: | ||
| @command -v helm >/dev/null || { echo "helm is required; install Helm 3 first." >&2; exit 1; } | ||
| helm repo add mongodb https://mongodb.github.io/helm-charts >/dev/null 2>&1 || true | ||
| helm repo add open-telemetry https://open-telemetry.github.io/opentelemetry-helm-charts >/dev/null 2>&1 || true | ||
| helm dependency build $(CHART) | ||
|
|
||
| install-helm-unittest: | ||
| @command -v helm >/dev/null || { echo "helm is required; install Helm 3 first." >&2; exit 1; } | ||
| @if helm plugin list 2>/dev/null | awk '{print $$1}' | grep -qx unittest; then \ | ||
| echo "helm-unittest already installed"; \ | ||
| else \ | ||
| echo "Installing helm-unittest $(HELM_UNITTEST_VERSION)..."; \ | ||
| helm plugin install $(HELM_UNITTEST_PLUGIN) --version $(HELM_UNITTEST_VERSION); \ | ||
| fi | ||
|
|
||
| validate: chart-deps | ||
| helm template clickstack-example $(CHART) -f examples/alb-ingress/values.yaml >/dev/null | ||
| helm template clickstack-example $(CHART) -f examples/api-only/values.yaml >/dev/null | ||
|
|
||
| test: chart-deps validate | ||
| helm unittest $(CHART) | ||
|
|
||
| coverage: chart-deps | ||
| THRESHOLD=$(COVERAGE_THRESHOLD) HELMCOV_IMAGE=$(HELMCOV_IMAGE) ./scripts/helmcov.sh | ||
|
|
||
| docs: install-helm-docs | ||
| ./scripts/helmdocs.sh | ||
|
|
||
| ci: test coverage docs | ||
| @git diff --exit-code -- charts/clickstack/README.md charts/clickstack-operators/README.md | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| # helm-docs source template (README.md is the published doc) | ||
| README.md.gotmpl |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding the Makefile. Can we make sure it also includes other test commands?