-
Notifications
You must be signed in to change notification settings - Fork 0
135 lines (119 loc) · 3.85 KB
/
charts-tests.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
name: "Charts: Test"
on:
workflow_call:
inputs:
checkoutCommit:
required: true
type: string
chartsToTest:
description: >
A JSON encoded array of charts to lint
type: string
required: true
overrideDeps:
description: >
A JSON encoded array of dependencies to override before testing
type: string
required: false
default: '[]'
env:
HELM_VERSION: 3.9.2
jobs:
install-chart:
name: Install chart
runs-on: ubuntu-22.04
if: ${{ inputs.chartsToTest != '[]' && inputs.chartsToTest != '' }}
strategy:
matrix:
chart: ${{ fromJSON(inputs.chartsToTest) }}
k8s_version: ["v1.22.17", "v1.23.15", "v1.24.9", "v1.25.5"]
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ inputs.checkoutCommit }}
- name: Install Kubernetes tools
uses: yokawasa/action-setup-kube-tools@v0.9.3
with:
setup-tools: |
helmv3
kubectl
helm: "${{ env.HELM_VERSION }}"
kubectl: "${{ matrix.k8s_version }}"
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Set up chart-testing
uses: helm/chart-testing-action@v2.4.0
- name: Create k3d cluster
uses: nolar/setup-k3d-k3s@v1
with:
version: ${{ matrix.k8s_version }}
- name: Remove node taints
run: |
kubectl taint --all=true nodes node.cloudprovider.kubernetes.io/uninitialized- || true
- name: Override chart dependencies
uses: ./.github/actions/override-chart-deps
if: ${{ inputs.overrideDeps != '[]' }}
with:
chart: ${{ matrix.chart }}
overrides: ${{ inputs.overrideDeps }}
- name: Run chart-testing (install)
run: ct install --config .ci/ct/ct.yaml --charts "charts/${{ matrix.chart }}"
# Summarize matrix https://github.community/t/status-check-for-a-matrix-jobs/127354/7
install_success:
needs:
- install-chart
if: |
always()
name: Install successful
runs-on: ubuntu-22.04
steps:
- name: Check install matrix status
if: ${{ (inputs.chartsToTest != '[]' && inputs.chartsToTest != '') && needs.install-chart.result != 'success' }}
run: exit 1
unittest-chart:
name: Unit-test chart
runs-on: ubuntu-20.04
if: ${{ inputs.chartsToTest != '[]' && inputs.chartsToTest != '' }}
strategy:
matrix:
chart: ${{ fromJSON(inputs.chartsToTest) }}
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ inputs.checkoutCommit }}
- name: Install Kubernetes tools
uses: yokawasa/action-setup-kube-tools@v0.9.3
with:
setup-tools: |
helmv3
helm: "${{ env.HELM_VERSION }}"
- name: Override chart dependencies
uses: ./.github/actions/override-chart-deps
if: ${{ inputs.overrideDeps != '[]' }}
with:
chart: ${{ matrix.chart }}
overrides: ${{ inputs.overrideDeps }}
- name: Run tests
run: |
helm plugin install https://github.com/vbehar/helm3-unittest --version v1.0.16
helm dep update "charts/${{ matrix.chart }}"
helm unittest -f "tests/**/*_test.yaml" "charts/${{ matrix.chart }}"
# Summarize matrix https://github.community/t/status-check-for-a-matrix-jobs/127354/7
unittest_success:
needs:
- unittest-chart
if: |
always()
name: Unittest successful
runs-on: ubuntu-22.04
steps:
- name: Check unittest matrix status
if: ${{ (inputs.chartsToTest != '[]' && inputs.chartsToTest != '') && needs.unittest-chart.result != 'success' }}
run: exit 1