From d361510c80bdf772322659ed8b0d695cb6952f8c Mon Sep 17 00:00:00 2001 From: christianhuth Date: Tue, 17 Dec 2024 14:10:19 +0000 Subject: [PATCH] wip --- .devcontainer/devcontainer.json | 6 ++++++ .git-hooks/helm-dependency-update.sh | 3 +++ .github/workflows/chart-testing.yml | 14 +++++++++----- .pre-commit-config.yaml | 15 +++++++++++---- .pre-commit-hooks.yaml | 11 +++++++++++ 5 files changed, 40 insertions(+), 9 deletions(-) create mode 100755 .git-hooks/helm-dependency-update.sh create mode 100644 .pre-commit-hooks.yaml diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 71943c61..1a8e057f 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -38,12 +38,18 @@ "customizations": { "vscode": { "extensions": [ + "github.vscode-github-actions", "ms-kubernetes-tools.vscode-kubernetes-tools", "tim-koehler.helm-intellisense" ] } }, + "mounts": [ + "type=bind,source=${localEnv:HOME}/.ssh,target=/home/vscode/.ssh,readonly" + ], + + // we use /home/vscode/helm-charts as development folder inside the container "workspaceFolder": "/home/vscode/helm-charts", "workspaceMount": "source=${localWorkspaceFolder},target=/home/vscode/helm-charts,type=bind" diff --git a/.git-hooks/helm-dependency-update.sh b/.git-hooks/helm-dependency-update.sh new file mode 100755 index 00000000..fa2be00a --- /dev/null +++ b/.git-hooks/helm-dependency-update.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +ct list-changed | xargs -d '\n' -I {} helm dependency update {} diff --git a/.github/workflows/chart-testing.yml b/.github/workflows/chart-testing.yml index 0b2b5e7f..28e02a4f 100644 --- a/.github/workflows/chart-testing.yml +++ b/.github/workflows/chart-testing.yml @@ -36,11 +36,15 @@ jobs: - name: setup helm uses: azure/setup-helm@v3 - - name: Update dependencies - run: find charts/ ! -path charts/ -maxdepth 1 -type d -exec helm dependency update {} \; + - uses: actions/setup-python@v5 + with: + python-version: 3.7 + + - name: Set up chart-testing + uses: helm/chart-testing-action@v2.6.1 - - name: helm linting - run : helm lint charts/* + - name: helm lint on changed charts + run : ct list-changed --config .github/config/chart-testing.yaml | xargs -d '\n' -I {} helm dependency update {} chart-testing: runs-on: ubuntu-22.04 @@ -63,7 +67,7 @@ jobs: - name: Run chart-testing (list-changed) id: list-changed run: | - changed=$(ct list-changed --target-branch ${{ github.event.repository.default_branch }}) + changed=$(ct list-changed --config .github/config/chart-testing.yaml) if [[ -n "$changed" ]]; then echo "::set-output name=changed::true" fi diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index cc30c82e..e98b2ef3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -22,7 +22,14 @@ repos: args: - --chart-search-root=charts - - repo: https://github.com/gruntwork-io/pre-commit - rev: v0.1.25 - hooks: - - id: helmlint + # - repo: https://github.com/igorshubovych/markdownlint-cli + # rev: v0.32.2 + # hooks: + # - id: markdownlint + # name: Markdownlint + + # - repo: https://github.com/jumanjihouse/pre-commit-hooks + # rev: 3.0.0 + # hooks: + # - id: shellcheck + # name: Shellcheck diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml new file mode 100644 index 00000000..228a1b54 --- /dev/null +++ b/.pre-commit-hooks.yaml @@ -0,0 +1,11 @@ +- id: helm-dependency-update + name: Update Helm Dependency for changed Charts + entry: bash -c 'ct list-changed | xargs -d '\n' -I {} helm dependency update {}' + language: system + pass_filenames: false + +- id: helm-kubeconform + name: Execute kubeconform for changed Charts + entry: bash -c 'ct list-changed | xargs -d '\n' -I {} helm kubeconform {}' + language: system + pass_filenames: false