Skip to content

Commit a5e2543

Browse files
authored
Update cd-helm-release.yml
1 parent 93c1813 commit a5e2543

File tree

1 file changed

+131
-23
lines changed

1 file changed

+131
-23
lines changed
Lines changed: 131 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,146 @@
1-
name: Release
1+
name: Lint and Test Chart
22

33
on:
4-
workflow_dispatch:
5-
push:
6-
branches:
7-
- main
4+
pull_request:
85
paths:
96
- 'charts/**'
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: read
1011

1112
jobs:
12-
release:
13-
environment: helm-release
14-
permissions:
15-
contents: write
13+
lint:
14+
name: Lint
1615
runs-on: ubuntu-latest
1716
steps:
1817
- name: Checkout
1918
uses: actions/checkout@v4
2019
with:
21-
fetch-depth: 0
22-
23-
- name: Configure Git
24-
run: |
25-
git config user.name "$GITHUB_ACTOR"
26-
git config user.email "[email protected]"
20+
fetch-depth: "0"
2721

2822
- name: Install Helm
2923
uses: azure/[email protected]
30-
id: helm-install
31-
with:
32-
token: ${{ secrets.GITHUB_TOKEN }}
3324

34-
- name: Run chart-releaser
35-
uses: helm/[email protected]
36-
env:
37-
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
38-
CR_GENERATE_RELEASE_NOTES: true
25+
- name: Set up chart-testing
26+
uses: helm/[email protected]
27+
28+
- name: Run chart-testing (list-changed)
29+
id: list-changed
30+
run: |
31+
changed=$(ct list-changed --target-branch ${{ github.event.repository.default_branch }})
32+
#if [[ -n "$changed" ]]; then
33+
echo "changed=true" >> "$GITHUB_OUTPUT"
34+
#fi
35+
36+
- name: Run chart-testing (lint)
37+
id: lint
38+
if: steps.list-changed.outputs.changed == 'true'
39+
run: ct lint --target-branch ${{ github.event.repository.default_branch }}
40+
41+
- name: Create kind cluster
42+
uses: helm/[email protected]
43+
if: steps.list-changed.outputs.changed == 'true'
44+
45+
- name: verify cluster and local path
46+
run: |
47+
kubectl config set-context kind-chart-testing
48+
kubectl cluster-info
49+
kubectl get pods -A
50+
pwd
51+
ls -hal
52+
53+
- name: Install Certmanager
54+
run: |
55+
helm repo add jetstack https://charts.jetstack.io
56+
helm repo update
57+
helm install cert-manager jetstack/cert-manager \
58+
--namespace cert-manager \
59+
--create-namespace \
60+
--set installCRDs=true \
61+
--set prometheus.enabled=false \
62+
--wait
63+
64+
- name: Install CNPG Operator
65+
run: |
66+
helm repo add cnpg-operator https://cloudnative-pg.github.io/charts
67+
helm repo update
68+
helm install cnpg-operator cnpg-operator/cloudnative-pg \
69+
--namespace cnpg-system \
70+
--create-namespace \
71+
--wait
72+
73+
- name: Creat testing values
74+
working-directory: ./charts/cloudnative-pg-cluster
75+
run: |
76+
cat << EOF > test-values.yaml
77+
name: "cnpg"
78+
instances: 3
79+
bootstrap:
80+
initdb:
81+
database: app
82+
owner: app
83+
secret:
84+
name: null
85+
certificates:
86+
server:
87+
enabled: true
88+
generate: true
89+
serverTLSSecret: ""
90+
serverCASecret: ""
91+
client:
92+
enabled: true
93+
generate: true
94+
clientCASecret: ""
95+
replicationTLSSecret: ""
96+
user:
97+
enabled: true
98+
username:
99+
- "app"
100+
monitoring:
101+
enablePodMonitor: false
102+
postgresql:
103+
pg_hba:
104+
- hostssl all all all cert
105+
resources:
106+
requests:
107+
cpu: "50m"
108+
memory: "256Mi"
109+
limits:
110+
cpu: "1000m"
111+
memory: "1024Mi"
112+
storage:
113+
size: 1Gi
114+
testApp:
115+
enabled: false
116+
EOF
117+
118+
- name: Install CNPG cluster
119+
working-directory: ./charts/cloudnative-pg-cluster
120+
run: |
121+
helm repo add cnpg-cluster https://small-hack.github.io/cloudnative-pg-cluster-chart
122+
helm repo update
123+
helm install cnpg-cluster cnpg-cluster/cnpg-cluster \
124+
--values test-values.yaml
125+
126+
ITER=0
127+
while true; do
128+
if [[ $ITER -ge 300 ]]; then
129+
echo "Cluster not ready"
130+
exit 1
131+
fi
132+
READY_INSTANCES=$(kubectl get cluster cnpg -o jsonpath='{.status.readyInstances}')
133+
if [[ "$READY_INSTANCES" == 3 ]]; then
134+
echo "Cluster up and running"
135+
break
136+
fi
137+
sleep 1
138+
STATUS=$(kubectl get cluster)
139+
echo "$STATUS"
140+
(( ++ITER ))
141+
done
142+
143+
- name: Run chart-testing (install)
144+
id: install
145+
if: steps.list-changed.outputs.changed == 'true'
146+
run: ct install --target-branch ${{ github.event.repository.default_branch }}

0 commit comments

Comments
 (0)