diff --git a/.github/kind-cluster.yaml b/.github/kind-cluster.yaml index 85452477..df0a3736 100644 --- a/.github/kind-cluster.yaml +++ b/.github/kind-cluster.yaml @@ -1,5 +1,5 @@ kind: Cluster -apiVersion: kind.sigs.k8s.io/v1alpha3 +apiVersion: kind.x-k8s.io/v1alpha4 nodes: # the control plane node config - role: control-plane diff --git a/.github/kubeval.sh b/.github/kubeval.sh deleted file mode 100755 index 642643d1..00000000 --- a/.github/kubeval.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash -# use kubeval to validate helm generated kubernetes manifest -# based on https://raw.githubusercontent.com/eclipse/packages/master/.github/kubeval.sh - -set -o errexit -set -o pipefail - -CHART_DIRS="$(ls charts)" -HELM_VERSION="v3.5.2" - -# install helm -curl --silent --show-error --fail --location --output get_helm.sh https://raw.githubusercontent.com/kubernetes/helm/master/scripts/get -chmod 700 get_helm.sh -./get_helm.sh --version "${HELM_VERSION}" - -# add helm repos to resolve dependencies -helm repo add stable https://charts.helm.sh/stable - -# install kubeval plugins to helm -helm plugin install https://github.com/instrumenta/helm-kubeval - -# validate charts -for CHART_DIR in ${CHART_DIRS};do - echo "kubeval(idating) charts/${CHART_DIR} chart..." - helm kubeval "charts/${CHART_DIR}" -v "${KUBERNETES_VERSION#v}" -done diff --git a/.github/workflows/helm_charts_scalar.yml b/.github/workflows/helm_charts_scalar.yml index ed25148a..1b9c0a07 100644 --- a/.github/workflows/helm_charts_scalar.yml +++ b/.github/workflows/helm_charts_scalar.yml @@ -4,50 +4,77 @@ on: pull_request: branches: - main - paths: - - "charts/**" push: branches: - main paths: - "charts/**" +env: + HELM_VERSION: v3.5.2 + jobs: lint-chart: runs-on: ubuntu-latest + env: + PYTHON_VERSION: 3.7 + steps: - - uses: actions/checkout@v2 + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 - - name: Fetch history for chart testing - run: git fetch --prune --unshallow + - name: Set up Helm + uses: azure/setup-helm@v1 + with: + version: ${{ env.HELM_VERSION }} - - name: Run chart-testing (lint) - id: lint - uses: helm/chart-testing-action@v1.0.0-rc.2 + - name: Set up Python + uses: actions/setup-python@v2 with: - command: lint - config: .github/ct.yaml + python-version: ${{ env.PYTHON_VERSION }} + + - name: Set up chart-testing + uses: helm/chart-testing-action@v2.0.1 + + - name: Run chart-testing (lint) + run: ct lint --config .github/ct.yaml kubeval-chart: runs-on: ubuntu-latest needs: lint-chart - # Uses 1.16.4 since it doesn't support 1.16.13 in https://github.com/instrumenta/kubernetes-json-schema. strategy: matrix: k8s: - - v1.15.7 - - v1.16.4 + - v1.18.15 + - v1.19.7 + - v1.20.2 + steps: - name: Checkout uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Set up Helm + uses: azure/setup-helm@v1 + with: + version: ${{ env.HELM_VERSION }} - - name: Fetch history for chart testing - run: git fetch --prune --unshallow + - name: Install helm-kubeval plugin + run: helm plugin install https://github.com/instrumenta/helm-kubeval - name: Run kubeval + run: | + chart_dirs=$(ls charts) + for chart_dir in ${chart_dirs}; do + echo "kubeval(idating) charts/${chart_dir} chart..." + helm kubeval "charts/${chart_dir}" -v "${KUBERNETES_VERSION#v}" + done env: KUBERNETES_VERSION: ${{ matrix.k8s }} - run: .github/kubeval.sh + KUBEVAL_SCHEMA_LOCATION: https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master install-chart: name: install-chart @@ -59,24 +86,36 @@ jobs: DOCKER_REGISTRY_PASSWORD: ${{ secrets.CR_PAT }} DOCKER_REGISTRY_USERNAME: scalar-git DOCKER_REGISTRY_SERVER: ghcr.io - # Uses 1.16.9 since it doesn't support 1.16.13 in https://hub.docker.com/r/kindest/node/tags. strategy: matrix: k8s: - - v1.15.11 - - v1.16.9 + - v1.18.15 + - v1.19.7 + - v1.20.2 + steps: - name: Checkout uses: actions/checkout@v2 + with: + fetch-depth: 0 - - name: Fetch history for chart testing - run: git fetch --prune --unshallow + - name: Set up chart-testing + uses: helm/chart-testing-action@v2.0.1 + + - name: Run chart-testing (list-changed) + id: list-changed + run: | + changed=$(ct list-changed --config .github/ct.yaml) + if [[ -n "$changed" ]]; then + echo "::set-output name=changed::true" + fi - name: Create kind ${{ matrix.k8s }} cluster - uses: helm/kind-action@v1.0.0-rc.1 + uses: helm/kind-action@v1.1.0 with: config: .github/kind-cluster.yaml node_image: kindest/node:${{ matrix.k8s }} + if: steps.list-changed.outputs.changed == 'true' - name: Setup kubernetes (Kind) with registry, cassandra and schema run: | @@ -87,14 +126,14 @@ jobs: kubectl get pods,svc,endpoints,nodes -o wide - name: Run chart-testing (install) - uses: helm/chart-testing-action@v1.0.0-rc.2 - with: - command: "install" - config: .github/ct.yaml + run: ct install --config .github/ct.yaml verify-chart-docs: runs-on: ubuntu-latest + steps: - - uses: actions/checkout@v2 + - name: Checkout + uses: actions/checkout@v2 + - name: Verify chart docs run: ./scripts/verify-chart-docs.sh