From 2379903475512d32b3330aceb1c01c41ff4b8b9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20B=C3=A4hler?= Date: Mon, 8 Mar 2021 23:34:05 +0100 Subject: [PATCH] feat: Move Linting to Github Actions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Oliver Bähler Disable ServiceAccount on disabled Dex Signed-off-by: Oliver Bähler Swap Linting to Github Signed-off-by: Oliver Bähler Increase all chart versions Signed-off-by: Oliver Bähler Remove Circle & Improve Github Lint Signed-off-by: Oliver Bähler Remove Circle & Improve Github Lint Signed-off-by: Oliver Bähler Lookup Configmaps update Retest Retest reduce changes reduce changes --- .circleci/chart-testing.yaml | 4 --- .circleci/config.yml | 14 ++------ .github/stale.yml | 1 - .github/workflows/lint-and-test.yml | 45 ++++++++++++++++++++++++ .github/workflows/stale.yml | 4 --- charts/argo-events/Chart.yaml | 2 +- charts/argo-events/ci/test-values.yaml | 6 ++-- ct.yaml | 18 ++++++++++ .circleci/lintconf.yaml => lintconf.yaml | 0 scripts/lint.sh | 26 +++++++------- 10 files changed, 82 insertions(+), 38 deletions(-) delete mode 100644 .circleci/chart-testing.yaml delete mode 100644 .github/stale.yml create mode 100644 .github/workflows/lint-and-test.yml create mode 100644 ct.yaml rename .circleci/lintconf.yaml => lintconf.yaml (100%) diff --git a/.circleci/chart-testing.yaml b/.circleci/chart-testing.yaml deleted file mode 100644 index 87e07618..00000000 --- a/.circleci/chart-testing.yaml +++ /dev/null @@ -1,4 +0,0 @@ -chart-repos: - - argo=https://argoproj.github.io/argo-helm - - minio=https://helm.min.io/ - - dandydeveloper=https://dandydeveloper.github.io/charts/ diff --git a/.circleci/config.yml b/.circleci/config.yml index 6c3306ec..e933ec03 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,12 +1,5 @@ version: 2.1 jobs: - lint: - docker: - - image: quay.io/helmpack/chart-testing:v3.3.1 - steps: - - checkout - - run: helm repo add stable https://charts.helm.sh/stable - - run: ct lint --config .circleci/chart-testing.yaml --lint-conf .circleci/lintconf.yaml # Technically this only needs to be run on master, but it's good to have it run on every PR # so that it is regularly tested. publish: @@ -21,6 +14,8 @@ jobs: - checkout - run: helm repo add stable https://charts.helm.sh/stable - run: helm repo add minio https://helm.min.io/ + - run: helm repo add minio-operator https://operator.min.io/ + - run: helm repo add argo https://argoproj.github.io/argo-helm - run: helm repo add dandydeveloper https://dandydeveloper.github.io/charts/ # Only actually publish charts on master. - run: | @@ -35,7 +30,4 @@ workflows: version: 2 workflow: jobs: - - lint - - publish: - requires: - - lint + - publish \ No newline at end of file diff --git a/.github/stale.yml b/.github/stale.yml deleted file mode 100644 index b81bf109..00000000 --- a/.github/stale.yml +++ /dev/null @@ -1 +0,0 @@ -# See https://github.com/probot/stale diff --git a/.github/workflows/lint-and-test.yml b/.github/workflows/lint-and-test.yml new file mode 100644 index 00000000..00d2fff2 --- /dev/null +++ b/.github/workflows/lint-and-test.yml @@ -0,0 +1,45 @@ +## Reference: https://github.com/helm/chart-testing-action +--- +name: Linting and Testing +on: pull_request +jobs: + chart-test: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Set up Helm + uses: azure/setup-helm@v1 + + - name: Set up python + uses: actions/setup-python@v2 + with: + python-version: 3.7 + + - name: Setup Chart Linting + id: lint + uses: helm/chart-testing-action@v2.0.1 + + - name: List changed charts + id: list-changed + run: | + ## If executed with debug this won't work anymore. + changed=$(ct --config ./ct.yaml list-changed) + charts=$(echo "$changed" | tr '\n' ' ' | xargs) + if [[ -n "$changed" ]]; then + echo "::set-output name=changed::true" + echo "::set-output name=changed_charts::$charts" + fi + - name: Run chart-testing (lint) + run: ct lint --debug --config ./ct.yaml --lint-conf ./lintconf.yaml + + - name: Create kind cluster + uses: helm/kind-action@v1.1.0 + if: steps.list-changed.outputs.changed == 'true' + + - name: Run chart-testing (install) + run: ct install --config ./ct.yaml + if: steps.list-changed.outputs.changed == 'true' diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index b671fc09..8b16dff4 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -1,14 +1,10 @@ name: Mark stale issues and pull requests - on: schedule: - cron: "30 1 * * *" - jobs: stale: - runs-on: ubuntu-latest - steps: - uses: actions/stale@v3 with: diff --git a/charts/argo-events/Chart.yaml b/charts/argo-events/Chart.yaml index a7a9854e..1f138c3c 100644 --- a/charts/argo-events/Chart.yaml +++ b/charts/argo-events/Chart.yaml @@ -1,7 +1,7 @@ apiVersion: v2 description: A Helm chart to install Argo-Events in k8s Cluster name: argo-events -version: 1.3.1 +version: 1.3.2 keywords: - argo-events - sensor-controller diff --git a/charts/argo-events/ci/test-values.yaml b/charts/argo-events/ci/test-values.yaml index cd5d3916..33eb3559 100644 --- a/charts/argo-events/ci/test-values.yaml +++ b/charts/argo-events/ci/test-values.yaml @@ -1,6 +1,6 @@ serviceAccount: argo-events-sa-test -additionalSaNamespaces: - - nsone - - nstwo +# additionalSaNamespaces: +# - nsone +# - nstwo instanceID: test-argo-events singleNamespace: false diff --git a/ct.yaml b/ct.yaml new file mode 100644 index 00000000..68ec54d0 --- /dev/null +++ b/ct.yaml @@ -0,0 +1,18 @@ +## Reference: https://github.com/helm/chart-testing/blob/master/doc/ct_lint-and-install.md +# Don't add the 'debug' attribute, otherwise the workflow won't work anymore +remote: origin +chart-dirs: + - charts +chart-repos: + - argo=https://argoproj.github.io/argo-helm + - minio=https://helm.min.io/ + - minio-operator=https://operator.min.io/ + - dandydeveloper=https://dandydeveloper.github.io/charts/ + - stable=https://charts.helm.sh/stable + - incubator=https://charts.helm.sh/incubator +helm-extra-args: "--timeout 600s" +validate-chart-schema: false +validate-maintainers: true +validate-yaml: true +exclude-deprecated: true +excluded-charts: [] diff --git a/.circleci/lintconf.yaml b/lintconf.yaml similarity index 100% rename from .circleci/lintconf.yaml rename to lintconf.yaml diff --git a/scripts/lint.sh b/scripts/lint.sh index 8f084c5b..45abb7f7 100755 --- a/scripts/lint.sh +++ b/scripts/lint.sh @@ -1,19 +1,17 @@ #!/bin/bash +# This script runs the chart-testing tool locally. It simulates the linting that is also done by the github action. Run this without any errors before pushing. +# Reference: https://github.com/helm/chart-testing set -eux SRCROOT="$(cd "$(dirname "$0")/.." && pwd)" -for dir in $(find $SRCROOT/charts -mindepth 1 -maxdepth 1 -type d); -do - rm -rf $dir/charts - name=$(basename $dir) - echo "Running Helm linting for $name" - docker run \ - -v "$SRCROOT:/workdir" \ - gcr.io/kubernetes-charts-ci/test-image:v3.1.0 \ - ct \ - lint \ - --config .circleci/chart-testing.yaml \ - --lint-conf .circleci/lintconf.yaml \ - --charts "/workdir/charts/${name}" -done +echo -e "\n-- Linting all Helm Charts --\n" +docker run \ + -v "$SRCROOT:/workdir" \ + --entrypoint /bin/sh \ + quay.io/helmpack/chart-testing:v3.3.1 \ + -c cd /workdir \ + ct lint \ + --config ct.yaml \ + --lint-conf lintconf.yaml \ + --debug