From 83845fac4872db35161188279234f8282623f7bc Mon Sep 17 00:00:00 2001 From: Ryan Lo Date: Sat, 9 Mar 2024 15:40:32 +0800 Subject: [PATCH 1/8] CI workflow for helm charts and manifests Signed-off-by: Ryan Lo --- .github/workflows/validate-helm-charts.yaml | 79 +++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 .github/workflows/validate-helm-charts.yaml diff --git a/.github/workflows/validate-helm-charts.yaml b/.github/workflows/validate-helm-charts.yaml new file mode 100644 index 0000000000..ae8101a0e9 --- /dev/null +++ b/.github/workflows/validate-helm-charts.yaml @@ -0,0 +1,79 @@ +name: Validate helm charts & manifests + +on: + pull_request: + push: + branches: + - master + +jobs: + lint-and-test-charts: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + sparse-checkout: charts + + - name: Install Helm + uses: azure/setup-helm@v4 + + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: "3.10" + check-latest: true + + - name: Set up chart-testing + uses: helm/chart-testing-action@v2 + + - name: Detect charts changed (list-changed) + id: charts-changed + run: | + changed=$(ct list-changed --target-branch ${{ github.event.repository.default_branch }}) + if [[ -n "$changed" ]]; then + echo "changed=true" >> "$GITHUB_OUTPUT" + fi + + - name: Create KinD cluster + if: steps.charts-changed.outputs.changed == 'true' + uses: helm/kind-action@v1 + + - name: Run chart-testing (install) + if: steps.charts-changed.outputs.changed == 'true' + run: ct install --target-branch ${{ github.event.repository.default_branch }} + + validate-manifests: + needs: + - lint-and-test-charts + runs-on: ubuntu-latest + defaults: + run: + shell: bash + strategy: + matrix: + k8s_versions: [ "1.29.2", "v1.28.7", "v1.27.11", "v1.26.14" ] + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + sparse-checkout: | + deployment + docker/sandbox-bundled/manifests + + - name: Install Helm + uses: azure/setup-helm@v4 + + - name: Install kubeconform + run: | + curl -L -o kubeconform.tar.gz https://github.com/yannh/kubeconform/releases/download/v0.6.4/kubeconform-linux-amd64.tar.gz + tar -zvxf kubeconform.tar.gz + chmod +x kubeconform + sudo mv kubeconform /usr/local/bin/kubeconform + + - name: Validate manifests + working-directory: deployment + run: | + kubeconform -strict -summary -skip CustomResourceDefinition -kubernetes-version ${{ matrix.k8s_versions }} ./deployment ./manifests From 690996d8a8ef55b7e902bec8d91464fdb59903f2 Mon Sep 17 00:00:00 2001 From: Ryan Lo Date: Sat, 9 Mar 2024 15:44:49 +0800 Subject: [PATCH 2/8] add lint step Signed-off-by: Ryan Lo --- .github/workflows/validate-helm-charts.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/validate-helm-charts.yaml b/.github/workflows/validate-helm-charts.yaml index ae8101a0e9..9a94ab325e 100644 --- a/.github/workflows/validate-helm-charts.yaml +++ b/.github/workflows/validate-helm-charts.yaml @@ -36,6 +36,10 @@ jobs: echo "changed=true" >> "$GITHUB_OUTPUT" fi + - name: Run chart-testing (lint) + if: steps.charts-changed.outputs.changed == 'true' + run: ct lint --target-branch ${{ github.event.repository.default_branch }} + - name: Create KinD cluster if: steps.charts-changed.outputs.changed == 'true' uses: helm/kind-action@v1 From af804242e655ee63c106f5021ff2f84d7b41e4c1 Mon Sep 17 00:00:00 2001 From: Ryan Lo Date: Sat, 9 Mar 2024 15:45:43 +0800 Subject: [PATCH 3/8] only executed on pull_request event Signed-off-by: Ryan Lo --- .github/workflows/validate-helm-charts.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/validate-helm-charts.yaml b/.github/workflows/validate-helm-charts.yaml index 9a94ab325e..3404b77c8a 100644 --- a/.github/workflows/validate-helm-charts.yaml +++ b/.github/workflows/validate-helm-charts.yaml @@ -2,7 +2,6 @@ name: Validate helm charts & manifests on: pull_request: - push: branches: - master From 6fbc88ed157917e656b8501d1331677f095741ed Mon Sep 17 00:00:00 2001 From: Ryan Lo Date: Sat, 9 Mar 2024 18:51:06 +0800 Subject: [PATCH 4/8] test Signed-off-by: Ryan Lo --- .github/workflows/validate-helm-charts.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/validate-helm-charts.yaml b/.github/workflows/validate-helm-charts.yaml index 3404b77c8a..b1e42b0a04 100644 --- a/.github/workflows/validate-helm-charts.yaml +++ b/.github/workflows/validate-helm-charts.yaml @@ -7,7 +7,7 @@ on: jobs: lint-and-test-charts: - runs-on: ubuntu-latest + runs-on: self-hosted steps: - name: Checkout code uses: actions/checkout@v4 @@ -50,7 +50,7 @@ jobs: validate-manifests: needs: - lint-and-test-charts - runs-on: ubuntu-latest + runs-on: self-hosted defaults: run: shell: bash From d48ecba20746f0f23deff637687cc956d131ad1d Mon Sep 17 00:00:00 2001 From: Ryan Lo Date: Sat, 9 Mar 2024 20:45:35 +0800 Subject: [PATCH 5/8] fix bug Signed-off-by: Ryan Lo --- .github/workflows/validate-helm-charts.yaml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/validate-helm-charts.yaml b/.github/workflows/validate-helm-charts.yaml index b1e42b0a04..f77a58f142 100644 --- a/.github/workflows/validate-helm-charts.yaml +++ b/.github/workflows/validate-helm-charts.yaml @@ -7,7 +7,7 @@ on: jobs: lint-and-test-charts: - runs-on: self-hosted + runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 @@ -50,13 +50,13 @@ jobs: validate-manifests: needs: - lint-and-test-charts - runs-on: self-hosted + runs-on: ubuntu-latest defaults: run: shell: bash strategy: matrix: - k8s_versions: [ "1.29.2", "v1.28.7", "v1.27.11", "v1.26.14" ] + k8s_versions: [ "1.29.2", "v1.28.7", "v1.27.11" ] steps: - name: Checkout code @@ -77,6 +77,5 @@ jobs: sudo mv kubeconform /usr/local/bin/kubeconform - name: Validate manifests - working-directory: deployment run: | - kubeconform -strict -summary -skip CustomResourceDefinition -kubernetes-version ${{ matrix.k8s_versions }} ./deployment ./manifests + kubeconform -strict -summary -skip CustomResourceDefinition -kubernetes-version ${{ matrix.k8s_versions }} ./deployment ./docker/sandbox-bundled/manifests From 13b1806fc3afa75b42d9a94d71a4435d6438fae6 Mon Sep 17 00:00:00 2001 From: Ryan Lo Date: Sat, 9 Mar 2024 20:55:27 +0800 Subject: [PATCH 6/8] fix typo Signed-off-by: Ryan Lo --- .github/workflows/validate-helm-charts.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/validate-helm-charts.yaml b/.github/workflows/validate-helm-charts.yaml index f77a58f142..e0d29adab0 100644 --- a/.github/workflows/validate-helm-charts.yaml +++ b/.github/workflows/validate-helm-charts.yaml @@ -56,7 +56,7 @@ jobs: shell: bash strategy: matrix: - k8s_versions: [ "1.29.2", "v1.28.7", "v1.27.11" ] + k8s_versions: [ "1.29.2", "1.28.7", "1.27.11" ] steps: - name: Checkout code From 80ed6e47a3f223a45f0f65c03f4b172a1cfd5806 Mon Sep 17 00:00:00 2001 From: Ryan Lo Date: Sun, 10 Mar 2024 16:14:41 +0800 Subject: [PATCH 7/8] ignore files under deployment/stats/prometheus Signed-off-by: Ryan Lo --- .github/workflows/validate-helm-charts.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/validate-helm-charts.yaml b/.github/workflows/validate-helm-charts.yaml index e0d29adab0..7fc244b77c 100644 --- a/.github/workflows/validate-helm-charts.yaml +++ b/.github/workflows/validate-helm-charts.yaml @@ -78,4 +78,4 @@ jobs: - name: Validate manifests run: | - kubeconform -strict -summary -skip CustomResourceDefinition -kubernetes-version ${{ matrix.k8s_versions }} ./deployment ./docker/sandbox-bundled/manifests + kubeconform -strict -summary -skip CustomResourceDefinition -ignore-filename-pattern "deployment/stats/prometheus/*" -kubernetes-version ${{ matrix.k8s_versions }} ./deployment ./docker/sandbox-bundled/manifests From 1f36148c3f10289b106875528e1c90855f68e7dc Mon Sep 17 00:00:00 2001 From: Ryan Lo Date: Sun, 10 Mar 2024 16:19:42 +0800 Subject: [PATCH 8/8] add path filter Signed-off-by: Ryan Lo --- .github/workflows/validate-helm-charts.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/validate-helm-charts.yaml b/.github/workflows/validate-helm-charts.yaml index 7fc244b77c..dc55ad980c 100644 --- a/.github/workflows/validate-helm-charts.yaml +++ b/.github/workflows/validate-helm-charts.yaml @@ -4,6 +4,9 @@ on: pull_request: branches: - master + paths: + - deployment + - docker/sandbox-bundled/manifests jobs: lint-and-test-charts: