Skip to content

step-security/chart-testing-action

Repository files navigation

StepSecurity Maintained Action

chart-testing Action

A GitHub Action for installing the helm/chart-testing CLI tool.

Usage

Pre-requisites

  1. A GitHub repo containing a directory with your Helm charts (e.g: charts)
  2. A workflow YAML file in your .github/workflows directory. An example workflow is available below. For more information, reference the GitHub Help Documentation for Creating a workflow file

Inputs

For more information on inputs, see the API Documentation

  • version: The chart-testing version to install (default: 3.14.0)
  • yamllint_version: The yamllint version to install (default: 1.33.0)
  • yamale_version: The yamale version to install (default: 6.0.0)

Example Workflow

Create a workflow (eg: .github/workflows/lint-test.yaml):

Note that Helm and Python must be installed. This can be achieved using actions as shown in the example below. Python is required because ct lint runs Yamale and yamllint which require Python.

name: Lint and Test Charts

on: pull_request

permissions: {}

jobs:
  lint-test:
    runs-on: ubuntu-latest
    permissions:
      contents: read
    steps:
      - name: Checkout
        uses: actions/checkout@v6
        with:
          fetch-depth: 0

      - name: Set up Helm
        uses: azure/setup-helm@v5

      - uses: actions/setup-python@v6
        with:
          python-version: '3.x'
          check-latest: true

      - name: Set up chart-testing
        uses: step-security/chart-testing-action@v2

      - name: Run chart-testing (list-changed)
        id: list-changed
        run: |
          changed=$(ct list-changed --target-branch ${{ github.event.repository.default_branch }})
          if [[ -n "$changed" ]]; then
            echo "changed=true" >> "$GITHUB_OUTPUT"
          fi

      - name: Run chart-testing (lint)
        if: steps.list-changed.outputs.changed == 'true'
        run: ct lint --target-branch ${{ github.event.repository.default_branch }}

      - name: Create kind cluster
        if: steps.list-changed.outputs.changed == 'true'
        uses: helm/kind-action@v1

      - name: Run chart-testing (install)
        if: steps.list-changed.outputs.changed == 'true'
        run: ct install --target-branch ${{ github.event.repository.default_branch }}

This uses helm/kind-action GitHub Action to spin up a kind Kubernetes cluster, and helm/chart-testing to lint and test your charts on every pull request.

About

A GitHub Action to lint and test Helm charts. Secure drop-in replacement for helm/chart-testing-action.

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages