Skip to content

Commit e4d1be4

Browse files
committed
add e2e test
Signed-off-by: cpanato <[email protected]>
1 parent 7e5f555 commit e4d1be4

File tree

6 files changed

+127
-2
lines changed

6 files changed

+127
-2
lines changed

.github/workflows/test-action.yml

+46-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99

1010
name: Install chart-testing and test presence in path
1111
steps:
12-
- uses: actions/checkout@v4
12+
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
1313
- name: Install chart-testing
1414
uses: ./
1515
- name: Check install!
@@ -38,7 +38,7 @@ jobs:
3838

3939
name: Install Custom chart-testing and test presence in path
4040
steps:
41-
- uses: actions/checkout@v4
41+
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
4242
- name: Install chart-testing
4343
uses: ./
4444
with:
@@ -65,3 +65,47 @@ jobs:
6565
else
6666
exit 0
6767
fi
68+
69+
test_ct_action_with_helm:
70+
runs-on: ubuntu-latest
71+
72+
name: rin action to test a helm chart
73+
steps:
74+
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
75+
76+
- name: Set up Helm
77+
uses: azure/setup-helm@v3
78+
with:
79+
version: v3.14.4
80+
81+
- uses: actions/setup-python@v4
82+
with:
83+
python-version: '3.x'
84+
check-latest: true
85+
86+
- name: Install chart-testing
87+
uses: ./
88+
89+
- run: |
90+
sed -i "s/version: .*/version: 2.0.0/" testdata/simple-deployment/Chart.yaml
91+
cat testdata/simple-deployment/Chart.yaml
92+
93+
- name: Run chart-testing (list-changed)
94+
id: list-changed
95+
run: |
96+
changed=$(ct list-changed --chart-dirs=./testdata --target-branch ${{ github.event.repository.default_branch }})
97+
if [[ -n "$changed" ]]; then
98+
echo "changed=true" >> "$GITHUB_OUTPUT"
99+
fi
100+
101+
- name: Run chart-testing (lint)
102+
if: steps.list-changed.outputs.changed == 'true'
103+
run: ct lint --chart-dirs=./testdata --target-branch ${{ github.event.repository.default_branch }}
104+
105+
- name: Create kind cluster
106+
if: steps.list-changed.outputs.changed == 'true'
107+
uses: helm/[email protected]
108+
109+
- name: Run chart-testing (install)
110+
if: steps.list-changed.outputs.changed == 'true'
111+
run: ct install --chart-dirs=./testdata --target-branch ${{ github.event.repository.default_branch }}

testdata/simple-deployment/Chart.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
apiVersion: v1
2+
appVersion: "1.0"
3+
description: A Helm chart for Kubernetes
4+
name: nginx
5+
version: 0.1.0

testdata/simple-deployment/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Simple chart with a Deployment.
2+
3+
The integration test will install first simple-deployment and then try to upgrade
4+
to simple-deployment-different-selector failing as expected
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{{/* vim: set filetype=mustache: */}}
2+
{{/*
3+
Expand the name of the chart.
4+
*/}}
5+
{{- define "nginx.name" -}}
6+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
7+
{{- end -}}
8+
9+
{{/*
10+
Create a default fully qualified app name.
11+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
12+
If release name contains chart name it will be used as a full name.
13+
*/}}
14+
{{- define "nginx.fullname" -}}
15+
{{- if .Values.fullnameOverride -}}
16+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
17+
{{- else -}}
18+
{{- $name := default .Chart.Name .Values.nameOverride -}}
19+
{{- if contains $name .Release.Name -}}
20+
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
21+
{{- else -}}
22+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
23+
{{- end -}}
24+
{{- end -}}
25+
{{- end -}}
26+
27+
{{/*
28+
Create chart name and version as used by the chart label.
29+
*/}}
30+
{{- define "nginx.chart" -}}
31+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
32+
{{- end -}}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ include "nginx.fullname" . }}
5+
labels:
6+
app.kubernetes.io/name: {{ include "nginx.name" . }}
7+
helm.sh/chart: {{ include "nginx.chart" . }}
8+
app.kubernetes.io/instance: {{ .Release.Name }}
9+
app.kubernetes.io/managed-by: {{ .Release.Service }}
10+
spec:
11+
replicas: 1
12+
selector:
13+
matchLabels:
14+
app.kubernetes.io/name: {{ include "nginx.name" . }}
15+
app.kubernetes.io/instance: {{ .Release.Name }}
16+
template:
17+
metadata:
18+
labels:
19+
app.kubernetes.io/name: {{ include "nginx.name" . }}
20+
app.kubernetes.io/instance: {{ .Release.Name }}
21+
spec:
22+
containers:
23+
- name: {{ .Chart.Name }}
24+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
25+
imagePullPolicy: {{ .Values.image.pullPolicy }}
26+
ports:
27+
- name: http
28+
containerPort: 80
29+
protocol: TCP
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Default values for nginx.
2+
# This is a YAML-formatted file.
3+
# Declare variables to be passed into your templates.
4+
5+
image:
6+
repository: nginx
7+
tag: stable
8+
pullPolicy: IfNotPresent
9+
10+
nameOverride: ""
11+
fullnameOverride: ""

0 commit comments

Comments
 (0)