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 }}