mirror of
https://github.com/bjw-s-labs/helm-charts.git
synced 2025-07-04 00:47:04 +02:00
Implement custom action to collect changes / matrix
This commit is contained in:
parent
fe0b8338e0
commit
d83abae451
20 changed files with 22213 additions and 183 deletions
42
.github/workflows/charts-lint.yaml
vendored
42
.github/workflows/charts-lint.yaml
vendored
|
@ -6,7 +6,9 @@ on:
|
|||
checkoutCommit:
|
||||
required: true
|
||||
type: string
|
||||
chartChanges:
|
||||
chartsToLint:
|
||||
description: >
|
||||
A JSON encoded array of charts to lint
|
||||
required: true
|
||||
type: string
|
||||
|
||||
|
@ -14,41 +16,12 @@ env:
|
|||
HELM_VERSION: 3.9.2
|
||||
|
||||
jobs:
|
||||
generate-lint-matrix:
|
||||
name: Generate matrix for linting
|
||||
runs-on: ubuntu-22.04
|
||||
outputs:
|
||||
lint-matrix: |
|
||||
{
|
||||
"chart": ${{ steps.list-changed.outputs.charts }}
|
||||
}
|
||||
detected: ${{ steps.list-changed.outputs.detected }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
ref: ${{ inputs.checkoutCommit }}
|
||||
|
||||
- name: Run chart-testing (list-changed)
|
||||
id: list-changed
|
||||
if: inputs.chartChanges != ''
|
||||
run: |
|
||||
EXCLUDED=$(yq -o json eval '.excluded-charts-lint' .ci/ct/ct.yaml)
|
||||
CHARTS_JSON=$(yq --null-input -o json eval '"${{ inputs.chartChanges }}" | split(" ")')
|
||||
OUTPUT_JSON=$(yq --null-input -o json eval "$CHARTS_JSON - $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
|
||||
|
||||
lint-chart:
|
||||
needs:
|
||||
- generate-lint-matrix
|
||||
if: needs.generate-lint-matrix.outputs.detected == 'true'
|
||||
if: ${{ inputs.chartsToLint != '[]' }}
|
||||
name: Lint chart
|
||||
strategy:
|
||||
matrix: ${{ fromJson(needs.generate-lint-matrix.outputs.lint-matrix) }}
|
||||
matrix:
|
||||
chart: ${{ fromJSON(inputs.chartsToLint) }}
|
||||
fail-fast: false
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
|
@ -80,7 +53,6 @@ jobs:
|
|||
# Summarize matrix https://github.community/t/status-check-for-a-matrix-jobs/127354/7
|
||||
lint_success:
|
||||
needs:
|
||||
- generate-lint-matrix
|
||||
- lint-chart
|
||||
if: |
|
||||
always()
|
||||
|
@ -88,5 +60,5 @@ jobs:
|
|||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- name: Check lint matrix status
|
||||
if: ${{ (needs.generate-lint-matrix.outputs.detected == 'true') && (needs.lint-chart.result != 'success') }}
|
||||
if: ${{ (inputs.chartsToLint != '' && inputs.chartsToLint != '[]') && (needs.lint-chart.result != 'success') }}
|
||||
run: exit 1
|
||||
|
|
62
.github/workflows/charts-test.yaml
vendored
62
.github/workflows/charts-test.yaml
vendored
|
@ -6,7 +6,9 @@ on:
|
|||
checkoutCommit:
|
||||
required: true
|
||||
type: string
|
||||
chartChanges:
|
||||
chartsToTest:
|
||||
description: >
|
||||
A JSON encoded array of charts to lint
|
||||
required: true
|
||||
type: string
|
||||
|
||||
|
@ -14,48 +16,15 @@ env:
|
|||
HELM_VERSION: 3.9.2
|
||||
|
||||
jobs:
|
||||
generate-test-matrix:
|
||||
name: Generate matrix for install
|
||||
runs-on: ubuntu-22.04
|
||||
outputs:
|
||||
install-matrix: |
|
||||
{
|
||||
"chart": ${{ steps.list-changed.outputs.charts }},
|
||||
"k8s_version": ["v1.22.12", "v1.24.3"]
|
||||
}
|
||||
unittest-matrix: |
|
||||
{
|
||||
"chart": ${{ steps.list-changed.outputs.charts }}
|
||||
}
|
||||
detected: ${{ steps.list-changed.outputs.detected }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
ref: ${{ inputs.checkoutCommit }}
|
||||
|
||||
- name: Run chart-testing (list-changed)
|
||||
id: list-changed
|
||||
if: inputs.chartChanges != ''
|
||||
run: |
|
||||
EXCLUDED=$(yq -o json eval '.excluded-charts-install' .ci/ct/ct.yaml)
|
||||
CHARTS_JSON=$(yq --null-input -o json eval '"${{ inputs.chartChanges }}" | split(" ")')
|
||||
OUTPUT_JSON=$(yq --null-input -o json eval "$CHARTS_JSON - $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
|
||||
|
||||
install-chart:
|
||||
needs:
|
||||
- generate-test-matrix
|
||||
if: needs.generate-test-matrix.outputs.detected == 'true'
|
||||
name: Install chart
|
||||
strategy:
|
||||
matrix: ${{ fromJson(needs.generate-test-matrix.outputs.install-matrix) }}
|
||||
fail-fast: false
|
||||
runs-on: ubuntu-22.04
|
||||
if: ${{ inputs.chartsToTest != '' && inputs.chartsToTest != '[]' }}
|
||||
strategy:
|
||||
matrix:
|
||||
chart: ${{ fromJSON(inputs.chartsToTest) }}
|
||||
k8s_version: ["v1.22.12", "v1.24.3"]
|
||||
fail-fast: false
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
@ -94,7 +63,6 @@ jobs:
|
|||
# Summarize matrix https://github.community/t/status-check-for-a-matrix-jobs/127354/7
|
||||
install_success:
|
||||
needs:
|
||||
- generate-test-matrix
|
||||
- install-chart
|
||||
if: |
|
||||
always()
|
||||
|
@ -102,17 +70,16 @@ jobs:
|
|||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- name: Check install matrix status
|
||||
if: ${{ (needs.generate-test-matrix.outputs.detected == 'true') && (needs.install-chart.result != 'success') }}
|
||||
if: ${{ (inputs.chartsToTest != '' && inputs.chartsToTest != '[]') && needs.install-chart.result != 'success' }}
|
||||
run: exit 1
|
||||
|
||||
unittest-chart:
|
||||
name: Unit-test chart
|
||||
runs-on: ubuntu-20.04
|
||||
needs:
|
||||
- generate-test-matrix
|
||||
if: needs.generate-test-matrix.outputs.detected == 'true'
|
||||
if: ${{ inputs.chartsToTest != '' && inputs.chartsToTest != '[]' }}
|
||||
strategy:
|
||||
matrix: ${{ fromJson(needs.generate-test-matrix.outputs.unittest-matrix) }}
|
||||
matrix:
|
||||
chart: ${{ fromJSON(inputs.chartsToTest) }}
|
||||
fail-fast: false
|
||||
steps:
|
||||
- name: Checkout
|
||||
|
@ -138,7 +105,6 @@ jobs:
|
|||
# Summarize matrix https://github.community/t/status-check-for-a-matrix-jobs/127354/7
|
||||
unittest_success:
|
||||
needs:
|
||||
- generate-test-matrix
|
||||
- unittest-chart
|
||||
if: |
|
||||
always()
|
||||
|
@ -146,5 +112,5 @@ jobs:
|
|||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- name: Check unittest matrix status
|
||||
if: ${{ (needs.generate-test-matrix.outputs.detected == 'true') && (needs.unittest-chart.result != 'success') }}
|
||||
if: ${{ (inputs.chartsToTest != '' && inputs.chartsToTest != '[]') && needs.unittest-chart.result != 'success' }}
|
||||
run: exit 1
|
||||
|
|
31
.github/workflows/pr-metadata.yaml
vendored
31
.github/workflows/pr-metadata.yaml
vendored
|
@ -9,15 +9,19 @@ on:
|
|||
isFork:
|
||||
description: "Is the PR coming from a forked repo?"
|
||||
value: ${{ jobs.pr-metadata.outputs.isFork }}
|
||||
addedOrModified:
|
||||
addedOrModifiedFilesDetected:
|
||||
description: "Does the PR contain any changes?"
|
||||
value: ${{ jobs.pr-changes.outputs.addedOrModified }}
|
||||
value: ${{ jobs.pr-changes.outputs.addedOrModifiedFilesDetected }}
|
||||
addedOrModifiedFiles:
|
||||
description: "A list of the files changed in this PR"
|
||||
value: ${{ jobs.pr-changes.outputs.addedOrModifiedFiles }}
|
||||
addedOrModifiedCharts:
|
||||
description: "A list of the charts changed in this PR"
|
||||
value: ${{ jobs.pr-changes.outputs.addedOrModifiedCharts }}
|
||||
chartsToLint:
|
||||
value: ${{ jobs.pr-changes.outputs.chartsToLint }}
|
||||
chartsToInstall:
|
||||
value: ${{ jobs.pr-changes.outputs.chartsToInstall }}
|
||||
|
||||
jobs:
|
||||
pr-metadata:
|
||||
|
@ -48,17 +52,26 @@ jobs:
|
|||
name: Collect PR changes
|
||||
runs-on: ubuntu-22.04
|
||||
outputs:
|
||||
addedOrModified: ${{ steps.collect-changes.outputs.changesDetected }}
|
||||
addedOrModifiedFiles: ${{ steps.collect-changes.outputs.addedOrModifiedFiles }}
|
||||
addedOrModifiedCharts: ${{ steps.collect-changes.outputs.addedOrModifiedCharts }}
|
||||
addedOrModifiedFilesDetected: ${{ steps.changed-files.outputs.allAddedOrModified }}
|
||||
addedOrModifiedFiles: ${{ steps.changed-files.outputs.allAddedOrModified_files }}
|
||||
addedOrModifiedCharts: ${{ steps.changed-charts.outputs.changedCharts }}
|
||||
chartsToLint: ${{ steps.changed-charts.outputs.chartsToLint }}
|
||||
chartsToInstall: ${{ steps.changed-charts.outputs.chartsToInstall }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Collect changes
|
||||
id: collect-changes
|
||||
uses: ./.github/actions/collect-changes
|
||||
- name: Collect changed files
|
||||
uses: dorny/paths-filter@v2
|
||||
id: changed-files
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
list-files: json
|
||||
filters: |
|
||||
allAddedOrModified:
|
||||
- added|modified: '**'
|
||||
|
||||
- name: Collect changed charts
|
||||
uses: ./.github/actions/collect-changed-charts
|
||||
id: changed-charts
|
||||
|
|
4
.github/workflows/pr-validate.yaml
vendored
4
.github/workflows/pr-validate.yaml
vendored
|
@ -43,7 +43,7 @@ jobs:
|
|||
# - charts-changelog
|
||||
with:
|
||||
checkoutCommit: ${{ github.sha }}
|
||||
chartChanges: ${{ needs.pr-metadata.outputs.addedOrModifiedCharts }}
|
||||
chartsToLint: ${{ needs.pr-metadata.outputs.chartsToLint }}
|
||||
|
||||
charts-test:
|
||||
uses: bjw-s/helm-charts/.github/workflows/charts-test.yaml@main
|
||||
|
@ -52,4 +52,4 @@ jobs:
|
|||
# - charts-changelog
|
||||
with:
|
||||
checkoutCommit: ${{ github.sha }}
|
||||
chartChanges: ${{ needs.pr-metadata.outputs.addedOrModifiedCharts }}
|
||||
chartsToTest: ${{ needs.pr-metadata.outputs.chartsToInstall }}
|
||||
|
|
4
.github/workflows/pre-commit-check.yaml
vendored
4
.github/workflows/pre-commit-check.yaml
vendored
|
@ -4,6 +4,8 @@ on:
|
|||
workflow_call:
|
||||
inputs:
|
||||
modifiedFiles:
|
||||
description: >
|
||||
A JSON encoded array of files to check
|
||||
required: true
|
||||
type: string
|
||||
|
||||
|
@ -18,4 +20,4 @@ jobs:
|
|||
- name: Run against changes
|
||||
uses: pre-commit/action@v3.0.0
|
||||
with:
|
||||
extra_args: --files ${{ inputs.modifiedFiles }} --config .ci/pre-commit/config.yaml
|
||||
extra_args: --files ${{ join(fromJson(inputs.modifiedFiles), ' ') }} --config .ci/pre-commit/config.yaml
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue