From 9644cdc1c8541ac2ee93c3649178a6be9402c4ee Mon Sep 17 00:00:00 2001 From: Matt Halder Date: Fri, 20 Oct 2023 11:57:52 -0600 Subject: [PATCH 1/4] Using helms chart-repo-actions demo to lint and test helm chart changes Signed-off-by: Matt Halder --- .github/ct.yaml | 6 +++ .github/workflows/chart-lint-test.yaml | 54 ++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 .github/ct.yaml create mode 100644 .github/workflows/chart-lint-test.yaml diff --git a/.github/ct.yaml b/.github/ct.yaml new file mode 100644 index 00000000..7a3fed63 --- /dev/null +++ b/.github/ct.yaml @@ -0,0 +1,6 @@ +remote: origin +target: main +chart-dirs: +- charts +helm-extra-args: --timeout 600 + diff --git a/.github/workflows/chart-lint-test.yaml b/.github/workflows/chart-lint-test.yaml new file mode 100644 index 00000000..c5ac4c3c --- /dev/null +++ b/.github/workflows/chart-lint-test.yaml @@ -0,0 +1,54 @@ +# Lint and Test was added using helm/chart-repo-actions-demo as a reference +# https://github.com/helm/charts-repo-actions-demo/blob/main/.github/workflows/lint-test.yaml + +name: Charts Linting and Testing + +on: + push: + branches: + - main + - /^release\/.*$/ + paths: + - 'charts/**' + +jobs: + lint-test: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4.1.0 + with: + fetch-depth: 0 + + - name: Setup Helm + uses: azure/setup-helm@v3.5 + with: + version: 'v3.13.0' + + # ct (chart testing) requires python + - name: Setup Python + uses: actions/setup-python@v4.7.1 + with: + python-version: '3.x' + + - name: Install chart-testing + uses: helm/chart-testing-action@v2.4.0 + + - name: Run chart-testing (list-changed) + id: list-changed + run: | + changed=$(ct list-changed --chart-dirs charts --config .github/ct.yaml) + if [[ -n "$changed" ]]; then + echo "changed=true" >> $GITHUB_OUTPUT + fi + + - name: Run chart-testing (lint) + run: ct lint --config .github/ct.yaml + + - name: Create kind cluster + uses: helm/kind-action@v1.8.0 + if: steps.list-changed.outputs.changed == 'true' + + - name: Run chart-testing (install) + run: ct install --config .github/ct.yaml + From 45cac5bab9e2b7f91127886a5f5c60a4f6727a8f Mon Sep 17 00:00:00 2001 From: Matt Halder Date: Fri, 20 Oct 2023 12:07:52 -0600 Subject: [PATCH 2/4] This needs a time unit specified Signed-off-by: Matt Halder --- .github/ct.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ct.yaml b/.github/ct.yaml index 7a3fed63..ebf86c1e 100644 --- a/.github/ct.yaml +++ b/.github/ct.yaml @@ -2,5 +2,5 @@ remote: origin target: main chart-dirs: - charts -helm-extra-args: --timeout 600 +helm-extra-args: --timeout 600s From 84ba1a3d01964e4fdf12745d37f9858bbcc818be Mon Sep 17 00:00:00 2001 From: Matt Halder Date: Fri, 20 Oct 2023 15:07:57 -0600 Subject: [PATCH 3/4] Updating to have the linting/testing on pull requests to the charts directory Signed-off-by: Matt Halder --- .github/workflows/chart-lint-test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/chart-lint-test.yaml b/.github/workflows/chart-lint-test.yaml index c5ac4c3c..4debd697 100644 --- a/.github/workflows/chart-lint-test.yaml +++ b/.github/workflows/chart-lint-test.yaml @@ -4,7 +4,7 @@ name: Charts Linting and Testing on: - push: + pull_request: branches: - main - /^release\/.*$/ From 588bd6ce95d5d49ff53221fd7995952765e622da Mon Sep 17 00:00:00 2001 From: Matt Halder Date: Fri, 20 Oct 2023 15:09:19 -0600 Subject: [PATCH 4/4] correcting indentations Signed-off-by: Matt Halder --- .github/workflows/chart-lint-test.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/chart-lint-test.yaml b/.github/workflows/chart-lint-test.yaml index 4debd697..b84c54ba 100644 --- a/.github/workflows/chart-lint-test.yaml +++ b/.github/workflows/chart-lint-test.yaml @@ -6,10 +6,10 @@ name: Charts Linting and Testing on: pull_request: branches: - - main - - /^release\/.*$/ + - main + - /^release\/.*$/ paths: - - 'charts/**' + - 'charts/**' jobs: lint-test: