ci: Expand PR validation flow

Signed-off-by: Bᴇʀɴᴅ Sᴄʜᴏʀɢᴇʀs <me@bjw-s.dev>
This commit is contained in:
Bᴇʀɴᴅ Sᴄʜᴏʀɢᴇʀs 2022-02-03 17:01:29 +01:00
parent b4af8c56c1
commit 085bd01f1a
No known key found for this signature in database
GPG Key ID: BC5E2BD907F9A8EC
3 changed files with 66 additions and 6 deletions

51
.github/workflows/charts-lint.yaml vendored Normal file
View File

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

View File

@ -77,7 +77,7 @@ jobs:
- name: Store commit hash - name: Store commit hash
id: store-commit-hash id: store-commit-hash
run: | 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 }}' echo '::set-output name=commit_hash::${{ steps.create-commit.outputs.commit_hash }}'
else else
echo "::set-output name=commit_hash::${GITHUB_SHA}" echo "::set-output name=commit_hash::${GITHUB_SHA}"

View File

@ -10,13 +10,22 @@ concurrency:
# cancel-in-progress: true # cancel-in-progress: true
jobs: jobs:
pr-get-metadata: pr-metadata:
uses: k8s-at-home/charts/.github/workflows/pr-get-metadata.yaml@master 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 uses: k8s-at-home/charts/.github/workflows/charts-update-readme.yaml@master
needs: needs:
- pr-get-metadata - pr-metadata
with: with:
isRenovatePR: ${{ needs.pr-get-metadata.outputs.isRenovatePR }} isRenovatePR: ${{ needs.pr-metadata.outputs.isRenovatePR }}
modifiedCharts: ${{ needs.pr-get-metadata.outputs.addedOrModifiedCharts }} 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 }}