From 005339b3eff25a3e68d4d30fe75e9179fb539e08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=E1=B4=87=CA=80=C9=B4=E1=B4=85=20S=E1=B4=84=CA=9C?= =?UTF-8?q?=E1=B4=8F=CA=80=C9=A2=E1=B4=87=CA=80s?= Date: Wed, 27 Jul 2022 13:19:45 +0200 Subject: [PATCH] =?UTF-8?q?ci:=20=F0=9F=A7=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .ci/ct/{ct-lint.yaml => ct.yaml} | 4 +- .github/workflows/charts-lint.yaml | 2 +- .github/workflows/charts-test.yaml | 72 +++++++++++++++--------------- .taskfiles/charts.yaml | 12 ++++- 4 files changed, 50 insertions(+), 40 deletions(-) rename .ci/ct/{ct-lint.yaml => ct.yaml} (84%) diff --git a/.ci/ct/ct-lint.yaml b/.ci/ct/ct.yaml similarity index 84% rename from .ci/ct/ct-lint.yaml rename to .ci/ct/ct.yaml index 7db37dcc..1cac46ef 100644 --- a/.ci/ct/ct-lint.yaml +++ b/.ci/ct/ct.yaml @@ -10,7 +10,9 @@ chart-dirs: - charts/library - charts/stable -excluded-charts: +excluded-charts-lint: [] + +excluded-charts-install: [] chart-repos: - bitnami=https://charts.bitnami.com/bitnami diff --git a/.github/workflows/charts-lint.yaml b/.github/workflows/charts-lint.yaml index 633c16b3..106cceff 100644 --- a/.github/workflows/charts-lint.yaml +++ b/.github/workflows/charts-lint.yaml @@ -37,4 +37,4 @@ jobs: - name: Run chart-testing (lint) id: lint if: inputs.chartChanges != '' - run: ct lint --config .ci/ct/ct-lint.yaml + run: ct lint --config .ci/ct/ct.yaml diff --git a/.github/workflows/charts-test.yaml b/.github/workflows/charts-test.yaml index ca921e47..01e2becf 100644 --- a/.github/workflows/charts-test.yaml +++ b/.github/workflows/charts-test.yaml @@ -11,39 +11,39 @@ on: type: string jobs: - unit-test: - name: Run unit tests - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 0 - ref: ${{ inputs.checkoutCommit }} + # unit-test: + # name: Run unit tests + # runs-on: ubuntu-latest + # steps: + # - name: Checkout + # uses: actions/checkout@v3 + # with: + # fetch-depth: 0 + # ref: ${{ inputs.checkoutCommit }} - - name: Install Kubernetes tools - uses: yokawasa/action-setup-kube-tools@v0.8.2 - with: - setup-tools: | - helmv3 - helm: "3.8.0" + # - name: Install Kubernetes tools + # uses: yokawasa/action-setup-kube-tools@v0.8.2 + # with: + # setup-tools: | + # helmv3 + # helm: "3.8.0" - - name: Install Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: 2.7 + # - name: Install Ruby + # uses: ruby/setup-ruby@v1 + # with: + # ruby-version: 2.7 - - name: Install dependencies - env: - RUBYJQ_USE_SYSTEM_LIBRARIES: 1 - run: | - sudo apt-get update - sudo apt-get install libjq-dev - bundle install + # - name: Install dependencies + # env: + # RUBYJQ_USE_SYSTEM_LIBRARIES: 1 + # run: | + # sudo apt-get update + # sudo apt-get install libjq-dev + # bundle install - - name: Run tests - run: | - bundle exec m -r ./test/ + # - name: Run tests + # run: | + # bundle exec m -r ./test/ generate-install-matrix: name: Generate matrix for install @@ -51,7 +51,8 @@ jobs: outputs: matrix: | { - "chart": ${{ steps.list-changed.outputs.charts }} + "chart": ${{ steps.list-changed.outputs.charts }}, + "k8s_version": ["v1.21", "v1.24"] } detected: ${{ steps.list-changed.outputs.detected }} steps: @@ -68,10 +69,9 @@ jobs: id: list-changed if: inputs.chartChanges != '' run: | - EXCLUDED=$(yq eval -o=json '.excluded-charts // []' .github/ct-install.yaml) - CHARTS=$(ct list-changed --config .github/ct-install.yaml) - CHARTS_JSON=$(echo "${CHARTS}" | jq -R -s -c 'split("\n")[:-1]') - OUTPUT_JSON=$(echo "{\"excluded\": ${EXCLUDED}, \"all\": ${CHARTS_JSON}}" | jq -c '.all-.excluded') + EXCLUDED=$(yq eval '.excluded-charts-install | join(",")' .ci/ct/ct.yaml) + CHARTS=$(ct list-changed --config .ci/ct/ct.yaml --excluded-charts "${EXCLUDED}") + OUTPUT_JSON=$(echo "${CHARTS}" | jq -R -s -c 'split("\n")[:-1]') echo ::set-output name=charts::${OUTPUT_JSON} if [[ $(echo ${OUTPUT_JSON} | jq -c '. | length') -gt 0 ]]; then echo "::set-output name=detected::true" @@ -110,14 +110,14 @@ jobs: - name: Create k3d cluster uses: nolar/setup-k3d-k3s@v1 with: - version: v1.19 + version: ${{ matrix.k8s_version }} - name: Remove node taints run: | kubectl taint --all=true nodes node.cloudprovider.kubernetes.io/uninitialized- || true - name: Run chart-testing (install) - run: ct install --config .github/ct-install.yaml --charts ${{ matrix.chart }} + run: ct install --config .ci/ct/ct.yaml --charts ${{ matrix.chart }} # Summarize matrix https://github.community/t/status-check-for-a-matrix-jobs/127354/7 install_success: diff --git a/.taskfiles/charts.yaml b/.taskfiles/charts.yaml index fb0ed894..c508d13c 100644 --- a/.taskfiles/charts.yaml +++ b/.taskfiles/charts.yaml @@ -1,15 +1,23 @@ --- version: "3" +vars: + CT_IMAGE: quay.io/helmpack/chart-testing:v3.6.0 + CT_CONFIG_FILE: .ci/ct/ct.yaml + CHARTS_EXCLUDED_FROM_LINT: + sh: yq eval '.excluded-charts-lint | join(",")' {{.CT_CONFIG_FILE}} + CHARTS_EXCLUDED_FROM_INSTALL: + sh: yq eval '.excluded-charts-install | join(",")' {{.CT_CONFIG_FILE}} + tasks: lint: desc: Run ct-lint on charts cmds: - - docker run --rm -it --workdir=/data --volume $(pwd):/data quay.io/helmpack/chart-testing:v3.6.0 ct lint --config .ci/ct/ct-lint.yaml + - docker run --rm -it --workdir=/data --volume $(pwd):/data {{.CT_IMAGE}} ct lint --config {{.CT_CONFIG_FILE}} --excluded-charts "{{.CHARTS_EXCLUDED_FROM_LINT}}" silent: true lint-all: desc: Run ct-lint on all charts cmds: - - docker run --rm -it --workdir=/data --volume $(pwd):/data quay.io/helmpack/chart-testing:v3.6.0 ct lint --config .ci/ct/ct-lint.yaml --all + - docker run --rm -it --workdir=/data --volume $(pwd):/data {{.CT_IMAGE}} ct lint --config {{.CT_CONFIG_FILE}} --all --excluded-charts "{{.CHARTS_EXCLUDED_FROM_LINT}}" silent: true