chore: document how to test unpublished charts #413
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: Lint and Test Charts | |
on: pull_request | |
jobs: | |
lint-test: | |
strategy: | |
matrix: | |
k8s_ver: [v1.29.8, v1.30.4, v1.31.0] | |
helm_ver: [v3.13.2, v3.15.4, v3.16.1] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Set up Helm | |
uses: azure/setup-helm@v3 | |
with: | |
version: ${{ matrix.helm_ver }} | |
- name: Set up kubectl | |
uses: azure/setup-kubectl@v4 | |
with: | |
version: latest | |
id: install | |
- name: Create kind cluster | |
uses: helm/kind-action@v1.9.0 | |
with: | |
node_image: kindest/node:${{ matrix.k8s_ver }} | |
- name: Validate chart template with default values | |
run: | | |
helm repo add argo-helm-charts https://chanzuckerberg.github.io/argo-helm-charts/ | |
helm dependency update ./stack | |
helm dependency build ./stack | |
output=$(helm template ./stack --values ./test-fixtures/values.yaml | kubectl apply -f - --dry-run=client 2>&1 || :) | |
if [[ $output -ne "error: no objects passed to apply" ]]; then | |
exit 1 | |
fi | |
- name: Validate chart template with invalid values | |
run: | | |
output=$(helm template ./stack --values ./test-fixtures/values1.yaml | kubectl apply -f - --dry-run=client 2>&1 || :) | |
if [[ $output -ne "Error: failed to parse ./test-fixtures/values1.yaml: error unmarshaling JSON: while decoding JSON: json: cannot unmarshal string into Go value of type map[string]interface {}" ]]; then | |
exit 1 | |
fi | |
- name: Validate chart template with valid values | |
run: | | |
helm template ./stack --values ./test-fixtures/values2.yaml | kubectl apply -f - --dry-run=client 2>&1 | |
- name: Install helm on cluster | |
if: steps.list-changed.outputs.changed == 'true' | |
run: | | |
helm repo add argo-helm-charts https://chanzuckerberg.github.io/argo-helm-charts/ | |
helm dep update ./stack | |
helm dependency build ./stack | |
helm install test ./stack --wait --values ./test-fixtures/gha-cluster-values.yaml --debug | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: '3.12' | |
check-latest: true | |
- name: Set up chart-testing | |
uses: helm/chart-testing-action@v2.6.1 | |
- name: Run chart-testing (list-changed) | |
id: list-changed | |
run: | | |
changed=$(ct list-changed --chart-dirs . --target-branch ${{ github.event.repository.default_branch }}) | |
if [[ -n "$changed" ]]; then | |
echo "changed=true" >> "$GITHUB_OUTPUT" | |
fi | |
- name: Run chart-testing (lint) | |
if: steps.list-changed.outputs.changed == 'true' | |
run: ct lint --target-branch ${{ github.event.repository.default_branch }} | |
- name: Run chart-testing (install) | |
if: steps.list-changed.outputs.changed == 'true' | |
run: ct install --target-branch ${{ github.event.repository.default_branch }} | |
# job to aggregate lint-test matrix job completion | |
matrix-complete: | |
needs: lint-test | |
runs-on: ubuntu-latest | |
steps: | |
- name: complete | |
run: echo "Done!" |