Chart Testing
May 12, 2025 ยท View on GitHub
This document explains how to use and customize the chart-testing configuration for this repository.
Overview
The chart-testing pipeline is configured to run automatically on pull requests that modify Helm chart-related files (YAML files, templates, Chart.yaml, etc.) within the clusters directory. It:
- Lints all charts to ensure they follow best practices
- Validates chart structure and schema
- Installs charts in a kind cluster (Kubernetes v1.32) to ensure they deploy successfully
- Runs Helm tests to validate chart functionality
Configuration
GitHub Actions Workflow
The main workflow is defined in .github/workflows/chart-testing.yml. It:
- Runs on pull requests that modify chart-related files in the
clustersdirectory - Uses a two-job approach:
- Lint Job: Validates chart syntax and best practices
- Install and Test Job: Sets up a kind cluster with Kubernetes v1.32, installs charts, and runs Helm tests
- Only creates the kind cluster if there are actually changed charts (optimization)
- Uses chart-testing to detect, lint, install, and test charts
Chart Testing Configuration
The chart-testing configuration is in ct.yaml at the root of the repository. Key settings include:
chart-dirs: Directories containing Helm charts to test (clusters/core/addons only)helm-extra-args: Additional arguments to pass to Helm during installationtarget-branch: The target branch to compare changes againstcheck-version-increment: Ensures chart version is incremented when changes are madelint-conf: Points to thelint-conf.yamlfile containing linting rules and configurationchart-repos: Additional Helm repositories required for dependencies
Linting Configuration
The linting configuration is defined in lint-conf.yaml at the root of the repository. This file contains rules for chart validation, including:
- Rules for Chart Requirements: Enforces best practices like requiring README files, NOTES.txt files, and proper maintainer information
- Validation Rules: Validates chart names, versions, and Kubernetes schema compatibility
- Excluded Charts: Allows excluding certain charts from linting (useful for work-in-progress charts)
- Custom Lint Values: Enables specifying additional values files for linting
These rules help ensure that all charts in the repository maintain consistent quality and follow Helm best practices.
Local Testing
You can run the same tests locally before submitting a pull request. The project includes several Makefile targets to help with testing:
-
Install chart-testing tool (for macOS):
# For Apple Silicon (M1/M2) curl -L https://github.com/helm/chart-testing/releases/latest/download/chart-testing_darwin_arm64.tar.gz | tar xvz -C /tmp chmod +x /tmp/ct sudo mv /tmp/ct /usr/local/bin/ct # For Intel Macs curl -L https://github.com/helm/chart-testing/releases/latest/download/chart-testing_darwin_amd64.tar.gz | tar xvz -C /tmp chmod +x /tmp/ct sudo mv /tmp/ct /usr/local/bin/ct -
View all available Makefile targets:
make help -
Run basic chart linting with chart-testing:
make test-charts -
Run advanced linting with all rules defined in lint-conf.yaml:
make lint-all-charts -
Lint a specific chart using the rules:
make lint-chart CHART=argo-cd -
Work with kind clusters for testing:
# Create a kind cluster using the configuration file make kind-create # Run a comprehensive test cycle (advanced lint, install, tests) make test-charts-full # Delete the kind cluster when done make kind-delete
Understanding Test Targets
The Makefile includes several testing targets with different purposes:
test-charts: Basic linting of all charts with chart-testing, no installationlint-all-charts: Advanced linting using the rules in lint-conf.yaml for all chartslint-chart: Advanced linting for a specific chartkind-create: Creates a kind cluster with Kubernetes v1.32 for testingkind-delete: Removes the kind cluster used for testingtest-charts-full: Comprehensive workflow combining advanced linting, installation and Helm tests
Chart Change Detection
The chart-testing tool has a built-in capability to detect which charts have changed compared to a target branch. This is configured in the ct.yaml file:
remote: origin
target-branch: main
With these settings, chart-testing will:
- Compare your current working branch to the main branch
- Identify charts that have changes in their files
- Only process those changed charts
This mechanism is used by the GitHub Actions workflow to avoid testing unchanged charts. When you create a PR, the workflow will automatically detect chart changes and only test the modified charts, making the process more efficient.
Customizing Chart Testing
To modify which charts are tested or change testing parameters:
- Edit
ct.yamlto add/remove chart directories or change validation settings - Edit
kind-config.yamlto customize the kind cluster configuration - Update the GitHub Actions workflow in
.github/workflows/chart-testing.ymlif needed
For more information on chart-testing options, see the chart-testing documentation.