-
Notifications
You must be signed in to change notification settings - Fork 0
95 lines (78 loc) · 3.18 KB
/
chart-testing.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
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!"