🐘 PostgreSQL Integration Tests #111
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This workflow runs PostgreSQL integration tests | |
| # Triggers: | |
| # - On demand (workflow_dispatch) | |
| # - Daily at 12 AM Local Time(SL) | |
| # - During release (when release workflow completes) | |
| name: 🐘 PostgreSQL Integration Tests | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| distribution-url: | |
| description: 'URL to download Distribution (optional, will build if not provided)' | |
| required: false | |
| type: string | |
| version: | |
| description: 'Version to test (optional, defaults to latest)' | |
| required: false | |
| type: string | |
| schedule: | |
| # Run daily at 12 AM Local Time(SL) | |
| - cron: '30 18 * * *' | |
| workflow_run: | |
| workflows: ["🚀 Release Builder"] | |
| types: [completed] | |
| branches: [main] | |
| env: | |
| GOFLAGS: "-mod=readonly" | |
| PRODUCT_NAME: "Thunder" | |
| PRODUCT_NAME_LOWER: "thunder" | |
| jobs: | |
| dependency-guard: | |
| name: 🛡️ Dependency Guard | |
| uses: ./.github/workflows/dependency-guard.yml | |
| with: | |
| detection-mode: commit | |
| build-if-needed: | |
| name: 🔨 Build Distribution (if needed) | |
| needs: dependency-guard | |
| runs-on: ubuntu-latest | |
| if: ${{ always() && (needs.dependency-guard.result == 'success' || needs.dependency-guard.result == 'skipped') && (github.event.inputs.distribution-url == '' || github.event.inputs.distribution-url == null) }} | |
| outputs: | |
| distribution-path: ${{ steps.build.outputs.distribution-path }} | |
| steps: | |
| - name: 📥 Checkout Code | |
| uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: ⚙️ Set up Go Environment | |
| uses: ./.github/actions/setup-go | |
| - name: 🗄️ Cache Go Modules | |
| uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4 | |
| id: cache-go-modules | |
| with: | |
| path: | | |
| ~/.cache/go-build | |
| ~/go/pkg/mod | |
| key: ${{ runner.os }}-go-modules-${{ hashFiles('**/go.sum') }} | |
| restore-keys: | | |
| ${{ runner.os }}-go-modules- | |
| - name: 📦 Install Dependencies | |
| run: | | |
| cd backend | |
| go mod download | |
| cd ../tests/integration | |
| go mod download | |
| - name: 🏷️ Set Version (if provided) | |
| if: ${{ github.event.inputs.version != '' && github.event.inputs.version != null }} | |
| run: | | |
| VERSION="${{ github.event.inputs.version }}" | |
| echo "$VERSION" > version.txt | |
| echo "Set version to: $VERSION" | |
| - name: 🧹 Clean Previous Builds | |
| run: make clean | |
| - name: 🔨 Build Product with Coverage | |
| id: build | |
| run: | | |
| set -e | |
| make build_with_coverage_only OS=$(go env GOOS) ARCH=$(go env GOARCH) | |
| # Find the built distribution | |
| DIST_PATH=$(find target/dist -name "$PRODUCT_NAME_LOWER-*.zip" | head -1) | |
| echo "distribution-path=$DIST_PATH" >> $GITHUB_OUTPUT | |
| echo "Built distribution: $DIST_PATH" | |
| - name: 📦 Upload Built Distribution | |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 | |
| with: | |
| name: product-distribution | |
| path: target/dist/*.zip | |
| if-no-files-found: error | |
| download-distribution: | |
| name: 📥 Download Distribution | |
| runs-on: ubuntu-latest | |
| if: ${{ github.event.inputs.distribution-url != '' && github.event.inputs.distribution-url != null }} | |
| outputs: | |
| distribution-path: ${{ steps.download.outputs.distribution-path }} | |
| steps: | |
| - name: 📥 Download Distribution | |
| id: download | |
| run: | | |
| DIST_URL="${{ github.event.inputs.distribution-url }}" | |
| DIST_FILENAME="product-distribution.zip" | |
| echo "Downloading distribution from: $DIST_URL" | |
| curl -L -o "$DIST_FILENAME" "$DIST_URL" | |
| # Verify the download | |
| if [ ! -f "$DIST_FILENAME" ]; then | |
| echo "❌ Failed to download distribution" | |
| exit 1 | |
| fi | |
| echo "✅ Distribution downloaded successfully" | |
| echo "distribution-path=$DIST_FILENAME" >> $GITHUB_OUTPUT | |
| test-postgres: | |
| name: 🧪 PostgreSQL Integration Tests | |
| runs-on: ubuntu-latest | |
| needs: [dependency-guard, build-if-needed, download-distribution] | |
| if: always() && (needs.dependency-guard.result == 'success' || needs.dependency-guard.result == 'skipped') && (needs.build-if-needed.result == 'success' || needs.download-distribution.result == 'success') | |
| services: | |
| postgres: | |
| image: postgres:latest | |
| env: | |
| POSTGRES_USER: dbuser | |
| POSTGRES_PASSWORD: dbpassword | |
| POSTGRES_DB: thunderdb | |
| ports: | |
| - 5432:5432 | |
| options: >- | |
| --health-cmd pg_isready | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| steps: | |
| - name: 📥 Checkout Code | |
| uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 | |
| - name: ⚙️ Set up Go Environment | |
| uses: ./.github/actions/setup-go | |
| - name: 🗄️ Cache Go Modules | |
| uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4 | |
| id: cache-go-modules | |
| with: | |
| path: | | |
| ~/.cache/go-build | |
| ~/go/pkg/mod | |
| key: ${{ runner.os }}-go-modules-${{ hashFiles('**/go.sum') }} | |
| restore-keys: | | |
| ${{ runner.os }}-go-modules- | |
| - name: 📥 Download Built Distribution | |
| uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4 | |
| with: | |
| name: product-distribution | |
| path: target/dist/ | |
| - name: 📦 Install Dependencies | |
| run: | | |
| cd backend | |
| go mod download | |
| cd ../tests/integration | |
| go mod download | |
| - name: 📝 Configure Test Database | |
| run: | | |
| chmod +x tests/integration/resources/scripts/setup-test-config.sh | |
| ./tests/integration/resources/scripts/setup-test-config.sh | |
| env: | |
| DB_TYPE: postgres | |
| - name: 🧪 Run PostgreSQL Integration Tests | |
| uses: ./.github/actions/run-integration-tests | |
| with: | |
| database-type: postgres | |
| coverage-enabled: true | |
| - name: 📊 Upload Coverage Report | |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 | |
| if: always() | |
| with: | |
| name: postgres-coverage-report | |
| path: | | |
| target/coverage_integration_postgres.out | |
| target/coverage_integration_postgres.html | |
| if-no-files-found: ignore | |
| notify-results: | |
| name: 📢 Notify Test Results | |
| runs-on: ubuntu-latest | |
| needs: [test-postgres] | |
| if: always() | |
| steps: | |
| - name: 📢 Notify Success | |
| if: needs.test-postgres.result == 'success' | |
| run: | | |
| echo "✅ PostgreSQL integration tests completed successfully!" | |
| echo "Triggered by: ${{ github.event_name }}" | |
| if [ "${{ github.event_name }}" == "schedule" ]; then | |
| echo "📅 Daily PostgreSQL test run completed" | |
| elif [ "${{ github.event_name }}" == "workflow_run" ]; then | |
| echo "🚀 PostgreSQL tests completed after release" | |
| else | |
| echo "🔧 Manual PostgreSQL test run completed" | |
| fi | |
| - name: 📢 Notify Failure | |
| if: needs.test-postgres.result == 'failure' | |
| run: | | |
| echo "❌ PostgreSQL integration tests failed!" | |
| echo "Triggered by: ${{ github.event_name }}" | |
| if [ "${{ github.event_name }}" == "schedule" ]; then | |
| echo "📅 Daily PostgreSQL test run failed" | |
| elif [ "${{ github.event_name }}" == "workflow_run" ]; then | |
| echo "🚀 PostgreSQL tests failed after release" | |
| else | |
| echo "🔧 Manual PostgreSQL test run failed" | |
| fi | |
| exit 1 |