helm-charts/.taskfiles/charts.yaml
Bernd Schorgers a01a89cb13
feat(common): Release common 4.0.0 (#398)
Co-authored-by: lab-assistant[bot] <180935599+lab-assistant[bot]@users.noreply.github.com>
2025-05-16 08:55:14 +02:00

59 lines
2.2 KiB
YAML

---
# yaml-language-server: $schema=https://taskfile.dev/schema.json
version: "3"
vars:
CT_IMAGE: quay.io/helmpack/chart-testing:v3.6.0
REPO_CONFIG_FILE: .ci/repo-config.yaml
CT_CONFIG_FILE: .ci/ct/ct.yaml
CHARTS_EXCLUDED_FROM_LINT:
sh: yq eval '.excluded-charts-lint | join(",")' {{.REPO_CONFIG_FILE}}
CHARTS_EXCLUDED_FROM_INSTALL:
sh: yq eval '.excluded-charts-install | join(",")' {{.REPO_CONFIG_FILE}}
tasks:
lint:
desc: Run ct-lint on charts
cmds:
- docker run --rm -it --workdir=/data --volume $(pwd):/data {{.CT_IMAGE}} ct lint --config {{.CT_CONFIG_FILE}} --excluded-charts "{{.CHARTS_EXCLUDED_FROM_LINT}}"
silent: true
lint-all:
desc: Run ct-lint on all charts
cmds:
- docker run --rm -it --workdir=/data --volume $(pwd):/data {{.CT_IMAGE}} ct lint --config {{.CT_CONFIG_FILE}} --all --excluded-charts "{{.CHARTS_EXCLUDED_FROM_LINT}}"
silent: true
test:
desc: Test chart [CHART=required]
preconditions:
# Requires https://github.com/kstasik/schema-tools
- which helm schematools yq
- test -d "{{.CHART_DIR}}"
- test -d "{{.CHART_TEST_DIR}}"
requires:
vars:
- CHART
vars:
GLOB: "{{.GLOB | default \"**/*_test.yaml\"}}"
CHART_DIR: "{{.PROJECT_DIR}}/charts/{{.CHART}}"
CHART_TYPE:
sh: yq eval '.type // "application"' {{.PROJECT_DIR}}/charts/{{.CHART}}/Chart.yaml
CHART_TEST_DIR: |-
{{.CHART_DIR}}{{- if eq .CHART_TYPE "library" -}}/test-chart{{- end -}}
dir: "{{.CHART_TEST_DIR}}"
cmds:
- cp "{{.CHART_DIR}}/values.schema.json" "{{.CHART_DIR}}/values.schema.bak"
- schematools process dereference "{{.CHART_DIR}}/values.schema.json" --to-file "{{.CHART_DIR}}/values.schema.json"
- defer: mv "{{.CHART_DIR}}/values.schema.bak" "{{.CHART_DIR}}/values.schema.json"
- helm dep update
- helm unittest --color -f "unittests/{{.GLOB}}" .
silent: true
dependency-cleanup:
desc: clean up chart dependencies
dir: "{{.PROJECT_DIR}}/charts"
cmds:
- find {{.PROJECT_DIR}}/charts/ -mindepth 1 -type f -name 'Chart.lock' -print0 | xargs -r -0 rm
- find {{.PROJECT_DIR}}/charts/ -mindepth 1 -type d -name 'charts' -print0 | xargs -r -0 rm -rf
silent: true