Skip to content

wip: workflow to test helm deploy #55

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/workflows/test-helm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Test Helm Chart

on:
push:
paths:
- 'helm/**'
pull_request:
paths:
- 'helm/**'

jobs:
test-helm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Kubernetes tools
uses: azure/setup-kubectl@v3

- name: Set up Helm
uses: azure/setup-helm@v3
with:
version: 'v3.13.2'

- name: Create kind cluster
uses: helm/[email protected]

- name: Run Helm tests
run: |
# Install chart with test values
helm upgrade --install stac-auth-proxy ./helm \
--values ./helm/test-values.yaml \
--wait \
--timeout 2m

# Run helm tests
helm test stac-auth-proxy --timeout 2m
27 changes: 27 additions & 0 deletions helm/templates/tests/test-auth.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
apiVersion: v1
kind: Pod
metadata:
name: "{{ include "stac-auth-proxy.fullname" . }}-test-auth"
labels:
{{- include "stac-auth-proxy.labels" . | nindent 4 }}
annotations:
"helm.sh/hook": test
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
spec:
containers:
- name: curl
image: curlimages/curl
command:
- /bin/sh
- -c
- |
# Make request and check for 401
response=$(curl -o /dev/null -s -w "%{http_code}" http://{{ include "stac-auth-proxy.fullname" . }}:{{ .Values.service.port }}/)
if [ "$response" = "401" ]; then
echo "Successfully got 401 Unauthorized as expected"
exit 0
else
echo "Expected 401 but got $response"
exit 1
fi
restartPolicy: Never
15 changes: 15 additions & 0 deletions helm/templates/tests/test-connection.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Pod
metadata:
name: "{{ include "stac-auth-proxy.fullname" . }}-test-connection"
labels:
{{- include "stac-auth-proxy.labels" . | nindent 4 }}
annotations:
"helm.sh/hook": test
spec:
containers:
- name: wget
image: busybox
command: ['wget']
args: ['{{ include "stac-auth-proxy.fullname" . }}:{{ .Values.service.port }}/healthz']
restartPolicy: Never
35 changes: 35 additions & 0 deletions helm/templates/tests/test-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
apiVersion: v1
kind: Pod
metadata:
name: "{{ include "stac-auth-proxy.fullname" . }}-test-service"
labels:
{{- include "stac-auth-proxy.labels" . | nindent 4 }}
annotations:
"helm.sh/hook": test
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
spec:
containers:
- name: test
image: busybox
command:
- sh
- -c
- |
# Test service type is set to a valid value
service_type="{{ .Values.service.type }}"
valid_types="ClusterIP NodePort LoadBalancer"

if ! echo "$valid_types" | grep -w "$service_type" > /dev/null; then
echo "Invalid service type: $service_type"
exit 1
fi

# Test service port is set and is a valid port number
port="{{ .Values.service.port }}"
if [ -z "$port" ] || [ "$port" -lt 1 ] || [ "$port" -gt 65535 ]; then
echo "Invalid service port: $port"
exit 1
fi

echo "Service configuration is valid"
restartPolicy: Never
Loading