From 1b54c4bc0419b5f43a90ddbd5d57f8aa7281123e Mon Sep 17 00:00:00 2001 From: Jean-Philippe Evrard Date: Mon, 30 Nov 2020 10:05:02 +0100 Subject: [PATCH 1/2] Fix chart linter Without this patch, the lint action incorrectly returns everything is fine. This is a problem, as lint effectively is not running, and therefore we could merge broken charts. This fixes it by updating to the latest practices you can find in the official chart-repo-actions. (See the official example in ihttps://github.com/helm/charts-repo-actions-demo/blob/1a9640d9983d983404862daee9563fd871db3874/.github/workflows/lint-test.yaml) --- .github/workflows/on-pr-charts.yaml | 30 ++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/.github/workflows/on-pr-charts.yaml b/.github/workflows/on-pr-charts.yaml index 40adcbe..5401a39 100644 --- a/.github/workflows/on-pr-charts.yaml +++ b/.github/workflows/on-pr-charts.yaml @@ -16,12 +16,19 @@ jobs: with: fetch-depth: "0" - - name: Lint charts - uses: helm/chart-testing-action@v2.0.1 + - uses: actions/setup-python@v2 with: - command: lint - config: .github/ct.yaml + python-version: 3.7 + # Helm is already present in github actions, so do not re-install it + - name: Setup chart testing + uses: helm/chart-testing-action@v2.0.1 + + - name: Run chart testing + run: ct lint --config .github/ct.yaml + + # We create two jobs instead of one to make those parallel. + # GH should cancel the rest of the workflow if lint is failing. test-chart: name: Install helm chart runs-on: ubuntu-latest @@ -31,11 +38,16 @@ jobs: with: fetch-depth: "0" + - uses: actions/setup-python@v2 + with: + python-version: 3.7 + + # Helm is already present in github actions, so do not re-install it + - name: Setup chart testing + uses: helm/chart-testing-action@v2.0.1 + - name: Create default kind cluster uses: helm/kind-action@v1.1.0 - - name: Install chart with chart-testing-action - uses: helm/chart-testing-action@v2.0.1 - with: - command: install - config: .github/ct.yaml + - name: Install chart with chart-testing + run: ct install From 40f5eac8aa4f0108b5cad8d3c7dd847845456929 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Evrard Date: Mon, 30 Nov 2020 10:30:41 +0100 Subject: [PATCH 2/2] Simplify action code There are lots of duplicated code in this workflow. This fixes it by making a unique job with parameters. The matrix buys us the parallelisation and the fail-fast. --- .github/workflows/on-pr-charts.yaml | 40 ++++++++++------------------- 1 file changed, 14 insertions(+), 26 deletions(-) diff --git a/.github/workflows/on-pr-charts.yaml b/.github/workflows/on-pr-charts.yaml index 5401a39..9b2d04e 100644 --- a/.github/workflows/on-pr-charts.yaml +++ b/.github/workflows/on-pr-charts.yaml @@ -5,33 +5,20 @@ on: pull_request: paths: - "charts/**" - jobs: - lint-chart: - name: Lint helm chart - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - fetch-depth: "0" - - - uses: actions/setup-python@v2 - with: - python-version: 3.7 - - # Helm is already present in github actions, so do not re-install it - - name: Setup chart testing - uses: helm/chart-testing-action@v2.0.1 - - - name: Run chart testing - run: ct lint --config .github/ct.yaml - - # We create two jobs instead of one to make those parallel. - # GH should cancel the rest of the workflow if lint is failing. + # We create two jobs (with a matrix) instead of one to make those parallel. + # We don't need to conditionally check if something has changed, due to github actions + # tackling that for us. + # Fail-fast ensures that if one of those matrix job fail, the other one gets cancelled. test-chart: - name: Install helm chart + name: Test helm chart runs-on: ubuntu-latest + strategy: + fail-fast: true + matrix: + test-action: + - lint + - install steps: - name: Checkout uses: actions/checkout@v2 @@ -48,6 +35,7 @@ jobs: - name: Create default kind cluster uses: helm/kind-action@v1.1.0 + if: ${{ matrix.test-action == 'install' }} - - name: Install chart with chart-testing - run: ct install + - name: Run chart tests + run: ct ${{ matrix.test-action }} --config .github/ct.yaml