Skip to content

Commit

Permalink
lint it (#97)
Browse files Browse the repository at this point in the history
* lint it
  • Loading branch information
MichaelSp authored Sep 23, 2023
1 parent 9aea4cf commit 354efe0
Show file tree
Hide file tree
Showing 6 changed files with 155 additions and 33 deletions.
61 changes: 51 additions & 10 deletions .github/workflows/pr-checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,58 @@ on:
branches: [ "master" ]

jobs:

build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: 18
cache: 'npm'
- run: npm ci
- run: npm run lint
- run: npm run build:ts
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: 18
cache: "npm"
- run: npm ci
- run: npm run lint
- run: npm run build:ts

helm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Helm
uses: azure/setup-helm@v3
with:
version: v3.12.1

- uses: actions/setup-python@v4
with:
python-version: '3.9'
check-latest: true
- uses: helm/[email protected]

- name: Run chart-testing (list-changed)
id: list-changed
run: |
changed=$(ct list-changed --target-branch ${{ github.event.repository.default_branch }})
if [[ -n "$changed" ]]; then
echo "changed=true" >> "$GITHUB_OUTPUT"
fi
- name: install helm dependencies
if: steps.list-changed.outputs.changed == 'true'
run: |
helm dependency update charts/*
helm repo add bitnami https://charts.bitnami.com/bitnami
helm plugin install https://github.com/helm-unittest/helm-unittest.git
- name: Run chart-testing (lint)
if: steps.list-changed.outputs.changed == 'true'
run: ct lint --target-branch ${{ github.event.repository.default_branch }}

# run helm unittest
- name: Run helm lint
if: steps.list-changed.outputs.changed == 'true'
run: helm lint charts/*
- name: Run helm unittest
if: steps.list-changed.outputs.changed == 'true'
run: helm unittest charts/*
4 changes: 3 additions & 1 deletion charts/timelimit/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
apiVersion: v2
name: timelimit
description: A Helm chart for timelimit server
maintainers:
- name: Michael

# A chart can be either an 'application' or a 'library' chart.
#
Expand All @@ -15,7 +17,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.2.4
version: 0.2.5

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
45 changes: 25 additions & 20 deletions charts/timelimit/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,34 @@ kind: Deployment
metadata:
name: {{ include "timelimit.fullname" . }}
labels:
{{- include "timelimit.labels" . | nindent 4 }}
{{- include "timelimit.labels" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "timelimit.selectorLabels" . | nindent 6 }}
{{- include "timelimit.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "timelimit.selectorLabels" . | nindent 8 }}
{{- include "timelimit.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "timelimit.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
Expand All @@ -45,10 +45,14 @@ spec:
- name: DB_HOST
value: "{{ include "timelimit.fullname" . }}-mariadb"
- name: DB_PASS
{{- if and .Values.mariadb.auth .Values.mariadb.auth.existingSecret }}
valueFrom:
secretKeyRef:
name: {{ .Values.mariadb.auth.existingSecret }}
name: {{ .Values.mariadb.auth.existingSecret | quote }}
key: mariadb-password
{{- else }}
value: {{ .Values.mariadb.auth.password | quote }}
{{- end }}
- name: PORT
value: "8080"
{{- if .Values.mail.enabled }}
Expand All @@ -57,18 +61,19 @@ spec:
- name: MAIL_TRANSPORT
value: |
{"host": "{{ .Values.mail.host }}", "port": {{ .Values.mail.port }}, "tls": {"host": "{{ .Values.mail.tls }}"} }
{{- end }}
- name: ALWAYS_PRO
value: {{ default "no" .Values.timelimit.alwaysPro }}
value: {{ default .Values.timelimit.alwaysPro "no" | quote }}
- name: ADMIN_TOKEN
{{- if .Values.timelimit.adminToken.existingSecret -}}
{{- if .Values.timelimit.adminToken.existingSecret }}
valueFrom:
secretKeyRef:
name: {{ .Values.timelimit.adminToken.existingSecret.secretName }}
key: {{ .Values.timelimit.adminToken.existingSecret.secretKey }}
{{- else -}}
value: "{{.Values.timelimit.adminToken.literalValue }}"
{{- end -}}
name: {{ .Values.timelimit.adminToken.existingSecret.secretName | quote }}
key: {{ .Values.timelimit.adminToken.existingSecret.secretKey | quote }}
{{- else }}
value: {{.Values.timelimit.adminToken.literalValue | quote }}
{{- end }}
ports:
- name: http
containerPort: {{ .Values.service.port }}
Expand All @@ -82,16 +87,16 @@ spec:
path: /time
port: 8080
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- toYaml . | nindent 8 }}
{{- end }}
66 changes: 66 additions & 0 deletions charts/timelimit/tests/__snapshot__/simple_test.yaml.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
Matches the snapshot:
1: |
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: timelimit
app.kubernetes.io/version: 1.17.0
helm.sh/chart: timelimit-0.2.5
name: RELEASE-NAME-timelimit
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/name: timelimit
template:
metadata:
labels:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/name: timelimit
spec:
containers:
- env:
- name: NODE_ENV
value: production
- name: DB_NAME
value: RELEASE-NAME-timelimit
- name: DB_USER
value: RELEASE-NAME-timelimit
- name: DB_PORT
value: "3306"
- name: DB_HOST
value: RELEASE-NAME-timelimit-mariadb
- name: DB_PASS
value: ""
- name: PORT
value: "8080"
- name: ALWAYS_PRO
value: "no"
- name: ADMIN_TOKEN
valueFrom:
secretKeyRef:
key: the-key
name: the-secret-name
image: ghcr.io/michaelsp/timelimit-server/timelimit:latest
imagePullPolicy: IfNotPresent
livenessProbe:
httpGet:
path: /time
port: 8080
name: timelimit
ports:
- containerPort: 8080
name: http
protocol: TCP
readinessProbe:
httpGet:
path: /time
port: 8080
resources: {}
securityContext: {}
securityContext: {}
serviceAccountName: RELEASE-NAME-timelimit
7 changes: 7 additions & 0 deletions charts/timelimit/tests/simple_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
suite: email Test Suite
templates:
- deployment.yaml
tests:
- it: Matches the snapshot
asserts:
- matchSnapshot: {}
5 changes: 3 additions & 2 deletions charts/timelimit/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ service:
ingress:
enabled: false
# className: ""
# annotations:
# annotations:
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
# hosts:
Expand All @@ -71,7 +71,7 @@ ingress:
# - secretName: ingress-cert
# hosts:
# - timelimit.example.com

resources: {}
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
Expand Down Expand Up @@ -100,4 +100,5 @@ affinity: {}
mariadb:
enabled: false
auth:
password: ""
# details see https://github.com/bitnami/charts/tree/main/bitnami/mariadb

0 comments on commit 354efe0

Please sign in to comment.