Skip to content

wip

wip #1

name: Helm Chart Ginkgo Tests
on:
push:
branches: [main]
paths:
- 'chart/**'
- 'test/**'
- '.github/workflows/helm-ginkgo-tests.yml'
pull_request:
branches: [main]
paths:
- 'chart/**'
- 'test/**'
- '.github/workflows/helm-ginkgo-tests.yml'
workflow_dispatch:
env:
GO_VERSION: '1.21'
KIND_VERSION: 'v0.20.0'
HELM_VERSION: 'v3.13.3'
KUBECTL_VERSION: 'v1.29.0'
jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
test-suite:
- "New Installation"
- "Configuration Generation"
- "PostgreSQL Version Upgrade"
- "Admin Password Management"
- "High Availability and Production Settings"
- "Monitoring and Health Checks"
- "Edge Cases and Error Handling"
name: Test - ${{ matrix.test-suite }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache: true
cache-dependency-path: test/go.sum
- name: Install kind
run: |
curl -Lo ./kind https://kind.sigs.k8s.io/dl/${{ env.KIND_VERSION }}/kind-linux-amd64
chmod +x ./kind
sudo mv ./kind /usr/local/bin/kind
- name: Install kubectl
run: |
curl -LO "https://dl.k8s.io/release/${{ env.KUBECTL_VERSION }}/bin/linux/amd64/kubectl"
chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/kubectl
- name: Install Helm
run: |
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
chmod 700 get_helm.sh
./get_helm.sh --version ${{ env.HELM_VERSION }}
- name: Create kind cluster
run: |
cd test
kind create cluster --config kind-config.yaml
kubectl cluster-info --context kind-postgres-test
kubectl wait --for=condition=Ready nodes --all --timeout=60s
- name: Load Docker images to kind
run: |
# Load the upgrade container image
docker pull ghcr.io/flanksource/postgres-upgrade:to-17-latest || true
kind load docker-image ghcr.io/flanksource/postgres-upgrade:to-17-latest --name postgres-test || true
# Load Supabase PostgreSQL image
docker pull supabase/postgres:15.1.0.147 || true
kind load docker-image supabase/postgres:15.1.0.147 --name postgres-test || true
- name: Install Go dependencies
working-directory: test
run: |
go mod download
go install github.com/onsi/ginkgo/v2/ginkgo@latest
- name: Run Ginkgo tests
working-directory: test
env:
TEST_NAMESPACE: postgres-test-${{ github.run_id }}
CHART_PATH: ../chart
run: |
mkdir -p reports
ginkgo -v \
--fail-fast \
--trace \
--focus="${{ matrix.test-suite }}" \
--timeout=20m \
--output-dir=./reports \
--json-report=report.json \
--junit-report=report.xml
- name: Upload test reports
if: always()
uses: actions/upload-artifact@v4
with:
name: test-reports-${{ matrix.test-suite }}
path: |
test/reports/
test/*.out
test/*.log
- name: Cleanup
if: always()
run: |
kind delete cluster --name postgres-test || true
integration-test-summary:
needs: test
runs-on: ubuntu-latest
if: always()
steps:
- name: Download all test reports
uses: actions/download-artifact@v4
with:
path: test-reports
pattern: test-reports-*
- name: Summarize test results
run: |
echo "## Test Results Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
for report_dir in test-reports/test-reports-*; do
if [ -f "$report_dir/reports/report.xml" ]; then
suite_name=$(basename $report_dir | sed 's/test-reports-//')
echo "### $suite_name" >> $GITHUB_STEP_SUMMARY
# Parse JUnit XML for summary (basic parsing)
if grep -q 'failures="0"' "$report_dir/reports/report.xml" && \
grep -q 'errors="0"' "$report_dir/reports/report.xml"; then
echo "✅ All tests passed" >> $GITHUB_STEP_SUMMARY
else
echo "❌ Some tests failed" >> $GITHUB_STEP_SUMMARY
fi
echo "" >> $GITHUB_STEP_SUMMARY
fi
done
# Single comprehensive test run (optional, for quick validation)
quick-test:
runs-on: ubuntu-latest
if: github.event_name == 'workflow_dispatch'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Install tools
run: |
# Install kind
curl -Lo ./kind https://kind.sigs.k8s.io/dl/${{ env.KIND_VERSION }}/kind-linux-amd64
chmod +x ./kind
sudo mv ./kind /usr/local/bin/kind
# Install kubectl
curl -LO "https://dl.k8s.io/release/${{ env.KUBECTL_VERSION }}/bin/linux/amd64/kubectl"
chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/kubectl
# Install Helm
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
- name: Create kind cluster
run: |
cd test
kind create cluster --config kind-config.yaml
kubectl wait --for=condition=Ready nodes --all --timeout=60s
- name: Run quick smoke test
working-directory: test
run: |
go mod download
go install github.com/onsi/ginkgo/v2/ginkgo@latest
# Run only critical tests
ginkgo -v \
--fail-fast \
--focus="should install with default values" \
--timeout=10m
- name: Cleanup
if: always()
run: |
kind delete cluster --name postgres-test || true