Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 92bd0d7

Browse files
mikesmithghgrzesuav
authored andcommitted
ci(helm): Add helm chart testing
Signed-off-by: Mike Smith <[email protected]>
1 parent 41a462e commit 92bd0d7

File tree

8 files changed

+408
-18
lines changed

8 files changed

+408
-18
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Copied from https://github.com/helm/chart-testing/blob/main/etc/chart_schema.yaml
2+
name: str()
3+
home: str(required=False)
4+
version: str()
5+
apiVersion: str()
6+
appVersion: any(str(), num(), required=False)
7+
description: str(required=False)
8+
keywords: list(str(), required=False)
9+
sources: list(str(), required=False)
10+
maintainers: list(include('maintainer'), required=False)
11+
dependencies: list(include('dependency'), required=False)
12+
icon: str(required=False)
13+
engine: str(required=False)
14+
condition: str(required=False)
15+
tags: str(required=False)
16+
deprecated: bool(required=False)
17+
kubeVersion: str(required=False)
18+
annotations: map(str(), str(), required=False)
19+
type: str(required=False)
20+
---
21+
maintainer:
22+
name: str()
23+
email: str(required=False)
24+
url: str(required=False)
25+
---
26+
dependency:
27+
name: str()
28+
version: str()
29+
repository: str(required=False)
30+
condition: str(required=False)
31+
tags: list(str(), required=False)
32+
enabled: bool(required=False)
33+
import-values: any(list(str()), list(include('import-value')), required=False)
34+
alias: str(required=False)
35+
---
36+
import-value:
37+
child: str()
38+
parent: str()
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Copied from https://github.com/helm/chart-testing/blob/main/etc/lintconf.yaml
2+
---
3+
rules:
4+
braces:
5+
min-spaces-inside: 0
6+
max-spaces-inside: 0
7+
min-spaces-inside-empty: -1
8+
max-spaces-inside-empty: -1
9+
brackets:
10+
min-spaces-inside: 0
11+
max-spaces-inside: 0
12+
min-spaces-inside-empty: -1
13+
max-spaces-inside-empty: -1
14+
colons:
15+
max-spaces-before: 0
16+
max-spaces-after: 1
17+
commas:
18+
max-spaces-before: 0
19+
min-spaces-after: 1
20+
max-spaces-after: 1
21+
comments:
22+
require-starting-space: true
23+
min-spaces-from-content: 2
24+
document-end: disable
25+
document-start: disable # No --- to start a file
26+
empty-lines:
27+
max: 2
28+
max-start: 0
29+
max-end: 0
30+
hyphens:
31+
max-spaces-after: 1
32+
indentation:
33+
spaces: consistent
34+
indent-sequences: whatever # - list indentation will handle both indentation and without
35+
check-multi-line-strings: false
36+
key-duplicates: enable
37+
line-length: disable # Lines can be any length
38+
new-line-at-end-of-file: enable
39+
new-lines:
40+
type: unix
41+
trailing-spaces: enable
42+
truthy:
43+
level: warning
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
{
2+
"configuration": [
3+
{
4+
"version": "1.14",
5+
"kind": "v0.11.1",
6+
"image": "kindest/node:v1.14.10@sha256:f8a66ef82822ab4f7569e91a5bccaf27bceee135c1457c512e54de8c6f7219f8",
7+
"crd_version": "v1beta1"
8+
},
9+
{
10+
"version": "1.15",
11+
"kind": "v0.11.1",
12+
"image": "kindest/node:v1.15.12@sha256:b920920e1eda689d9936dfcf7332701e80be12566999152626b2c9d730397a95",
13+
"crd_version": "v1beta1"
14+
},
15+
{
16+
"version": "1.16",
17+
"kind": "v0.11.1",
18+
"image": "kindest/node:v1.16.15@sha256:83067ed51bf2a3395b24687094e283a7c7c865ccc12a8b1d7aa673ba0c5e8861",
19+
"crd_version": "v1"
20+
},
21+
{
22+
"version": "1.17",
23+
"kind": "v0.11.1",
24+
"image": "kindest/node:v1.17.17@sha256:66f1d0d91a88b8a001811e2f1054af60eef3b669a9a74f9b6db871f2f1eeed00",
25+
"crd_version": "v1"
26+
},
27+
{
28+
"version": "1.18",
29+
"kind": "v0.11.1",
30+
"image": "kindest/node:v1.18.19@sha256:7af1492e19b3192a79f606e43c35fb741e520d195f96399284515f077b3b622c",
31+
"crd_version": "v1"
32+
},
33+
{
34+
"version": "1.19",
35+
"kind": "v0.11.1",
36+
"image": "kindest/node:v1.19.11@sha256:07db187ae84b4b7de440a73886f008cf903fcf5764ba8106a9fd5243d6f32729",
37+
"crd_version": "v1"
38+
},
39+
{
40+
"version": "1.20",
41+
"kind": "v0.11.1",
42+
"image": "kindest/node:v1.20.7@sha256:cbeaf907fc78ac97ce7b625e4bf0de16e3ea725daf6b04f930bd14c67c671ff9",
43+
"crd_version": "v1"
44+
},
45+
{
46+
"version": "1.21",
47+
"kind": "v0.11.1",
48+
"image": "kindest/node:v1.21.1@sha256:69860bda5563ac81e3c0057d654b5253219618a22ec3a346306239bba8cfa1a6",
49+
"crd_version": "v1"
50+
},
51+
{
52+
"version": "1.22",
53+
"kind": "v0.11.1",
54+
"image": "kindest/node:v1.22.0@sha256:b8bda84bb3a190e6e028b1760d277454a72267a5454b57db34437c34a588d047",
55+
"crd_version": "v1"
56+
},
57+
{
58+
"version": "1.23",
59+
"kind": "v0.11.1",
60+
"image": "kindest/node:v1.23.0@sha256:49824ab1727c04e56a21a5d8372a402fcd32ea51ac96a2706a12af38934f81ac",
61+
"crd_version": "v1"
62+
}
63+
]
64+
}

.github/workflows/test_release.yaml

Lines changed: 80 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,24 @@
22
name: Test / Release
33
on: [push, pull_request]
44
jobs:
5+
setmatrix:
6+
name: Set Configuration Matrix
7+
runs-on: ubuntu-latest
8+
outputs:
9+
matrix: ${{ steps.set-matrix.outputs.matrix }}
10+
v1_matrix: ${{ steps.set-matrix.outputs.v1_matrix }}
11+
steps:
12+
- name: checkout
13+
uses: actions/checkout@v3
14+
with:
15+
fetch-depth: '5'
16+
- id: set-matrix
17+
name: setconfigmatrix
18+
run: |
19+
full_json=$(cat ./.github/config/kind-matrix-config.json | jq -rc .)
20+
v1_json=$(cat ./.github/config/kind-matrix-config.json | jq -rc '.configuration |= map(select(.crd_version == "v1"))')
21+
echo "::set-output name=matrix::${full_json}"
22+
echo "::set-output name=v1_matrix::${v1_json}"
523
tests:
624
runs-on: ubuntu-20.04
725
name: Tests
@@ -31,58 +49,102 @@ jobs:
3149
fail_ci_if_error: true # optional (default = false)
3250
e2etests:
3351
runs-on: ubuntu-20.04
52+
needs: ['setmatrix']
3453
strategy:
3554
fail-fast: false
36-
matrix:
37-
configuration:
38-
- {version: '1.14', kind: "v0.11.1", image: 'kindest/node:v1.14.10@sha256:f8a66ef82822ab4f7569e91a5bccaf27bceee135c1457c512e54de8c6f7219f8', crd_version: 'v1beta1' }
39-
- {version: '1.15', kind: "v0.11.1", image: 'kindest/node:v1.15.12@sha256:b920920e1eda689d9936dfcf7332701e80be12566999152626b2c9d730397a95', crd_version: 'v1beta1' }
40-
- {version: '1.16', kind: "v0.11.1", image: 'kindest/node:v1.16.15@sha256:83067ed51bf2a3395b24687094e283a7c7c865ccc12a8b1d7aa673ba0c5e8861', crd_version: 'v1' }
41-
- {version: '1.17', kind: "v0.11.1", image: 'kindest/node:v1.17.17@sha256:66f1d0d91a88b8a001811e2f1054af60eef3b669a9a74f9b6db871f2f1eeed00', crd_version: 'v1' }
42-
- {version: '1.18', kind: "v0.11.1", image: 'kindest/node:v1.18.19@sha256:7af1492e19b3192a79f606e43c35fb741e520d195f96399284515f077b3b622c', crd_version: 'v1' }
43-
- {version: '1.19', kind: "v0.11.1", image: 'kindest/node:v1.19.11@sha256:07db187ae84b4b7de440a73886f008cf903fcf5764ba8106a9fd5243d6f32729', crd_version: 'v1' }
44-
- {version: '1.20', kind: "v0.11.1", image: 'kindest/node:v1.20.7@sha256:cbeaf907fc78ac97ce7b625e4bf0de16e3ea725daf6b04f930bd14c67c671ff9', crd_version: 'v1' }
45-
- {version: '1.21', kind: "v0.11.1", image: 'kindest/node:v1.21.1@sha256:69860bda5563ac81e3c0057d654b5253219618a22ec3a346306239bba8cfa1a6', crd_version: 'v1' }
46-
- {version: '1.22', kind: "v0.11.1", image: 'kindest/node:v1.22.0@sha256:b8bda84bb3a190e6e028b1760d277454a72267a5454b57db34437c34a588d047', crd_version: 'v1' }
47-
- {version: '1.23', kind: "v0.11.1", image: 'kindest/node:v1.23.0@sha256:49824ab1727c04e56a21a5d8372a402fcd32ea51ac96a2706a12af38934f81ac', crd_version: 'v1' }
48-
name: k8s ${{ matrix.configuration.version }}
55+
matrix: ${{fromJson(needs.setmatrix.outputs.matrix)}}
56+
name: e2e test k8s ${{ matrix.configuration.version }}
4957
steps:
50-
- name: checkout
58+
- name: Checkout
5159
uses: actions/checkout@v3
5260
with:
5361
fetch-depth: '5'
54-
- name: build local Image
62+
63+
- name: Build local image
5564
run: docker build -t metacontrollerio/metacontroller:dev .
56-
- name: setup kind
65+
66+
- name: Setup kind
5767
uses: helm/[email protected]
5868
with:
5969
version: ${{ matrix.configuration.kind }}
6070
node_image: ${{ matrix.configuration.image }}
6171
cluster_name: kind
6272
wait: 120s
73+
6374
- name: Load metacontroller image
6475
run: |
6576
kind load docker-image metacontrollerio/metacontroller:dev
66-
- name: Replace CRD mnifests to v1beta1
77+
78+
- name: Replace CRD manifests to v1beta1
6779
if: ${{ matrix.configuration.crd_version == 'v1beta1' }}
6880
run: |
6981
sed -i 's/crds-v1/crds-v1beta1/' manifests/production/kustomization.yaml
7082
for file in examples/**/*.yaml; do sed -i 's/apiextensions.k8s.io\/v1/apiextensions.k8s.io\/v1beta1/g' $file; done
83+
7184
- name: Apply metacontroller manifests
7285
run: |
7386
kubectl apply -k manifests/dev
7487
sleep 60s
7588
kubectl get pods -n metacontroller
89+
7690
- name: Run e2e tests
7791
timeout-minutes: 30
7892
run: |
7993
cd examples
8094
./test.sh --crd_version ${{ matrix.configuration.crd_version }}
95+
96+
helmtests:
97+
runs-on: ubuntu-20.04
98+
needs: ['setmatrix']
99+
strategy:
100+
fail-fast: false
101+
matrix: ${{fromJson(needs.setmatrix.outputs.v1_matrix)}}
102+
name: helm test k8s ${{ matrix.configuration.version }}
103+
steps:
104+
- name: Checkout
105+
uses: actions/checkout@v3
106+
with:
107+
fetch-depth: 0
108+
109+
- name: Set up Helm
110+
uses: azure/setup-helm@v1
111+
with:
112+
version: v3.8.1
113+
114+
- uses: actions/setup-python@v2
115+
with:
116+
python-version: 3.7
117+
118+
- name: Set up chart-testing
119+
uses: helm/[email protected]
120+
121+
- name: Setup kind
122+
uses: helm/[email protected]
123+
with:
124+
version: ${{ matrix.configuration.kind }}
125+
node_image: ${{ matrix.configuration.image }}
126+
cluster_name: kind
127+
wait: 120s
128+
129+
- name: Run chart-testing (lint)
130+
run: |
131+
ct lint --chart-dirs deploy/helm \
132+
--chart-yaml-schema '.github/config/chart-testing/etc/chart_schema.yaml' \
133+
--lint-conf '.github/config/chart-testing/etc/lintconf.yaml' \
134+
--validate-maintainers=false \
135+
--check-version-increment=false \
136+
--target-branch ${{ github.event.repository.default_branch }}
137+
138+
- name: Run chart-testing (install)
139+
run: |
140+
ct install --chart-dirs deploy/helm \
141+
--target-branch ${{ github.event.repository.default_branch }}
142+
81143
release:
82144
if: (github.ref == 'refs/heads/master') && (github.repository_owner == 'metacontroller')
83145
name: Release - Create tag
84146
runs-on: ubuntu-20.04
85-
needs: ['tests', 'e2etests']
147+
needs: ['tests', 'e2etests', 'helmtests']
86148
steps:
87149
- name: Checkout
88150
uses: actions/checkout@v1
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../values.yaml
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
rbac:
2+
create: true
3+
4+
image:
5+
repository: metacontrollerio/metacontroller
6+
pullPolicy: IfNotPresent
7+
tag: ""
8+
9+
imagePullSecrets: []
10+
nameOverride: ""
11+
namespaceOverride: ""
12+
fullnameOverride: ""
13+
14+
serviceAccount:
15+
create: true
16+
annotations: {}
17+
# The name of the service account to use.
18+
# If not set and create is true, a name is generated using the fullname template
19+
name: ""
20+
21+
podAnnotations: {}
22+
23+
podSecurityContext: {}
24+
# fsGroup: 2000
25+
26+
securityContext: {}
27+
# capabilities:
28+
# drop:
29+
# - ALL
30+
# readOnlyRootFilesystem: true
31+
# runAsNonRoot: true
32+
# runAsUser: 1000
33+
34+
resources: {}
35+
# limits:
36+
# cpu: 100m
37+
# memory: 128Mi
38+
# requests:
39+
# cpu: 100m
40+
# memory: 128Mi
41+
42+
nodeSelector: {}
43+
44+
tolerations: []
45+
46+
affinity: {}
47+
48+
zap: {}
49+
# logLevel: 4
50+
# devel: "production"
51+
# encoder: "json"
52+
# stacktraceLevel: "info"
53+
54+
# Custom arguments which are used to start metacontroller
55+
commandArgs: []
56+
# - --client-go-qps=100
57+
# - --client-go-burst=200
58+
59+
# How often to refresh discovery cache to pick up newly-installed resources
60+
discoveryInterval: 20s
61+
62+
# How often to flush local caches and relist objects from the API server
63+
cacheFlushInterval: 30m
64+
65+
# The name of the PriorityClass that will be assigned to metacontroller
66+
priorityClassName: ""
67+
68+
clusterRole:
69+
aggregationRule:
70+
clusterRoleSelectors:
71+
- matchLabels:
72+
rbac.authorization.k8s.io/aggregate-to-admin: "true"
73+
- matchLabels:
74+
rbac.authorization.k8s.io/aggregate-to-edit: "true"
75+
- matchLabels:
76+
rbac.authorization.k8s.io/aggregate-to-view: "true"
77+
rules: []

0 commit comments

Comments
 (0)