Skip to content

Commit 0e8c311

Browse files
committed
add e2e test
Signed-off-by: cpanato <ctadeu@gmail.com>
1 parent 7e5f555 commit 0e8c311

File tree

6 files changed

+129
-2
lines changed

6 files changed

+129
-2
lines changed

.github/workflows/test-action.yml

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

testdata/simple-deployment/Chart.yaml

Lines changed: 5 additions & 0 deletions
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

Lines changed: 4 additions & 0 deletions
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
Lines changed: 32 additions & 0 deletions
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 -}}
Lines changed: 29 additions & 0 deletions
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
Lines changed: 11 additions & 0 deletions
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)