tests: introduce golden tests in kong chart using chartsnap #70
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: PR tests | |
concurrency: | |
# Run only for most recent commit in PRs but for all tags and commits on main | |
# Ref: https://docs.github.com/en/actions/using-jobs/using-concurrency | |
group: ${{ github.workflow }}-${{ github.head_ref || github.sha }} | |
cancel-in-progress: true | |
on: | |
pull_request: | |
branches: | |
- main | |
- release/kong-2.x | |
jobs: | |
lint: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version-file: third_party/go.mod | |
- name: Run linters | |
run: make lint | |
lint-test: | |
runs-on: ubuntu-latest | |
env: | |
# Specify this here because these tests rely on ktf to run kind for cluster creation. | |
KIND_VERSION: v0.20.0 | |
strategy: | |
matrix: | |
chart-name: | |
- kong | |
- ingress | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Helm | |
uses: azure/setup-helm@v3 | |
with: | |
version: v3.11.0 | |
- name: Add Helm repos | |
run: | | |
helm repo add bitnami https://charts.bitnami.com/bitnami | |
helm repo add kong https://charts.konghq.com | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: "3.11" | |
- name: Set up chart-testing | |
uses: helm/[email protected] | |
- name: Run chart-testing (lint) | |
run: ct lint --check-version-increment=false | |
- name: setup testing environment (kind-cluster) | |
env: | |
KUBERNETES_VERSION: ${{ matrix.kubernetes-version }} | |
run: ./scripts/test-env.sh | |
- name: Run chart-testing (install) | |
run: ct install --charts charts/${{ matrix.chart-name}} | |
integration-test: | |
runs-on: ubuntu-latest | |
env: | |
# Specify this here because these tests rely on ktf to run kind for cluster creation. | |
KIND_VERSION: v0.20.0 | |
GATEWAY_API_VERSION: v0.8.1 | |
strategy: | |
matrix: | |
kubernetes-version: | |
- "1.23.13" | |
- "1.24.7" | |
- "1.25.9" | |
- "1.26.4" | |
- "1.27.1" | |
chart-name: | |
- kong | |
- ingress | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: setup helm | |
uses: azure/setup-helm@v3 | |
with: | |
version: v3.11.0 | |
- name: setup testing environment (kind-cluster) | |
env: | |
KUBERNETES_VERSION: ${{ matrix.kubernetes-version }} | |
run: ./scripts/test-env.sh | |
- name: run integration tests (integration) | |
env: | |
CHART_NAME: ${{ matrix.chart-name }} | |
run: ./scripts/test-run.sh | |
- name: run upgrade integration tests (integration-upgrade) | |
env: | |
CHART_NAME: ${{ matrix.chart-name }} | |
run: ./scripts/test-upgrade.sh | |
- name: cleanup integration tests (cleanup) | |
run: ./scripts/test-env.sh cleanup | |
oldversion-integration-test: | |
runs-on: ubuntu-latest | |
env: | |
# Specify this here because these tests rely on ktf to run kind for cluster creation. | |
KIND_VERSION: v0.20.0 | |
GATEWAY_API_VERSION: v0.8.1 | |
strategy: | |
matrix: | |
kic-version: | |
- "2.10" | |
- "2.11" | |
kong-version: | |
- "3.3" | |
- "3.2" | |
chart-name: | |
- kong | |
- ingress | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: setup helm | |
uses: azure/setup-helm@v3 | |
with: | |
version: v3.11.0 | |
- name: setup testing environment (kind-cluster) | |
run: ./scripts/test-env.sh | |
- name: run integration tests (integration) | |
env: | |
CHART_NAME: ${{ matrix.chart-name }} | |
KONG_VERSION: ${{ matrix.kong-version }} | |
KIC_VERSION: ${{ matrix.kic-version }} | |
run: ./scripts/test-run.sh | |
- name: cleanup integration tests (cleanup) | |
run: ./scripts/test-env.sh cleanup | |
golden-tests: | |
runs-on: ubuntu-latest | |
name: Golden tests | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
# If these tests fail, it means that the chart has changed in a way that modified the rendered output | |
# of the chart using one of the values files in the charts/kong/ci/ directory. | |
# If this is expected, then the snapshots need to be updated using `make test.golden.update` command. | |
- name: Verify snapshots are up to date | |
uses: jlandowner/helm-chartsnap-action@v1 | |
id: chartsnap | |
with: | |
chart: charts/kong/ | |
values: charts/kong/ci/ | |
# Workaround to allow checking the matrix tests as required tests without adding the individual cases | |
# Ref: https://github.com/orgs/community/discussions/26822#discussioncomment-3305794 | |
passed: | |
runs-on: ubuntu-latest | |
needs: | |
- lint | |
- lint-test | |
- integration-test | |
- oldversion-integration-test | |
if: always() | |
steps: | |
- if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }} | |
run: | | |
echo "Some jobs failed or were cancelled." | |
exit 1 |