Skip to content

ci(actions): output matrix json in prep_job #150

ci(actions): output matrix json in prep_job

ci(actions): output matrix json in prep_job #150

---
name: Lint and Test Charts
"on":
pull_request:
types:
- opened
- synchronize
- reopened
branches:
- main
env:
python_version: '3.10'
jobs:
prep_job:
runs-on: ubuntu-latest
outputs:
has_changes: ${{ steps.changed-files.outputs.any_changed }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: tj-actions/changed-files@v41
id: changed-files
with:
files: |
**/*.yaml
**/*.yml
**/*.tpl
!**/.*md
!.github/**
- run: |
echo "Has changes: ${{ steps.changed-files.outputs.any_changed }}"
echo "Changed files: ${{ steps.changed-files.outputs.all_changed_files }}"
test:
runs-on: ubuntu-latest
needs: prep_job
env:
# see https://github.com/kubernetes-sigs/kind/releases
# make sure to update the image refs in the matrix as well, when update this version!
kind_version: v0.20.0
has_relevant_changes: ${{ needs.prep_job.outputs.has_changes }}
strategy:
matrix:
include:
- name: k8s-1.29
kindest_image: kindest/node:v1.29.0
- name: k8s-1.28
kindest_image: kindest/node:v1.28.0
- name: k8s-1.27
kindest_image: kindest/node:v1.27.3
- name: k8s-1.26
kindest_image: kindest/node:v1.26.6
- name: k8s-1.25
kindest_image: kindest/node:v1.25.11
- name: k8s-1.24
kindest_image: kindest/node:v1.24.15
- name: k8s-1.23
kindest_image: kindest/node:v1.23.17
name: ${{ matrix.name }}
steps:
- run: |
echo "Skip following steps as there're no relevant changes found in this pull request."
exit 0
if: ${{ needs.prep_job.outputs.has_changes == 'true' }}
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: azure/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/setup-python@v5
with:
python-version: ${{ env.python_version }}
- name: Set up chart-testing
uses: helm/[email protected]
- name: Lint charts
run: ct lint --config .github/workflows/conf/ct-lint.yml
- uses: helm/kind-action@main
with:
config: .github/workflows/conf/kind.yml
version: ${{ env.kind_version }}
node_image: ${{ matrix.kindest_image }}
- name: Create chart preconditions
run: .github/workflows/scripts/chart-test-prep.sh
- name: Chart installation tests
run: .github/workflows/scripts/chart-test.sh
- name: Debug information on failure
run: kubectl describe nodes; echo "=== API Versions ==="; kubectl api-versions; echo "=== CRDs ==="; kubectl get crd
if: failure()
lint:
runs-on: ubuntu-latest
needs: prep_job
if: ${{ needs.prep_job.outputs.has_changes == 'true' }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: ${{ env.python_version }}
- name: Run checkov on each test case permutation
run: .github/workflows/scripts/checkov-chart-linting.sh