From 46af3e1851f157e1dfaeeb661d0b914030a88077 Mon Sep 17 00:00:00 2001 From: Lan Liang Date: Wed, 7 Aug 2024 14:44:28 +0000 Subject: [PATCH] ci: add lint ci for helm chart. Signed-off-by: Lan Liang --- .github/workflows/lint-chart.yaml | 79 +++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 .github/workflows/lint-chart.yaml diff --git a/.github/workflows/lint-chart.yaml b/.github/workflows/lint-chart.yaml new file mode 100644 index 0000000000..30599b370e --- /dev/null +++ b/.github/workflows/lint-chart.yaml @@ -0,0 +1,79 @@ +# validate any chart changes under charts directory +name: Chart Lint + +env: + HELM_VERSION: v3.11.2 + KIND_VERSION: v0.23.0 + KIND_NODE_IMAGE: kindest/node:v1.30.0 + K8S_VERSION: v1.30.0 + +on: + push: + # Exclude branches created by Dependabot to avoid triggering current workflow + # for PRs initiated by Dependabot. + branches-ignore: + - 'dependabot/**' + pull_request: + paths: + - "charts/**" + +permissions: + contents: read + +jobs: + chart-lint-test: + runs-on: ubuntu-22.04 + 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 chart-testing (template) + run: | + helm template --dependency-update ./kwok/charts --debug > /dev/null + + # Python is required because `ct lint` runs Yamale (https://github.com/23andMe/Yamale) and + # yamllint (https://github.com/adrienverge/yamllint) which require Python + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: 3.9 + check-latest: true + + - name: Set up chart-testing + uses: helm/chart-testing-action@v2.6.1 + + - name: Add dependency chart repos + run: | + helm repo add bitnami https://charts.bitnami.com/bitnami + + - name: Run chart-testing (list-changed) + id: list-changed + run: | + changed=$( ct list-changed ) + 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 --debug --check-version-increment=false + + - name: Create kind cluster + uses: helm/kind-action@v1.10.0 + if: steps.list-changed.outputs.changed == 'true' + with: + wait: 120s + version: ${{ env.KIND_VERSION }} + node_image: ${{ env.KIND_NODE_IMAGE }} + kubectl_version: ${{ env.K8S_VERSION }} + + - name: Run chart-testing (install) + if: steps.list-changed.outputs.changed == 'true' + run: ct install --debug --helm-extra-args "--timeout 800s"