Files
truecharts/.github/workflows/charts-lint.yaml
T

140 lines
4.7 KiB
YAML

name: "Charts: Lint"
on:
workflow_call:
inputs:
checkoutCommit:
required: true
type: string
chartChangesDetected:
required: true
type: string
jobs:
generate-lint-matrix:
name: Generate matrix for lint
runs-on: ubuntu-latest
outputs:
matrix1: |
{
"chart": ${{ steps.list-changed.outputs.charts1 }}
}
matrix2: |
{
"chart": ${{ steps.list-changed.outputs.charts2 }}
}
detected1: ${{ steps.list-changed.outputs.detected1 }}
detected2: ${{ steps.list-changed.outputs.detected2 }}
steps:
- name: Checkout
uses: actions/checkout@a12a3943b4bdde767164f792f33f40b04645d846 # tag=v3
with:
fetch-depth: 0
ref: ${{ inputs.checkoutCommit }}
- name: Set up chart-testing
uses: helm/chart-testing-action@dae259e86a35ff09145c0805e2d7dd3f7207064a # tag=v2.2.1
- name: Collect changes
id: list-changed
if: inputs.chartChangesDetected == 'true'
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')
OUTPUT_JSON1=$(echo $OUTPUT_JSON | jq -r -c '.[:254]')
OUTPUT_JSON2=$(echo $OUTPUT_JSON | jq -r -c '.[254:500]')
echo ::set-output name=charts1::${OUTPUT_JSON1}
echo ::set-output name=charts2::${OUTPUT_JSON2}
if [[ $(echo ${OUTPUT_JSON1} | jq -c '. | length') -gt 0 ]]; then
echo "::set-output name=detected1::true"
fi
if [[ $(echo ${OUTPUT_JSON2} | jq -c '. | length') -gt 0 ]]; then
echo "::set-output name=detected2::true"
fi
lint-charts1:
needs:
- generate-lint-matrix
if: needs.generate-lint-matrix.outputs.detected1 == 'true'
name: Lint charts Part 1
strategy:
matrix: ${{ fromJson(needs.generate-lint-matrix.outputs.matrix1) }}
fail-fast: false
max-parallel: 10
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@a12a3943b4bdde767164f792f33f40b04645d846 # tag=v3
with:
fetch-depth: 0
ref: ${{ inputs.checkoutCommit }}
- name: lint Kubernetes tools
uses: yokawasa/action-setup-kube-tools@c81bf94cddd6c3172e6f61aa7f5ad66a2b5db98d # tag=v0.8.0
with:
setup-tools: |
helmv3
helm: "3.8.0"
- uses: actions/setup-python@9c644ca2ab8e57ea0a487b5ec2f8290740378bfd # tag=v3
with:
python-version: "3.10"
- name: Set up chart-testing
uses: helm/chart-testing-action@dae259e86a35ff09145c0805e2d7dd3f7207064a # tag=v2.2.1
- name: Run chart-testing (lint)
run: ct lint --config ".github/ct-lint.yaml" --charts "${{ matrix.chart }}"
lint-charts2:
needs:
- generate-lint-matrix
if: needs.generate-lint-matrix.outputs.detected2 == 'true'
name: Lint charts Part 2
strategy:
matrix: ${{ fromJson(needs.generate-lint-matrix.outputs.matrix2) }}
fail-fast: false
max-parallel: 5
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@a12a3943b4bdde767164f792f33f40b04645d846 # tag=v3
with:
fetch-depth: 0
ref: ${{ inputs.checkoutCommit }}
- name: lint Kubernetes tools
uses: yokawasa/action-setup-kube-tools@c81bf94cddd6c3172e6f61aa7f5ad66a2b5db98d # tag=v0.8.0
with:
setup-tools: |
helmv3
helm: "3.8.0"
- uses: actions/setup-python@9c644ca2ab8e57ea0a487b5ec2f8290740378bfd # tag=v3
with:
python-version: "3.10"
- name: Set up chart-testing
uses: helm/chart-testing-action@dae259e86a35ff09145c0805e2d7dd3f7207064a # tag=v2.2.1
- name: Run chart-testing (lint)
run: ct lint --config ".github/ct-lint.yaml" --charts "${{ matrix.chart }}"
# Summarize matrix https://github.community/t/status-check-for-a-matrix-jobs/127354/7
lint_success:
needs:
- generate-lint-matrix
- lint-charts1
- lint-charts2
if: |
always()
name: Lint successful
runs-on: ubuntu-latest
steps:
- name: Check lint matrix status
if: ${{ ( (needs.generate-lint-matrix.outputs.detected1 == 'true') && (needs.lint-charts1.result != 'success') ) && ( (needs.generate-lint-matrix.outputs.detected2 == 'true') && ( (needs.lint-charts2.result != 'success') || ( needs.lint-charts2.result != 'skipped' ) ) ) }}
run: exit 1