|
| 1 | +name: PMM-HA PR checks |
| 2 | +on: |
| 3 | + pull_request: |
| 4 | + paths: |
| 5 | + - 'charts/pmm-ha/**' |
| 6 | + - 'charts/pmm-ha-dependencies/**' |
| 7 | + |
| 8 | +jobs: |
| 9 | + lint-test: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + steps: |
| 12 | + - name: Checkout |
| 13 | + uses: actions/checkout@v4 |
| 14 | + with: |
| 15 | + fetch-depth: 0 |
| 16 | + sparse-checkout: | |
| 17 | + .github/ |
| 18 | + charts/pmm-ha |
| 19 | + charts/pmm-ha-dependencies |
| 20 | +
|
| 21 | + - name: Set up Helm |
| 22 | + uses: azure/setup-helm@v4.2.0 |
| 23 | + with: |
| 24 | + version: v3.15.4 |
| 25 | + |
| 26 | + - uses: azure/setup-kubectl@v4 |
| 27 | + |
| 28 | + - name: Set up chart-testing |
| 29 | + uses: helm/chart-testing-action@v2.6.1 |
| 30 | + |
| 31 | + - name: Add Helm repositories |
| 32 | + run: | |
| 33 | + helm repo add altinity https://helm.altinity.com |
| 34 | + helm repo add percona https://percona.github.io/percona-helm-charts/ |
| 35 | + helm repo add vm https://victoriametrics.github.io/helm-charts/ |
| 36 | + helm repo add haproxytech https://haproxytech.github.io/helm-charts/ |
| 37 | + helm repo add prometheus-community https://prometheus-community.github.io/helm-charts/ |
| 38 | + helm repo update |
| 39 | +
|
| 40 | + - name: Run chart-testing (list-changed) |
| 41 | + id: list-changed |
| 42 | + run: | |
| 43 | + changed=$(ct list-changed --config .github/ct.yaml) |
| 44 | + if [[ -n "$changed" ]]; then |
| 45 | + echo "changed=true" >> $GITHUB_OUTPUT |
| 46 | + fi |
| 47 | +
|
| 48 | + - name: Run chart-testing (lint) |
| 49 | + run: | |
| 50 | + ct lint --config .github/ct.yaml --lint-conf .github/lintconf.yaml --chart-dirs=charts --charts=charts/pmm-ha,charts/pmm-ha-dependencies --check-version-increment=true |
| 51 | +
|
| 52 | + - name: Create kind cluster |
| 53 | + uses: helm/kind-action@v1.10.0 |
| 54 | + if: steps.list-changed.outputs.changed == 'true' |
| 55 | + |
| 56 | + - name: Prepare PMM-HA prerequisites |
| 57 | + if: steps.list-changed.outputs.changed == 'true' |
| 58 | + run: | |
| 59 | + NS="pmm-ha-$(openssl rand -hex 5)" |
| 60 | + echo "NS=$NS" >> $GITHUB_ENV |
| 61 | + kubectl create namespace "$NS" || true |
| 62 | +
|
| 63 | + # pmm-secret |
| 64 | + cat <<'EOF' | kubectl apply -n "$NS" -f - |
| 65 | + apiVersion: v1 |
| 66 | + kind: Secret |
| 67 | + metadata: |
| 68 | + name: pmm-secret |
| 69 | + labels: |
| 70 | + app.kubernetes.io/name: pmm |
| 71 | + type: Opaque |
| 72 | + data: |
| 73 | + PMM_ADMIN_PASSWORD: YWRtaW4= |
| 74 | + PG_PASSWORD: cG1tcGFzcw== |
| 75 | + GF_PASSWORD: Z2ZwYXNz |
| 76 | + VMAGENT_remoteWrite_basicAuth_username: dm11c2Vy |
| 77 | + VMAGENT_remoteWrite_basicAuth_password: dm1wYXNz |
| 78 | + PMM_CLICKHOUSE_USER: Y2h1c2Vy |
| 79 | + PMM_CLICKHOUSE_PASSWORD: Y2hwYXNz |
| 80 | + EOF |
| 81 | +
|
| 82 | + - name: Install pmm-ha-dependencies chart |
| 83 | + if: steps.list-changed.outputs.changed == 'true' |
| 84 | + run: | |
| 85 | + echo "Installing pmm-ha-dependencies (operators)..." |
| 86 | + # Using --skip-clean-up to keep operators running for pmm-ha installation |
| 87 | + ct install --namespace "${{ env.NS }}" --config .github/ct.yaml --charts=charts/pmm-ha-dependencies --skip-clean-up |
| 88 | + |
| 89 | + echo "Waiting for operators to be ready..." |
| 90 | + kubectl wait --for=condition=ready pod -l app.kubernetes.io/name=victoria-metrics-operator -n "${{ env.NS }}" --timeout=300s |
| 91 | + kubectl wait --for=condition=ready pod -l app.kubernetes.io/name=altinity-clickhouse-operator -n "${{ env.NS }}" --timeout=300s |
| 92 | + kubectl wait --for=condition=ready pod -l app.kubernetes.io/name=pg-operator -n "${{ env.NS }}" --timeout=300s |
| 93 | + |
| 94 | + echo "All operators are ready!" |
| 95 | +
|
| 96 | + # - name: Setup tmate session on failure |
| 97 | + # uses: mxschmitt/action-tmate@v3 |
| 98 | + # timeout-minutes: 60 |
| 99 | + # with: |
| 100 | + # limit-access-to-actor: true |
| 101 | + |
| 102 | + - name: Run chart-testing (install pmm-ha) |
| 103 | + if: steps.list-changed.outputs.changed == 'true' |
| 104 | + run: | |
| 105 | + # Install pmm-ha chart via ct (using --skip-crds from ct.yaml) |
| 106 | + ct install --namespace "${{ env.NS }}" --config .github/ct.yaml --charts=charts/pmm-ha |
| 107 | +
|
| 108 | + - name: Build chart packages |
| 109 | + run: | |
| 110 | + changed=$(ct list-changed --config .github/ct.yaml) |
| 111 | + if [[ -n "$changed" ]]; then |
| 112 | + for chart in $changed; do |
| 113 | + echo "Packaging $chart..." |
| 114 | + helm package "$chart" |
| 115 | + done |
| 116 | + else |
| 117 | + echo "No charts changed, skipping package" |
| 118 | + fi |
| 119 | +
|
| 120 | + - name: Upload helm charts |
| 121 | + uses: actions/upload-artifact@v4 |
| 122 | + with: |
| 123 | + path: ./*.tgz |
| 124 | + retention-days: 30 |
| 125 | + if-no-files-found: ignore |
| 126 | + |
| 127 | + - name: Cleanup test resources |
| 128 | + if: steps.list-changed.outputs.changed == 'true' |
| 129 | + run: | |
| 130 | + echo "Cleaning up test namespace: ${{ env.NS }}" |
| 131 | + |
| 132 | + # Uninstall pmm-ha-dependencies chart (ct creates dynamic release names) |
| 133 | + DEPS_RELEASE=$(helm list -n "${{ env.NS }}" --filter 'pmm-ha-dependencies-*' -q) |
| 134 | + if [[ -n "$DEPS_RELEASE" ]]; then |
| 135 | + echo "Uninstalling release: $DEPS_RELEASE" |
| 136 | + helm uninstall "$DEPS_RELEASE" -n "${{ env.NS }}" || true |
| 137 | + fi |
| 138 | + |
| 139 | + # Delete namespace and all remaining resources |
| 140 | + kubectl delete namespace "${{ env.NS }}" --timeout=120s || true |
| 141 | + |
| 142 | + echo "Cleanup completed. CRDs are intentionally left for reuse by other tests." |
0 commit comments