Skip to content

Commit

Permalink
add visual regression tracker (#112)
Browse files Browse the repository at this point in the history
* add visual regression tracker

Signed-off-by: André Bauer <[email protected]>

* fix yaml lint

Signed-off-by: André Bauer <[email protected]>

* fix more yaml lint

Signed-off-by: André Bauer <[email protected]>

* use fixed postgres name

Signed-off-by: André Bauer <[email protected]>

* remove tests

Signed-off-by: André Bauer <[email protected]>
  • Loading branch information
monotek authored Jul 12, 2022
1 parent 2219919 commit 03136ca
Show file tree
Hide file tree
Showing 13 changed files with 816 additions and 8 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- 'charts/**/**'

env:
helm-version: "v3.8.2"
helm-version: "v3.9.0"
kubeval-version: "v0.16.1"

jobs:
Expand All @@ -18,14 +18,14 @@ jobs:
with:
fetch-depth: 0
- name: Set up Helm
uses: azure/setup-helm@v2.0
uses: azure/setup-helm@v3.1
with:
version: "${{ env.helm-version }}"
- uses: actions/setup-python@v2
- uses: actions/setup-python@v4.1.0
with:
python-version: 3.7
- name: Set up chart-testing
uses: helm/chart-testing-action@v2.1.0
uses: helm/chart-testing-action@v2.2.1
- name: Run chart-testing (lint)
run: ct lint --config .github/ct.yaml

Expand Down Expand Up @@ -62,7 +62,7 @@ jobs:
with:
fetch-depth: 0
- name: Set up Helm
uses: azure/setup-helm@v2.0
uses: azure/setup-helm@v3.1
with:
version: "${{ env.helm-version }}"
- name: Run kubeval
Expand All @@ -88,10 +88,10 @@ jobs:
with:
fetch-depth: 0
- name: Set up Helm
uses: azure/setup-helm@v2.0
uses: azure/setup-helm@v3.1
with:
version: "${{ env.helm-version }}"
- uses: actions/setup-python@v2
- uses: actions/setup-python@v4.1.0
with:
python-version: 3.7
- name: Set up chart-testing
Expand All @@ -104,7 +104,7 @@ jobs:
echo "::set-output name=changed::true"
fi
- name: Create kind cluster
uses: helm/kind-action@v1.2.0
uses: helm/kind-action@v1.3.0
if: steps.list-changed.outputs.changed == 'true'
with:
config: .github/kind-config.yaml
Expand Down
23 changes: 23 additions & 0 deletions charts/visual-regression-tracker/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
21 changes: 21 additions & 0 deletions charts/visual-regression-tracker/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: v2
name: visual-regression-tracker
description: A Helm chart for Visual Regression Tracker
home: https://visual-regression-tracker.com
sources:
- https://github.com/Visual-Regression-Tracker/Visual-Regression-Tracker
type: application
version: 0.1.0
appVersion: "4.20.4"
maintainers:
- name: monotek
email: [email protected]
dependencies:
- name: elasticsearch
version: "7.17.3"
repository: https://helm.elastic.co
condition: vrtConfig.elasticsearch.enabled
- name: postgresql
version: "11.6.15"
repository: https://charts.bitnami.com/bitnami
condition: vrtConfig.postgresql.enabled
45 changes: 45 additions & 0 deletions charts/visual-regression-tracker/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
Get the API application URL by running these commands:
{{- if .Values.ui.ingress.enabled }}
{{- range $host := .Values.api.ingress.hosts }}
{{- range .paths }}
http{{ if $.Values.api.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
{{- end }}
{{- end }}
{{- else if contains "NodePort" .Values.api.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "visual-regression-tracker.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.api.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "visual-regression-tracker.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "visual-regression-tracker.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ .Values.api.service.port }}
{{- else if contains "ClusterIP" .Values.api.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "visual-regression-tracker.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 3000:$CONTAINER_PORT
{{- end }}

Get the UI application URL by running these commands:
{{- if .Values.ui.ingress.enabled }}
{{- range $host := .Values.ui.ingress.hosts }}
{{- range .paths }}
http{{ if $.Values.ui.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
{{- end }}
{{- end }}
{{- else if contains "NodePort" .Values.ui.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "visual-regression-tracker.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.ui.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "visual-regression-tracker.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "visual-regression-tracker.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ .Values.ui.service.port }}
{{- else if contains "ClusterIP" .Values.ui.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "visual-regression-tracker.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[1].ports[0].containerPort}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
{{- end }}
95 changes: 95 additions & 0 deletions charts/visual-regression-tracker/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "visual-regression-tracker.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "visual-regression-tracker.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "visual-regression-tracker.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "visual-regression-tracker.labels" -}}
helm.sh/chart: {{ include "visual-regression-tracker.chart" . }}
{{ include "visual-regression-tracker.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "visual-regression-tracker.selectorLabels" -}}
app.kubernetes.io/name: {{ include "visual-regression-tracker.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "visual-regression-tracker.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "visual-regression-tracker.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

{{/*
elasticsearch secret name
*/}}
{{- define "visual-regression-tracker.elasticsearchSecretName" -}}
{{- if .Values.secrets.elasticsearch.useExisting -}}
{{ .Values.secrets.elasticsearch.secretName }}
{{- else -}}
{{ template "visual-regression-tracker.fullname" . }}-{{ .Values.secrets.elasticsearch.secretName }}
{{- end -}}
{{- end -}}

{{/*
jwt secret name
*/}}
{{- define "visual-regression-tracker.jwtSecretName" -}}
{{- if .Values.secrets.jwt.useExisting -}}
{{ .Values.secrets.jwt.secretName }}
{{- else -}}
{{ template "visual-regression-tracker.fullname" . }}-{{ .Values.secrets.jwt.secretName }}
{{- end -}}
{{- end -}}

{{/*
postgresql secret name
*/}}
{{- define "visual-regression-tracker.postgresqlSecretName" -}}
{{- if .Values.secrets.postgresql.useExisting -}}
{{ .Values.secrets.postgresql.secretName }}
{{- else -}}
{{ template "visual-regression-tracker.fullname" . }}-{{ .Values.secrets.postgresql.secretName }}
{{- end -}}
{{- end -}}
61 changes: 61 additions & 0 deletions charts/visual-regression-tracker/templates/ingress-api.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{{- if .Values.api.ingress.enabled -}}
{{- $fullName := include "visual-regression-tracker.fullname" . -}}
{{- $svcPort := .Values.api.service.port -}}
{{- if and .Values.api.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
{{- if not (hasKey .Values.api.ingress.annotations "kubernetes.io/ingress.class") }}
{{- $_ := set .Values.api.ingress.annotations "kubernetes.io/ingress.class" .Values.api.ingress.className}}
{{- end }}
{{- end }}
{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1
{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1beta1
{{- else -}}
apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress
metadata:
name: {{ $fullName }}
labels:
{{- include "visual-regression-tracker.labels" . | nindent 4 }}
{{- with .Values.api.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if and .Values.api.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
ingressClassName: {{ .Values.api.ingress.className }}
{{- end }}
{{- if .Values.api.ingress.tls }}
tls:
{{- range .Values.api.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
{{- range .Values.api.ingress.hosts }}
- host: {{ .host | quote }}
http:
paths:
{{- range .paths }}
- path: {{ .path }}
{{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }}
pathType: {{ .pathType }}
{{- end }}
backend:
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
service:
name: {{ $fullName }}
port:
number: {{ $svcPort }}
{{- else }}
serviceName: {{ $fullName }}
servicePort: {{ $svcPort }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
61 changes: 61 additions & 0 deletions charts/visual-regression-tracker/templates/ingress-ui.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{{- if .Values.ui.ingress.enabled -}}
{{- $fullName := include "visual-regression-tracker.fullname" . -}}
{{- $svcPort := .Values.ui.service.port -}}
{{- if and .Values.ui.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
{{- if not (hasKey .Values.ui.ingress.annotations "kubernetes.io/ingress.class") }}
{{- $_ := set .Values.ui.ingress.annotations "kubernetes.io/ingress.class" .Values.ui.ingress.className}}
{{- end }}
{{- end }}
{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1
{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1beta1
{{- else -}}
apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress
metadata:
name: {{ $fullName }}
labels:
{{- include "visual-regression-tracker.labels" . | nindent 4 }}
{{- with .Values.ui.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if and .Values.ui.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
ingressClassName: {{ .Values.ui.ingress.className }}
{{- end }}
{{- if .Values.ui.ingress.tls }}
tls:
{{- range .Values.ui.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
{{- range .Values.ui.ingress.hosts }}
- host: {{ .host | quote }}
http:
paths:
{{- range .paths }}
- path: {{ .path }}
{{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }}
pathType: {{ .pathType }}
{{- end }}
backend:
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
service:
name: {{ $fullName }}
port:
number: {{ $svcPort }}
{{- else }}
serviceName: {{ $fullName }}
servicePort: {{ $svcPort }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
Loading

0 comments on commit 03136ca

Please sign in to comment.