Skip to content

Commit

Permalink
ci: add chart-testing workflow
Browse files Browse the repository at this point in the history
Signed-off-by: GridexX <arsene582@gmail.com>
  • Loading branch information
GridexX committed Jul 31, 2023
1 parent 5a77c46 commit 71176a2
Show file tree
Hide file tree
Showing 11 changed files with 132 additions and 65 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/chart-testing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Lint and Test Charts

on:
push:
paths:
- '.github/**'
- 'charts/**'
- '!**.md'

env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
CT_MYSQL_ARGS: '--helm-extra-set-args "--set mysql.enabled=true --set mariadb.enabled=false --set postgresql.enabled=false"'
CT_MARIADB_ARGS: '--helm-extra-set-args "--set mysql.enabled=false --set mariadb.enabled=true --set postgresql.enabled=false"'
CT_POSTGRES_ARGS: '--helm-extra-set-args "--set mysql.enabled=false --set mariadb.enabled=false --set postgresql.enabled=true"'

jobs:
lint-test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up Helm
uses: azure/setup-helm@v3

- name: Add repos
run: |
helm repo add bitnami https://charts.bitnami.com/bitnami
- name: Set up Python
uses: actions/setup-python@v4.7.0
with:
python-version: 3.7

- name: Set up chart-testing
uses: helm/chart-testing-action@v2.3.1

- 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: Run chart-testing (lint)
run: ct lint --validate-maintainers=false --target-branch ${{ github.event.repository.default_branch }}

- name: Create kind cluster
# if: steps.list-changed.outputs.changed == 'true'
uses: helm/kind-action@v1.8.0

- name: Run chart-testing (install)
# if: steps.list-changed.outputs.changed == 'true'
run: ct install --validate-maintainers=false --target-branch ${{ github.event.repository.default_branch }}

# TODO Test with differents DBs


1 change: 0 additions & 1 deletion charts/xwiki/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,3 @@ dependencies:
repository: https://charts.bitnami.com/bitnami
version: 12.5.6
condition: postgresql.enabled

26 changes: 13 additions & 13 deletions charts/xwiki/templates/initialization-configmaps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ data:
entrypoint: |
#!/bin/bash
##
# *Experimental* solution for custom properties.
# With time we are looking other alternatives to setup this custom values.
# *Experimental* solution for custom properties.
# With time we are looking other alternatives to setup this custom values.
##
# Always execute "first_start" in order to get all new values keys from future versions.
# Always execute "first_start" in order to get all new values keys from future versions.
rm -f /usr/local/xwiki/data/xwiki.cfg
rm -f /usr/local/xwiki/data/xwiki.properties
rm -f /usr/local/xwiki/data/hibernate.cfg.xml
# Reuse commands/resources from default entrypoint.
# Reuse commands/resources from default entrypoint.
source /usr/local/bin/docker-entrypoint.sh
file_env 'CONTEXT_PATH' 'ROOT'
# Setup all default actions from first start
Expand All @@ -35,11 +35,11 @@ data:
# Replace all values from keys defineded on customConfigs
{{- range $file, $values := .Values.customConfigs }}
{{- range $key, $value := $values }}
# TODO review/manage extensions
# TODO review/manage extensions
if grep -wq "{{ $key }}" /usr/local/xwiki/data/{{ $file }}; then
echo "Key ({{ $key }}) exists on file ({{ $file }}), replacing that key line with new value."
xwiki_replace "/usr/local/xwiki/data/{{ $file }}" "{{ $key }}" "{{ $value }}" || true
else
else
echo "Key ({{ $key }}) don't exists on file ({{ $file }}), appending that key line with new value."
echo '{{ $key }} = {{ $value }}' >> "/usr/local/xwiki/data/{{ $file }}" || true
fi
Expand All @@ -51,16 +51,16 @@ data:
{{- end }}
{{- if .Values.glowroot.enabled }}
mkdir -p /usr/local/xwiki/data/glowroot
GLOWROOT_VERSION="0.14.0"
if ! [ -d "/usr/local/xwiki/data/glowroot/glowroot-${GLOWROOT_VERSION}" ]; then
wget -O /tmp/glowroot-${GLOWROOT_VERSION}-dist.zip https://github.com/glowroot/glowroot/releases/download/v${GLOWROOT_VERSION}/glowroot-${GLOWROOT_VERSION}-dist.zip
mkdir -p /usr/local/xwiki/data/glowroot
GLOWROOT_VERSION="0.14.0"
if ! [ -d "/usr/local/xwiki/data/glowroot/glowroot-${GLOWROOT_VERSION}" ]; then
wget -O /tmp/glowroot-${GLOWROOT_VERSION}-dist.zip https://github.com/glowroot/glowroot/releases/download/v${GLOWROOT_VERSION}/glowroot-${GLOWROOT_VERSION}-dist.zip
unzip /tmp/glowroot-${GLOWROOT_VERSION}-dist.zip -d /usr/local/xwiki/data/glowroot/
rm -f /tmp/glowroot-${GLOWROOT_VERSION}-dist.zip
rm -f /tmp/glowroot-${GLOWROOT_VERSION}-dist.zip
mv /usr/local/xwiki/data/glowroot/glowroot /usr/local/xwiki/data/glowroot/glowroot-${GLOWROOT_VERSION}
fi
fi
cp /configmaps/glowroot.properties /usr/local/xwiki/data/glowroot/glowroot-${GLOWROOT_VERSION}/glowroot.properties
# Append first to enable user override agent.
# Append first to enable user override agent.
export JAVA_OPTS=" -javaagent:/usr/local/xwiki/data/glowroot/glowroot-${GLOWROOT_VERSION}/glowroot.jar ${JAVA_OPTS}"
{{- end }}
Expand Down
2 changes: 1 addition & 1 deletion charts/xwiki/templates/istio-certificate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ metadata:
spec:
secretName: {{ template "xwiki.istio.credentialName" . }}
commonName: {{ .Values.istio.host | quote }}
{{- with .Values.istio.tls.certificate.issuerRef }}
{{- with .Values.istio.tls.certificate.issuerRef }}
issuerRef:
{{- toYaml . | nindent 4 }}
{{- end }}
Expand Down
2 changes: 1 addition & 1 deletion charts/xwiki/templates/istio.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ spec:
headers:
request:
set:
# Required for some extensions (Realtime Editor/Websocket)
# Required for some extensions (Realtime Editor/Websocket)
x-forwarded-host: {{ .Values.istio.host | quote }}
---
apiVersion: networking.istio.io/v1beta1
Expand Down
6 changes: 3 additions & 3 deletions charts/xwiki/templates/solr-statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{{- $fullName := include "solr.fullname" . -}}
apiVersion: {{ include "common.capabilities.statefulset.apiVersion" . }}
kind: StatefulSet
metadata:
metadata:
name: {{ $fullName }}
labels:
{{- include "solr.labels" . | nindent 4 }}
Expand All @@ -14,7 +14,7 @@ spec:
{{- include "solr.selectorLabels" . | nindent 6 }}
template:
metadata:
# annotations:
# annotations:
labels:
{{- include "solr.labels" . | nindent 8 }}
spec:
Expand All @@ -25,7 +25,7 @@ spec:
volumeMounts:
- name: xwiki-solr-data
mountPath: /tmp/cores
securityContext:
securityContext:
enabled: true
runAsGroup: 1001
runAsUser: 1001
Expand Down
4 changes: 2 additions & 2 deletions charts/xwiki/templates/xwiki.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ metadata:
name: {{ $fullName }}
labels:
{{- include "xwiki.labels" . | nindent 4 }}
spec:
spec:
replicas: {{ .Values.replicaCount }}
{{- if .Values.workloadStateful }}
serviceName: {{ $fullName }}
Expand All @@ -21,7 +21,7 @@ spec:
template:
metadata:
annotations:
# Annotations to rollout changes on configs on workload
# Annotations to rollout changes on configs on workload
checksum/configmap: {{ include (print $.Template.BasePath "/configmaps.yaml") . | sha256sum }}
checksum/initialization-configmaps: {{ include (print $.Template.BasePath "/initialization-configmaps.yaml") . | sha256sum }}
labels:
Expand Down
6 changes: 3 additions & 3 deletions charts/xwiki/tests/ingress_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ tests:
asserts:
- isKind:
of: Ingress
template: ingress.yaml
template: ingress.yaml
- matchSnapshot:
path: metadata.annotations
template: ingress.yaml
template: ingress.yaml
- equal:
path: metadata.name
value: release-xwiki
Expand All @@ -28,4 +28,4 @@ tests:
# pattern: xwiki-*
- matchSnapshot:
path: spec
template: ingress.yaml
template: ingress.yaml
6 changes: 3 additions & 3 deletions charts/xwiki/tests/service_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ tests:
asserts:
- isKind:
of: Service
# template: service.yaml
# template: service.yaml
- matchSnapshot:
path: spec
# template: service.yaml
# template: service.yaml
- it: should have same labels as Deployment
set:
service.type: ClusterIP
Expand All @@ -28,6 +28,6 @@ tests:
asserts:
- equal:
path: spec.selector
value:
value:
app.kubernetes.io/instance: release
app.kubernetes.io/name: xwiki
38 changes: 19 additions & 19 deletions charts/xwiki/tests/xwiki_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ suite: test deployment
templates:
- xwiki.yaml
- configmaps.yaml
- initialization-configmaps.yaml
- initialization-configmaps.yaml
tests:
- it: testing default values
documentIndex: 0
Expand All @@ -12,10 +12,10 @@ tests:
template: xwiki.yaml
- isNotEmpty:
path: spec.template.metadata.annotations["checksum/configmap"]
template: xwiki.yaml
template: xwiki.yaml
- isNotEmpty:
path: spec.template.metadata.annotations["checksum/initialization-configmaps"]
template: xwiki.yaml
template: xwiki.yaml
- it: should use custom image
set:
image.tag: latest
Expand All @@ -32,11 +32,11 @@ tests:
- equal:
path: spec.template.spec.containers[0].image
value: default:latest
template: xwiki.yaml
template: xwiki.yaml
documentIndex: 0
- matchSnapshot:
path: spec.template.spec.containers[0].env
template: xwiki.yaml
template: xwiki.yaml
documentIndex: 0
- it: should use mysql lts image
set:
Expand All @@ -47,10 +47,10 @@ tests:
- equal:
path: spec.template.spec.containers[0].image
value: xwiki:lts-mysql-tomcat
template: xwiki.yaml
template: xwiki.yaml
- matchSnapshot:
path: spec.template.spec.containers[0].env
template: xwiki.yaml
template: xwiki.yaml
- it: should use postgres lts image
set:
mysql.enabled: false
Expand All @@ -60,41 +60,41 @@ tests:
- equal:
path: spec.template.spec.containers[0].image
value: xwiki:lts-postgres-tomcat
template: xwiki.yaml
template: xwiki.yaml
- matchSnapshot:
path: spec.template.spec.containers[0].env
template: xwiki.yaml
template: xwiki.yaml
- it: should properly set value
set:
image.pullPolicy: IfNotPresent
service.internalPort: 8080
asserts:
asserts:
- equal:
path: spec.template.spec.containers[0].imagePullPolicy
value: IfNotPresent
template: xwiki.yaml
template: xwiki.yaml
- equal:
path: spec.template.spec.containers[0].ports[0].containerPort
value: 8080
template: xwiki.yaml
template: xwiki.yaml
# - equal:
# path: spec.template.spec.containers[0].volumeMounts[1].name
# value: xwiki-data
# template: xwiki.yaml
# template: xwiki.yaml
# - equal:
# path: spec.template.spec.volumes[1].name
# value: xwiki-data
# template: xwiki.yaml
# template: xwiki.yaml
# - equal:
# path: spec.template.spec.volumes[1].persistentVolumeClaim.claimName
# value: xwiki
# template: xwiki.yaml
# template: xwiki.yaml
# - matchSnapshot:
# path: spec.template.spec.containers[1].volumeMounts
# template: xwiki.yaml
# template: xwiki.yaml
# - matchSnapshot:
# path: spec.template.spec.volumes
# template: xwiki.yaml
# path: spec.template.spec.volumes
# template: xwiki.yaml
# - it: should properly set value pvc
# asserts:
# - isKind:
Expand All @@ -106,4 +106,4 @@ tests:
# - equal:
# path: metadata.name
# value: xwiki
# documentIndex: 1
# documentIndex: 1
Loading

0 comments on commit 71176a2

Please sign in to comment.