diff --git a/.github/workflows/helm.yaml b/.github/workflows/helm.yaml index cce29edb..fe0dcaec 100644 --- a/.github/workflows/helm.yaml +++ b/.github/workflows/helm.yaml @@ -8,33 +8,35 @@ on: types: [opened, reopened, synchronize] paths: - "charts/*" - - "test/e2e-kind.sh" jobs: - shellcheck: - if: github.event_name == 'pull_request' - name: Shellcheck Helm Charts - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: docker://koalaman/shellcheck-alpine - with: - entrypoint: shellcheck - args: -x test/e2e-kind.sh charts-e2e: name: Run E2E Tests on the Helm Charts - needs: [shellcheck] runs-on: ubuntu-latest - env: - CHART_TESTING_IMAGE: quay.io/helmpack/chart-testing - CHART_TESTING_TAG: v2.4.1 - K8S_VERSION: v1.18.0 - KIND_VERSION: v0.8.1 steps: - uses: actions/checkout@v2 - - run: git fetch --prune --unshallow + - name: Fetch history + run: git fetch --prune --unshallow + - name: Run chart-testing (lint) + id: lint + uses: helm/chart-testing-action@v1.0.0 + with: + command: lint - - name: Run linting and chart testing against kind - run: test/e2e-kind.sh + - name: Create kind cluster + uses: helm/kind-action@v1.0.0-alpha.3 + # Only build a kind cluster if there are chart changes to test. + if: steps.lint.outputs.changed == 'true' + + - name: delete default storage class + run: kubectl delete stroageclass standard + + - name: create local-path-provisioner stroageclass + run: kubectl apply -f test/local-path-provisioner.yaml + + - name: Run chart-testing (install) + uses: helm/chart-testing-action@v1.0.0 + with: + command: install publish: if: success() && github.event_name == 'push' && github.ref == 'refs/heads/main' diff --git a/test/ct.yaml b/test/ct.yaml deleted file mode 100644 index f081c88d..00000000 --- a/test/ct.yaml +++ /dev/null @@ -1,5 +0,0 @@ -target-branch: main -chart-dirs: - - charts -helm-extra-args: --timeout 800 -check-version-increment: false diff --git a/test/e2e-kind.sh b/test/e2e-kind.sh deleted file mode 100755 index cd6078cd..00000000 --- a/test/e2e-kind.sh +++ /dev/null @@ -1,118 +0,0 @@ -#!/usr/bin/env bash - -set -o errexit -set -o nounset -set -o pipefail - -readonly CLUSTER_NAME=chart-testing - -lint_charts() { - echo - echo "Starting charts linting..." - mkdir -p tmp - docker run --rm -v "$(pwd):/workdir" --workdir /workdir "$CHART_TESTING_IMAGE:$CHART_TESTING_TAG" ct lint --config /workdir/test/ct.yaml | tee tmp/lint.log || true - echo "Done Charts Linting!" - - if grep -q "No chart changes detected" tmp/lint.log > /dev/null; then - echo "No chart changes detected, stopping pipeline!" - exit 0 - elif grep -q "Error linting charts" tmp/lint.log > /dev/null; then - echo "Error linting charts stopping pipeline!" - exit 1 - else - install_charts - fi -} - -run_ct_container() { - echo 'Running ct container...' - docker run --rm --interactive --detach --network host --name ct \ - --volume "$(pwd):/workdir" \ - --workdir /workdir \ - "$CHART_TESTING_IMAGE:$CHART_TESTING_TAG" \ - cat - echo -} - -cleanup() { - echo 'Removing ct container...' - docker kill ct > /dev/null 2>&1 - - echo 'Done!' -} - -docker_exec() { - docker exec --interactive -e HELM_HOST=127.0.0.1:44134 -e HELM_TILLER_SILENT=true ct "$@" -} - -create_kind_cluster() { - echo 'Installing kind...' - - curl -sSLo kind "https://github.com/kubernetes-sigs/kind/releases/download/$KIND_VERSION/kind-linux-amd64" - chmod +x kind - sudo mv kind /usr/local/bin/kind - - kind create cluster --name "$CLUSTER_NAME" --image "kindest/node:$K8S_VERSION" - - docker_exec mkdir -p /root/.kube - - echo 'Copying kubeconfig to container...' - # local kubeconfig - kind get kubeconfig --name "$CLUSTER_NAME" > kube-config.yaml - docker cp kube-config.yaml ct:/root/.kube/config - - docker_exec kubectl cluster-info - echo - - echo -n 'Waiting for cluster to be ready...' - until ! grep --quiet 'NotReady' <(docker_exec kubectl get nodes --no-headers); do - printf '.' - sleep 1 - done - - echo '✔︎' - echo - - docker_exec kubectl get nodes - echo - - echo 'Cluster ready!' - echo -} - -install_local-path-provisioner() { - # Remove default storage class. It will be recreated by local-path-provisioner - docker_exec kubectl delete storageclass standard - - echo 'Installing local-path-provisioner...' - docker_exec kubectl apply -f test/local-path-provisioner.yaml - echo -} - -install_tiller() { - docker_exec apk add bash - echo "Install Tillerless Helm plugin..." - docker_exec helm init --client-only - docker_exec helm plugin install https://github.com/rimusz/helm-tiller - docker_exec bash -c 'echo "Starting Tiller..."; helm tiller start-ci >/dev/null 2>&1 &' - docker_exec bash -c 'echo "Waiting Tiller to launch on 44134..."; while ! nc -z localhost 44134; do sleep 1; done; echo "Tiller launched..."' - echo -} - -install_charts() { - echo "Starting charts install testing..." - run_ct_container - trap cleanup EXIT - - create_kind_cluster - install_local-path-provisioner - install_tiller - docker_exec ct install --config /workdir/test/ct.yaml - echo -} - -main() { - lint_charts -} - -main \ No newline at end of file