Skip to content
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

feat: (CCIE-3082) add unit testing to GHA #64

Merged
merged 9 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from 6 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
13 changes: 13 additions & 0 deletions .github/workflows/unittest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Unit testing

on: pull_request

jobs:
unittest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: d3adb5/helm-unittest-action@v2
with:
helm-version: v3.8.0
github-token: ${{ secrets.GITHUB_TOKEN }}
2 changes: 2 additions & 0 deletions stack/.helmignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@
.idea/
*.tmproj
.vscode/
# testing
tests
24 changes: 24 additions & 0 deletions stack/tests/deployment_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
suite: test deployment
templates:
- deployment.yaml
tests:
- it: should work
values:
- values.yaml
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use set instead of values for this test so we can just get a minimal test running

asserts:
- isKind:
of: Deployment
- isSubset:
path: spec
content:
revisionHistoryLimit: 3
any: true
- containsDocument:
apiVersion: apps/v1
kind: Deployment

# path: metadata.name
# pattern: -my-chart$
# - equal:
# path: spec.template.spec.containers[0].image
# value: nginx:latest
219 changes: 219 additions & 0 deletions stack/tests/values.yaml
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be removed now, right?

Original file line number Diff line number Diff line change
@@ -0,0 +1,219 @@
# Service defaults
global:
deploymentStage: ""
replicaCount: 1

# Settings for the primary container
image:
repository: nginx
pullPolicy: IfNotPresent
tag: "latest"

args: []
command: []

imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""

dnsPolicy: ClusterFirst
restartPolicy: Always

# Probes for the primary container
livenessProbe:
failureThreshold: 3
httpGet:
path: /
port: http
scheme: HTTP
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 1
initialDelaySeconds: 30
readinessProbe:
failureThreshold: 3
httpGet:
path: /
port: http
scheme: HTTP
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 1
initialDelaySeconds: 30
startupProbe:
enabled: false
failureThreshold: 3
successThreshold: 1
initialDelaySeconds: 0
timeoutSeconds: 1
periodSeconds: 10
exec:
command:
- ps
- "-ef"

progressDeadlineSeconds: 600

resources:
limits:
cpu: "1"
memory: "1Gi"
requests:
cpu: "100m"
memory: "128Mi"

service:
type: ClusterIP
port: 80

initContainers: []
sidecars: []

appContext:
envContextConfigMapName: "" # App environment level configuration configmap name
stackContextConfigMapName: "" # Stack level configuration configmap name

appSecrets:
envSecret: # App environment level configuration secret
secretName: ""
secretKey: ""
stackSecret: # Stack level configuration secret
secretName: ""
secretKey: ""

# Global annotations to add to all resources
annotations: {}
# Labels to add to pods
podLabels: {}

serviceAccount:
# Specifies whether a service account should be created
create: false
# Automatically mount a ServiceAccount's API credentials?
automount: true
# Annotations to add to the service account
annotations: {}
# The name of the service account to use.
# If not set and create is true, a name is generated using the fullname template
name: ""

podSecurityContext:
{}
# fsGroup: 2000

securityContext:
{}
# capabilities:
# drop:
# - ALL
# readOnlyRootFilesystem: true
# runAsNonRoot: true
# runAsUser: 1000

ingress:
enabled: true
className: nginx
host: chart-example.local
paths:
- path: /
pathType: Prefix
rules: []
annotations:
infra: "true"
external-dns.alpha.kubernetes.io/exclude: "true"
cert-manager.io/cluster-issue: nginx-issuer
nginx.ingress.kubernetes.io/proxy-connect-timeout: "60"
nginx.ingress.kubernetes.io/proxy-send-timeout: "60"
nginx.ingress.kubernetes.io/proxy-read-timeout: "60"
nginx.ingress.kubernetes.io/affinity: "cookie"
nginx.ingress.kubernetes.io/session-cookie-name: "argus_sticky_session"
nginx.ingress.kubernetes.io/session-cookie-max-age: "600"
tls: []
# - secretName: chart-example-tls
# hosts:
# - chart-example.local
nodeSelector:
kubernetes.io/arch: arm64

# Annotations to add to pods
podAnnotations:
linkerd.io/inject: enabled
config.linkerd.io/skip-outbound-ports: 3306,5432,6379,9300,11211,4444,4567,4568,587,25,2525,465,2465

autoscaling:
enabled: true
minReplicas: 1
maxReplicas: 10
targetCPUUtilizationPercentage: 80
targetMemoryUtilizationPercentage: 80

# Additional volumes on the output Deployment definition.
volumes: []
# - name: foo
# secret:
# secretName: mysecret
# optional: false

# Additional volumeMounts on the output Deployment definition.
volumeMounts: []
# - name: foo
# mountPath: "/etc/foo"
# readOnly: true

tolerations: []

affinity: {}

topologySpreadConstraints: []

env: []
envFrom: []

# Service overrides
services:
# {}
service1:
args: ["arg1", "arg2"]
command: ["command1", "command2"]
autoscaling:
enabled: true
minReplicas: 2
maxReplicas: 10
maxUnavailable: 1
replicaCount: 2
sidecars:
- name: sidecar1
image: "sidecar1:latest"
- name: sidecar2
image: "sidecar2:latest"
initContainers:
- name: initContainer1
image: "alpine:latest"
command: ["echo", "Hello World"]
# service2:
# startupProbe:
# enabled: true
# autoscaling:
# enabled: true
# minReplicas: 2
# maxReplicas: 10
# maxUnavailable: 1
# replicaCount: 2
# sidecars:
# - name: sidecar3
# image: sidecar3:latest
# - name: sidecar4
# image: sidecar4:latest

cronJobs:
{}
# cronJob1:
# concurrencyPolicy: Forbid
# schedule: "* * * * *"
# image:
# repository: nginx
# pullPolicy: IfNotPresent
# tag: "latest"
# command: ["command1", "command2"]
# args: ["arg1", "arg2"]
# bump5
Loading