TrueChartsClone/.github/workflows/charts-lint.yaml

93 lines
2.6 KiB
YAML
Raw Normal View History

name: "Charts: Lint"
on:
workflow_call:
inputs:
checkoutCommit:
required: true
type: string
chartChangesDetected:
required: true
type: string
jobs:
2022-03-30 13:59:15 -04:00
generate-lint-matrix:
name: Generate matrix for lint
runs-on: ubuntu-latest
2022-03-30 13:59:15 -04:00
outputs:
matrix: |
{
"chart": ${{ steps.list-changed.outputs.charts }}
}
detected: ${{ steps.list-changed.outputs.detected }}
steps:
- name: Checkout
2022-03-30 13:59:15 -04:00
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ inputs.checkoutCommit }}
- name: Set up chart-testing
2022-03-30 13:59:15 -04:00
uses: helm/chart-testing-action@v2.2.1
2022-03-30 13:59:15 -04:00
- name: Run chart-testing (list-changed)
id: list-changed
if: inputs.chartChangesDetected == 'true'
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
2022-03-30 13:59:15 -04:00
lint-charts:
needs:
- generate-lint-matrix
if: needs.generate-lint-matrix.outputs.detected == 'true'
name: lint charts
strategy:
matrix: ${{ fromJson(needs.generate-lint-matrix.outputs.matrix) }}
fail-fast: true
max-parallel: 15
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ inputs.checkoutCommit }}
- name: lint Kubernetes tools
uses: yokawasa/action-setup-kube-tools@v0.8.0
with:
setup-tools: |
helmv3
helm: "3.8.0"
- uses: actions/setup-python@v3
with:
python-version: "3.10"
- name: Set up chart-testing
uses: helm/chart-testing-action@v2.2.1
- name: Run chart-testing (lint)
2022-03-30 13:59:15 -04:00
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-charts
if: |
always()
name: Lint successful
runs-on: ubuntu-latest
steps:
- name: Check lint matrix status
if: ${{ (needs.generate-lint-matrix.outputs.detected == 'true') && (needs.lint-charts.result != 'success') }}
run: exit 1