Skip to content

Lint and Test Chart #66

Lint and Test Chart

Lint and Test Chart #66

name: Lint and Test Chart
on:
pull_request:
paths:
- 'charts/**'
workflow_dispatch:
permissions:
contents: read
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: "0"
- name: Install Helm
uses: azure/[email protected]
- name: Set up chart-testing
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: Run chart-testing (lint)
id: lint
if: steps.list-changed.outputs.changed == 'true'
run: ct lint --target-branch ${{ github.event.repository.default_branch }}
- name: Create kind cluster
uses: helm/[email protected]
if: steps.list-changed.outputs.changed == 'true'
- name: verify cluster and local path
run: |
kubectl config set-context kind-chart-testing
kubectl cluster-info
kubectl get pods -A
pwd
ls -hal
- name: Install Certmanager
run: |
helm repo add jetstack https://charts.jetstack.io
helm repo update
helm install cert-manager jetstack/cert-manager \
--namespace cert-manager \
--create-namespace \
--set installCRDs=true \
--set prometheus.enabled=false \
--wait
- name: Install CNPG Operator
run: |
helm repo add cnpg-operator https://cloudnative-pg.github.io/charts
helm repo update
helm install cnpg-operator cnpg-operator/cloudnative-pg \
--namespace cnpg-system \
--create-namespace \
--wait
- name: Creat testing values
working-directory: ./charts/cloudnative-pg-cluster
run: |
cat << EOF > test-values.yaml
name: "cnpg"
instances: 3
bootstrap:
initdb:
database: app
owner: app
secret:
name: null
certificates:
server:
enabled: true
generate: true
serverTLSSecret: ""
serverCASecret: ""
client:
enabled: true
generate: true
clientCASecret: ""
replicationTLSSecret: ""
user:
enabled: true
username: "app"
monitoring:
enablePodMonitor: false
postgresql:
pg_hba:
- hostssl all all all cert
storage:
size: 1Gi
testApp:
enabled: false
EOF
- name: Install CNPG cluster
working-directory: ./charts/cloudnative-pg-cluster
run: |
helm repo add cnpg-cluster https://small-hack.github.io/cloudnative-pg-cluster-chart
helm repo update
helm install cnpg-cluster cnpg-cluster/cnpg-cluster \
--values test-values.yaml \
--wait
ITER=0
while true; do
if [[ $ITER -ge 300 ]]; then
echo "Cluster not ready"
exit 1
fi
READY_INSTANCES=$(kubectl get cluster cnpg -o jsonpath='{.status.readyInstances}')
if [[ "$READY_INSTANCES" == 3 ]]; then
echo "Cluster up and running"
break
fi
sleep 1
echo "$READY_INSTANCES"
(( ++ITER ))
done
- name: Run chart-testing (install)
id: install
if: steps.list-changed.outputs.changed == 'true'
run: ct install --target-branch ${{ github.event.repository.default_branch }}