|
1 | | -name: Release |
| 1 | +name: Lint and Test Chart |
2 | 2 |
|
3 | 3 | on: |
4 | | - workflow_dispatch: |
5 | | - push: |
6 | | - branches: |
7 | | - - main |
| 4 | + pull_request: |
8 | 5 | paths: |
9 | 6 | - 'charts/**' |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: read |
10 | 11 |
|
11 | 12 | jobs: |
12 | | - release: |
13 | | - environment: helm-release |
14 | | - permissions: |
15 | | - contents: write |
| 13 | + lint: |
| 14 | + name: Lint |
16 | 15 | runs-on: ubuntu-latest |
17 | 16 | steps: |
18 | 17 | - name: Checkout |
19 | 18 | uses: actions/checkout@v4 |
20 | 19 | 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" |
27 | 21 |
|
28 | 22 | - name: Install Helm |
29 | 23 | |
30 | | - id: helm-install |
31 | | - with: |
32 | | - token: ${{ secrets.GITHUB_TOKEN }} |
33 | 24 |
|
34 | | - - name: Run chart-releaser |
35 | | - |
36 | | - env: |
37 | | - CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" |
38 | | - CR_GENERATE_RELEASE_NOTES: true |
| 25 | + - name: Set up chart-testing |
| 26 | + |
| 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 | + |
| 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