From 085bd01f1a6f5298e0a5577896acf22408f393eb 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: Thu, 3 Feb 2022 17:01:29 +0100 Subject: [PATCH] ci: Expand PR validation flow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Bᴇʀɴᴅ Sᴄʜᴏʀɢᴇʀs --- .github/workflows/charts-lint.yaml | 51 +++++++++++++++++++++ .github/workflows/charts-update-readme.yaml | 2 +- .github/workflows/pr-validate.yaml | 19 ++++++-- 3 files changed, 66 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/charts-lint.yaml diff --git a/.github/workflows/charts-lint.yaml b/.github/workflows/charts-lint.yaml new file mode 100644 index 00000000..6bca219f --- /dev/null +++ b/.github/workflows/charts-lint.yaml @@ -0,0 +1,51 @@ +name: "Charts: Lint" + +on: + workflow_call: + inputs: + checkoutCommit: + required: true + type: string + modifiedCharts: + required: true + type: string + +jobs: + lint: + name: Lint successful + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + ref: ${{ inputs.checkoutCommit }} + + - name: Install Helm + uses: azure/setup-helm@v1 + with: + version: v3.6.3 + + - uses: actions/setup-python@v2 + with: + python-version: 3.7 + + - name: Set up chart-testing + uses: helm/chart-testing-action@v2.1.0 + + - name: Collect changes + id: list-changed + run: | + EXCLUDED=$(yq eval -o=json '.excluded-charts // []' .github/ct-lint.yaml) + CHARTS=$(ct list-changed --config .github/ct-lint.yaml) + CHARTS_JSON=$(echo "${CHARTS}" | jq -R -s -c 'split("\n")[:-1]') + OUTPUT_JSON=$(echo "{\"excluded\": ${EXCLUDED}, \"all\": ${CHARTS_JSON}}" | jq -c '.all-.excluded') + echo ::set-output name=charts::${OUTPUT_JSON} + if [[ $(echo ${OUTPUT_JSON} | jq -c '. | length') -gt 0 ]]; then + echo "::set-output name=detected::true" + fi + + - name: Run chart-testing (lint) + id: lint + if: steps.list-changed.outputs.detected == 'true' + run: ct lint --config .github/ct-lint.yaml diff --git a/.github/workflows/charts-update-readme.yaml b/.github/workflows/charts-update-readme.yaml index 706da5cc..48e3d91c 100644 --- a/.github/workflows/charts-update-readme.yaml +++ b/.github/workflows/charts-update-readme.yaml @@ -77,7 +77,7 @@ jobs: - name: Store commit hash id: store-commit-hash run: | - if [ "${{ steps.create-commit.outputs.changes_detected }}" == "true"]; then + if [ "${{ steps.create-commit.outputs.changes_detected }}" == "true" ]; then echo '::set-output name=commit_hash::${{ steps.create-commit.outputs.commit_hash }}' else echo "::set-output name=commit_hash::${GITHUB_SHA}" diff --git a/.github/workflows/pr-validate.yaml b/.github/workflows/pr-validate.yaml index b27a393c..97438d2c 100644 --- a/.github/workflows/pr-validate.yaml +++ b/.github/workflows/pr-validate.yaml @@ -10,13 +10,22 @@ concurrency: # cancel-in-progress: true jobs: - pr-get-metadata: + pr-metadata: uses: k8s-at-home/charts/.github/workflows/pr-get-metadata.yaml@master - charts-update-readme: + charts-readme: uses: k8s-at-home/charts/.github/workflows/charts-update-readme.yaml@master needs: - - pr-get-metadata + - pr-metadata with: - isRenovatePR: ${{ needs.pr-get-metadata.outputs.isRenovatePR }} - modifiedCharts: ${{ needs.pr-get-metadata.outputs.addedOrModifiedCharts }} + isRenovatePR: ${{ needs.pr-metadata.outputs.isRenovatePR }} + modifiedCharts: ${{ needs.pr-metadata.outputs.addedOrModifiedCharts }} + + charts-lint: + uses: k8s-at-home/charts/.github/workflows/charts-lint.yaml@master + needs: + - pr-metadata + - charts-readme + with: + checkoutCommit: ${{ needs.charts-readme.outputs.commitHash }} + modifiedCharts: ${{ needs.pr-metadata.outputs.addedOrModifiedCharts }}