Lint and Test Charts workflow (joeferner/redis-commander)
The Lint and Test Charts workflow from joeferner/redis-commander, explained and optimized by Latchkey.
CI health: F - at risk
Point runs-on at Latchkey and get caching, run de-duplication, job timeouts, SHA-pinned actions, self-healing for flaky steps, and up to 58% lower cost, applied automatically.
What it does
This is the Lint and Test Charts workflow from the joeferner/redis-commander repository, a real project running GitHub Actions. It is shown here with attribution under its MIT license.
Below, Latchkey shows a faster, safer version produced by its optimization engine.
The workflow
name: Lint and Test Charts
# code and jobs are mostly taken from https://jamiemagee.co.uk/blog/how-to-host-your-helm-chart-repository-on-github/
# and adapted for newer version of the test tools
#
# - ct - Helm project created Chart Testing, AKA ct, as a comprehensive linting tool for Helm charts
# - Helm-docs - not strictly a linting tool, but it makes sure that your documentation stays up-to-date with the current
# state of your chart
# - Kubeval - It validates the output from Helm against schemas generated from the Kubernetes OpenAPI specification
#
# not used by now:
# - Kubernetes in Docker (KIND) - use Chart Testing again to install your Helm charts on a Kubernetes cluster running in
# the GitHub Actions runner using Kubernetes in Docker (KIND)
on:
pull_request:
paths:
- 'k8s/helm-chart/**'
push:
branches-ignore:
- 'gh-pages'
paths:
- 'k8s/helm-chart/**'
env:
HELM_VERSION: v3.8.1
jobs:
lint-chart:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Helm
uses: azure/setup-helm@v4
with:
version: ${{ env.HELM_VERSION }}
- uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Set up chart-testing
uses: helm/chart-testing-action@v2.7.0
- name: Run chart-testing (lint)
run: "ct lint --config .github/ct.yml --chart-dirs k8/helm-chart"
lint-docs:
runs-on: ubuntu-latest
needs: lint-chart
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Run helm-docs
run: ".github/helm-docs.sh"
kubeval-chart:
runs-on: ubuntu-latest
needs:
- lint-chart
- lint-docs
strategy:
matrix:
k8s:
- v1.11.10 # for openshift 3.11
#- v1.16.15
#- v1.17.14
#- v1.18.20
- v1.19.16
#- v1.20.15
- v1.21.14
#- v1.22.15
- v1.23.12
#- v1.24.6
- v1.25.10
- v1.27.2
include:
- k8s: v1.11.10
legacy_ingress: true
- k8s: v1.19.16
legacy_ingress: true
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Helm
uses: azure/setup-helm@v4
with:
version: ${{ env.HELM_VERSION }}
- name: Run kubeval with legacy ingress for older k8s
if: ${{ matrix.legacy_ingress }}
env:
KUBERNETES_VERSION: ${{ matrix.k8s }}
HELM_VALUES: "--set ingress.enabled=true --set ingress.legacy=true"
run: ".github/kubeval.sh"
- name: Run kubeval with new ingress
if: ${{ ! matrix.legacy_ingress }}
env:
KUBERNETES_VERSION: ${{ matrix.k8s }}
HELM_VALUES: "--set ingress.enabled=true"
run: ".github/kubeval.sh"
# install-chart:
# name: install chart on KIND
# runs-on: ubuntu-latest
# needs:
# - lint-chart
# - lint-docs
# - kubeval-chart
# strategy:
# matrix:
# # not all k8s version are supported - check https://hub.docker.com/r/kindest/node/tags?page=1&ordering=last_updated
# k8s:
# - v1.11.10 # for openshift 3.11
# #- v1.16.15
# #- v1.17.17
# - v1.18.20
# - v1.19.16
# - v1.20.15
# - v1.21.14
# - v1.22.15
# - v1.23.12
# - v1.24.6
# - v1.25.2
# steps:
# - name: Checkout
# uses: actions/checkout@v4
# - name: Create kind ${{ matrix.k8s }} cluster
# uses: helm/kind-action@master
# with:
# node_image: kindest/node:${{ matrix.k8s }}
# - name: Run chart-testing (install)
# uses: helm/chart-testing-action@master
# with:
# command: install
# config: .github/ct.yaml
The same workflow, on Latchkey
Estimated ~20% faster on cache hits, plus fewer wasted runs and a safer supply chain. Added and changed lines are highlighted.
name: Lint and Test Charts # code and jobs are mostly taken from https://jamiemagee.co.uk/blog/how-to-host-your-helm-chart-repository-on-github/ # and adapted for newer version of the test tools # # - ct - Helm project created Chart Testing, AKA ct, as a comprehensive linting tool for Helm charts # - Helm-docs - not strictly a linting tool, but it makes sure that your documentation stays up-to-date with the current # state of your chart # - Kubeval - It validates the output from Helm against schemas generated from the Kubernetes OpenAPI specification # # not used by now: # - Kubernetes in Docker (KIND) - use Chart Testing again to install your Helm charts on a Kubernetes cluster running in # the GitHub Actions runner using Kubernetes in Docker (KIND) on: pull_request: paths: - 'k8s/helm-chart/**' push: branches-ignore: - 'gh-pages' paths: - 'k8s/helm-chart/**' env: HELM_VERSION: v3.8.1 concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: lint-chart: timeout-minutes: 30 runs-on: latchkey-small steps: - name: Checkout uses: actions/checkout@v4 with: fetch-depth: 0 - name: Set up Helm uses: azure/setup-helm@v4 with: version: ${{ env.HELM_VERSION }} - uses: actions/setup-python@v5 with: cache: 'pip' python-version: "3.10" - name: Set up chart-testing uses: helm/chart-testing-action@v2.7.0 - name: Run chart-testing (lint) run: "ct lint --config .github/ct.yml --chart-dirs k8/helm-chart" lint-docs: timeout-minutes: 30 runs-on: latchkey-small needs: lint-chart steps: - name: Checkout uses: actions/checkout@v4 with: fetch-depth: 0 - name: Run helm-docs run: ".github/helm-docs.sh" kubeval-chart: timeout-minutes: 30 runs-on: latchkey-small needs: - lint-chart - lint-docs strategy: matrix: k8s: - v1.11.10 # for openshift 3.11 #- v1.16.15 #- v1.17.14 #- v1.18.20 - v1.19.16 #- v1.20.15 - v1.21.14 #- v1.22.15 - v1.23.12 #- v1.24.6 - v1.25.10 - v1.27.2 include: - k8s: v1.11.10 legacy_ingress: true - k8s: v1.19.16 legacy_ingress: true steps: - name: Checkout uses: actions/checkout@v4 with: fetch-depth: 0 - name: Set up Helm uses: azure/setup-helm@v4 with: version: ${{ env.HELM_VERSION }} - name: Run kubeval with legacy ingress for older k8s if: ${{ matrix.legacy_ingress }} env: KUBERNETES_VERSION: ${{ matrix.k8s }} HELM_VALUES: "--set ingress.enabled=true --set ingress.legacy=true" run: ".github/kubeval.sh" - name: Run kubeval with new ingress if: ${{ ! matrix.legacy_ingress }} env: KUBERNETES_VERSION: ${{ matrix.k8s }} HELM_VALUES: "--set ingress.enabled=true" run: ".github/kubeval.sh" # install-chart: # name: install chart on KIND # runs-on: latchkey-small # needs: # - lint-chart # - lint-docs # - kubeval-chart # strategy: # matrix: # # not all k8s version are supported - check https://hub.docker.com/r/kindest/node/tags?page=1&ordering=last_updated # k8s: # - v1.11.10 # for openshift 3.11 # #- v1.16.15 # #- v1.17.17 # - v1.18.20 # - v1.19.16 # - v1.20.15 # - v1.21.14 # - v1.22.15 # - v1.23.12 # - v1.24.6 # - v1.25.2 # steps: # - name: Checkout # uses: actions/checkout@v4 # - name: Create kind ${{ matrix.k8s }} cluster # uses: helm/kind-action@master # with: # node_image: kindest/node:${{ matrix.k8s }} # - name: Run chart-testing (install) # uses: helm/chart-testing-action@master # with: # command: install # config: .github/ct.yaml
What changed
- Run on Latchkey managed runners with one line (
runs-on), which apply the fixes below automatically and self-heal transient failures. This example useslatchkey-small; pick the runner size that fits the job. - Cancel superseded runs when a branch or PR gets a newer push.
- Cache dependency installs on the setup step so they are served from cache.
- Add a job timeout so a hung step cannot burn hours of runner time.
3 third-party actions are referenced by a movable tag. Pin them to the commit SHA (Latchkey resolves and applies this automatically) so a repointed tag cannot change what runs.
This workflow runs 3 jobs (8 with the matrix expanded) per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.