mirror of
https://github.com/bjw-s-labs/helm-charts.git
synced 2025-07-03 08:37:03 +02:00
99 lines
2.8 KiB
YAML
99 lines
2.8 KiB
YAML
name: "Charts: Lint"
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
checkoutCommit:
|
|
required: true
|
|
type: string
|
|
chartChanges:
|
|
required: true
|
|
type: string
|
|
|
|
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'
|
|
name: Lint chart
|
|
strategy:
|
|
matrix: ${{ fromJson(needs.generate-lint-matrix.outputs.lint-matrix) }}
|
|
fail-fast: false
|
|
runs-on: ubuntu-22.04
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
with:
|
|
fetch-depth: 0
|
|
ref: ${{ inputs.checkoutCommit }}
|
|
|
|
- name: Install zx
|
|
shell: bash
|
|
run: |
|
|
npm i --location=global zx
|
|
npm link zx
|
|
|
|
- name: Check chart version update
|
|
shell: bash
|
|
run: |
|
|
if ! zx .ci/scripts/check_chart_version.mjs "charts/${{ matrix.chart }}" ; then
|
|
echo "::error::Chart version has not been updated!" && exit 1
|
|
fi
|
|
|
|
- name: Install Kubernetes tools
|
|
uses: yokawasa/action-setup-kube-tools@v0.8.2
|
|
with:
|
|
setup-tools: |
|
|
helmv3
|
|
helm: "${{ env.HELM_VERSION }}"
|
|
|
|
- name: Set up chart-testing
|
|
uses: helm/chart-testing-action@v2.2.1
|
|
|
|
- name: Run chart-testing (install)
|
|
run: ct lint --config .ci/ct/ct.yaml --charts "charts/${{ matrix.chart }}"
|
|
|
|
# Summarize matrix https://github.community/t/status-check-for-a-matrix-jobs/127354/7
|
|
lint_success:
|
|
needs:
|
|
- generate-lint-matrix
|
|
- lint-chart
|
|
if: |
|
|
always()
|
|
name: Lint successful
|
|
runs-on: ubuntu-22.04
|
|
steps:
|
|
- name: Check lint matrix status
|
|
if: ${{ (needs.generate-lint-matrix.outputs.detected == 'true') && (needs.lint-chart.result != 'success') }}
|
|
run: exit 1
|