Skip to content

PostgreSQL 13.23, 14.20, 15.15, 16.11, 17.7, and 18.1 #28

PostgreSQL 13.23, 14.20, 15.15, 16.11, 17.7, and 18.1

PostgreSQL 13.23, 14.20, 15.15, 16.11, 17.7, and 18.1 #28

Workflow file for this run

name: PostgreSQL Module Tests
on:
pull_request:
branches:
- main
- develop
types: [opened, synchronize, reopened, edited]
jobs:
detect-versions:
name: Detect PostgreSQL Versions
runs-on: ubuntu-latest
outputs:
versions: ${{ steps.get-versions.outputs.versions }}
has-changes: ${{ steps.check-changes.outputs.has-changes }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check for Changes
id: check-changes
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
echo "has-changes=true" >> $GITHUB_OUTPUT
echo "Manual workflow trigger - will run tests"
elif [ "${{ github.event_name }}" == "pull_request" ]; then
echo "has-changes=true" >> $GITHUB_OUTPUT
echo "Pull request - will run tests"
else
CHANGED_FILES=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }})
if echo "$CHANGED_FILES" | grep -qE "releases\.properties|\.github/workflows/postgresql-test\.yml"; then
echo "has-changes=true" >> $GITHUB_OUTPUT
echo "Relevant files changed - will run tests"
else
echo "has-changes=false" >> $GITHUB_OUTPUT
echo "No relevant changes - skipping tests"
fi
fi
- name: Get PostgreSQL Versions
id: get-versions
run: |
if [ "${{ github.event.inputs.version }}" != "" ]; then
# Manual workflow with specific version
VERSION="${{ github.event.inputs.version }}"
echo "Testing specific version: $VERSION"
VERSIONS="[\"$VERSION\"]"
else
# Get all versions from releases.properties
VERSIONS=$(grep -E "^[0-9]+\.[0-9]+" releases.properties | cut -d'=' -f1 | tr -d ' ' | jq -R -s -c 'split("\n") | map(select(length > 0)) | unique | sort_by(split(".") | map(tonumber)) | reverse | .[0:5]')
echo "Testing latest 5 versions"
fi
echo "versions=$VERSIONS" >> $GITHUB_OUTPUT
echo "Versions to test: $VERSIONS"
test-postgresql:
name: Test PostgreSQL ${{ matrix.version }}
needs: detect-versions
if: needs.detect-versions.outputs.has-changes == 'true'
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
version: ${{ fromJson(needs.detect-versions.outputs.versions) }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Create Test Directories
run: |
New-Item -ItemType Directory -Force -Path "test-postgresql" | Out-Null
New-Item -ItemType Directory -Force -Path "test-results" | Out-Null
New-Item -ItemType Directory -Force -Path "test-data" | Out-Null
Write-Host "✅ Test directories created"
- name: Phase 1.1 - Download PostgreSQL
id: download-postgresql
continue-on-error: true
run: |
$ErrorActionPreference = "Continue"
$version = "${{ matrix.version }}"
Write-Host "=== Phase 1.1: Download PostgreSQL $version ==="
# Read releases.properties to get download URL
$releasesFile = "releases.properties"
$downloadUrl = ""
if (Test-Path $releasesFile) {
$content = Get-Content $releasesFile
foreach ($line in $content) {
if ($line -match "^$version\s*=\s*(.+)$") {
$downloadUrl = $matches[1].Trim()
break
}
}
} else {
Write-Host "❌ ERROR: releases.properties file not found!"
echo "success=false" >> $env:GITHUB_OUTPUT
echo "error=releases.properties file not found" >> $env:GITHUB_OUTPUT
exit 1
}
if (-not $downloadUrl) {
Write-Host "❌ ERROR: Version $version not found in releases.properties"
Write-Host "Available versions in releases.properties:"
Get-Content $releasesFile | Select-String "^[0-9]" | ForEach-Object { Write-Host " - $($_.Line.Split('=')[0].Trim())" }
echo "success=false" >> $env:GITHUB_OUTPUT
echo "error=Version $version not found in releases.properties" >> $env:GITHUB_OUTPUT
exit 1
}
Write-Host "Download URL: $downloadUrl"
try {
$fileName = [System.IO.Path]::GetFileName($downloadUrl)
$downloadPath = Join-Path "test-postgresql" $fileName
Write-Host "Downloading PostgreSQL $version..."
Write-Host "Target file: $downloadPath"
try {
Invoke-WebRequest -Uri $downloadUrl -OutFile $downloadPath -UseBasicParsing -TimeoutSec 300
} catch {
Write-Host "❌ ERROR: Download failed!"
Write-Host "Error details: $($_.Exception.Message)"
Write-Host "Status Code: $($_.Exception.Response.StatusCode.value__)"
Write-Host "URL attempted: $downloadUrl"
echo "success=false" >> $env:GITHUB_OUTPUT
echo "error=Download failed: $($_.Exception.Message)" >> $env:GITHUB_OUTPUT
exit 1
}
if (Test-Path $downloadPath) {
$fileSize = (Get-Item $downloadPath).Length / 1MB
Write-Host "✅ Downloaded: $fileName ($([math]::Round($fileSize, 2)) MB)"
# Verify file is not empty or too small
if ($fileSize -lt 0.1) {
Write-Host "❌ ERROR: Downloaded file is too small ($([math]::Round($fileSize, 2)) MB), likely corrupted"
echo "success=false" >> $env:GITHUB_OUTPUT
echo "error=Downloaded file is too small or corrupted" >> $env:GITHUB_OUTPUT
exit 1
}
# Extract the archive
Write-Host "Extracting archive..."
$extractOutput = & 7z x $downloadPath -o"test-postgresql" -y 2>&1
if ($LASTEXITCODE -eq 0) {
Write-Host "✅ Extraction successful"
# List extracted contents
Write-Host "Extracted contents:"
Get-ChildItem -Path "test-postgresql" -Directory | ForEach-Object { Write-Host " - $($_.Name)" }
# Find the postgresql directory
$pgDir = Get-ChildItem -Path "test-postgresql" -Directory | Where-Object { $_.Name -match "^postgresql" } | Select-Object -First 1
if ($pgDir) {
$pgPath = $pgDir.FullName
Write-Host "✅ PostgreSQL directory found: $pgPath"
# Verify bin directory exists
$binPath = Join-Path $pgPath "bin"
if (Test-Path $binPath) {
Write-Host "✅ bin directory exists"
echo "pg-path=$pgPath" >> $env:GITHUB_OUTPUT
echo "success=true" >> $env:GITHUB_OUTPUT
} else {
Write-Host "❌ ERROR: bin directory not found in $pgPath"
Write-Host "Directory structure:"
Get-ChildItem -Path $pgPath | ForEach-Object { Write-Host " - $($_.Name)" }
echo "success=false" >> $env:GITHUB_OUTPUT
echo "error=bin directory not found in extracted archive" >> $env:GITHUB_OUTPUT
exit 1
}
} else {
Write-Host "❌ ERROR: PostgreSQL directory not found after extraction"
Write-Host "Expected directory pattern: postgresql*"
Write-Host "Found directories:"
Get-ChildItem -Path "test-postgresql" -Directory | ForEach-Object { Write-Host " - $($_.Name)" }
echo "success=false" >> $env:GITHUB_OUTPUT
echo "error=PostgreSQL directory not found after extraction" >> $env:GITHUB_OUTPUT
exit 1
}
} else {
Write-Host "❌ ERROR: Extraction failed with exit code: $LASTEXITCODE"
Write-Host "7z output:"
Write-Host $extractOutput
echo "success=false" >> $env:GITHUB_OUTPUT
echo "error=Extraction failed with exit code $LASTEXITCODE" >> $env:GITHUB_OUTPUT
exit 1
}
} else {
Write-Host "❌ ERROR: Download file not found at expected path: $downloadPath"
echo "success=false" >> $env:GITHUB_OUTPUT
echo "error=Download file not found after download attempt" >> $env:GITHUB_OUTPUT
exit 1
}
} catch {
Write-Host "❌ ERROR: Unexpected error occurred"
Write-Host "Error message: $($_.Exception.Message)"
Write-Host "Stack trace: $($_.ScriptStackTrace)"
echo "success=false" >> $env:GITHUB_OUTPUT
echo "error=$($_.Exception.Message)" >> $env:GITHUB_OUTPUT
exit 1
}
- name: Phase 1.2 - Verify PostgreSQL Installation
id: verify-postgresql
if: steps.download-postgresql.outputs.success == 'true'
continue-on-error: true
run: |
$ErrorActionPreference = "Continue"
$pgPath = "${{ steps.download-postgresql.outputs.pg-path }}"
Write-Host "=== Phase 1.2: Verify PostgreSQL Installation ==="
# Check for required executables
$binPath = Join-Path $pgPath "bin"
$requiredExes = @("postgres.exe", "psql.exe", "pg_ctl.exe", "initdb.exe", "createdb.exe", "dropdb.exe")
$allFound = $true
$verifyResults = @{}
foreach ($exe in $requiredExes) {
$exePath = Join-Path $binPath $exe
if (Test-Path $exePath) {
Write-Host "✅ Found: $exe"
$verifyResults[$exe] = @{ found = $true; path = $exePath }
} else {
Write-Host "❌ Missing: $exe"
$verifyResults[$exe] = @{ found = $false }
$allFound = $false
}
}
# Test postgres version
if ($allFound) {
try {
$postgresExe = Join-Path $binPath "postgres.exe"
$versionOutput = & $postgresExe --version 2>&1 | Out-String
Write-Host "Version: $versionOutput"
$verifyResults["version"] = $versionOutput.Trim()
} catch {
Write-Host "⚠️ Could not get version: $_"
}
}
$verifyResults | ConvertTo-Json -Depth 10 | Out-File "test-results/verify.json"
if ($allFound) {
echo "success=true" >> $env:GITHUB_OUTPUT
echo "bin-path=$binPath" >> $env:GITHUB_OUTPUT
} else {
echo "success=false" >> $env:GITHUB_OUTPUT
exit 1
}
- name: Phase 2.1 - Initialize Database Cluster
id: init-database
if: steps.verify-postgresql.outputs.success == 'true'
continue-on-error: true
run: |
$ErrorActionPreference = "Continue"
$binPath = "${{ steps.verify-postgresql.outputs.bin-path }}"
$dataDir = Join-Path (Get-Location) "test-data\pgdata"
Write-Host "=== Phase 2.1: Initialize Database Cluster ==="
Write-Host "Data directory: $dataDir"
try {
$initdbExe = Join-Path $binPath "initdb.exe"
# Initialize the database cluster
Write-Host "Initializing database cluster..."
$output = & $initdbExe -D $dataDir -U postgres -A trust --locale=C --encoding=UTF8 2>&1 | Out-String
if ($LASTEXITCODE -eq 0) {
Write-Host "✅ Database cluster initialized successfully"
Write-Host $output
echo "success=true" >> $env:GITHUB_OUTPUT
echo "data-dir=$dataDir" >> $env:GITHUB_OUTPUT
} else {
Write-Host "❌ Database initialization failed"
Write-Host $output
echo "success=false" >> $env:GITHUB_OUTPUT
exit 1
}
} catch {
Write-Host "❌ Error initializing database: $_"
echo "success=false" >> $env:GITHUB_OUTPUT
exit 1
}
- name: Phase 2.2 - Start PostgreSQL Server
id: start-server
if: steps.init-database.outputs.success == 'true'
continue-on-error: true
run: |
$ErrorActionPreference = "Continue"
$binPath = "${{ steps.verify-postgresql.outputs.bin-path }}"
$dataDir = "${{ steps.init-database.outputs.data-dir }}"
$logFile = Join-Path (Get-Location) "test-results\postgresql.log"
Write-Host "=== Phase 2.2: Start PostgreSQL Server ==="
try {
$pgCtlExe = Join-Path $binPath "pg_ctl.exe"
# Start the server
Write-Host "Starting PostgreSQL server..."
$output = & $pgCtlExe -D $dataDir -l $logFile start 2>&1 | Out-String
Write-Host $output
# Wait for server to be ready
Write-Host "Waiting for server to be ready..."
Start-Sleep -Seconds 5
# Check server status
$statusOutput = & $pgCtlExe -D $dataDir status 2>&1 | Out-String
Write-Host $statusOutput
if ($statusOutput -match "server is running") {
Write-Host "✅ PostgreSQL server is running"
echo "success=true" >> $env:GITHUB_OUTPUT
echo "log-file=$logFile" >> $env:GITHUB_OUTPUT
} else {
Write-Host "❌ Server is not running"
if (Test-Path $logFile) {
Write-Host "Server log:"
Get-Content $logFile | Write-Host
}
echo "success=false" >> $env:GITHUB_OUTPUT
exit 1
}
} catch {
Write-Host "❌ Error starting server: $_"
if (Test-Path $logFile) {
Write-Host "Server log:"
Get-Content $logFile | Write-Host
}
echo "success=false" >> $env:GITHUB_OUTPUT
exit 1
}
- name: Phase 3.1 - Test Database Connection
id: test-connection
if: steps.start-server.outputs.success == 'true'
continue-on-error: true
run: |
$ErrorActionPreference = "Continue"
$binPath = "${{ steps.verify-postgresql.outputs.bin-path }}"
Write-Host "=== Phase 3.1: Test Database Connection ==="
try {
$psqlExe = Join-Path $binPath "psql.exe"
# Test connection to default postgres database
Write-Host "Testing connection to postgres database..."
$output = & $psqlExe -U postgres -d postgres -c "SELECT version();" 2>&1 | Out-String
if ($LASTEXITCODE -eq 0) {
Write-Host "✅ Connection successful"
Write-Host $output
echo "success=true" >> $env:GITHUB_OUTPUT
} else {
Write-Host "❌ Connection failed"
Write-Host $output
echo "success=false" >> $env:GITHUB_OUTPUT
exit 1
}
} catch {
Write-Host "❌ Error testing connection: $_"
echo "success=false" >> $env:GITHUB_OUTPUT
exit 1
}
- name: Phase 3.2 - Test Database Creation
id: test-create-db
if: steps.test-connection.outputs.success == 'true'
continue-on-error: true
run: |
$ErrorActionPreference = "Continue"
$binPath = "${{ steps.verify-postgresql.outputs.bin-path }}"
$testDbName = "bearsampp_test_db"
Write-Host "=== Phase 3.2: Test Database Creation ==="
try {
$createdbExe = Join-Path $binPath "createdb.exe"
$psqlExe = Join-Path $binPath "psql.exe"
# Create test database
Write-Host "Creating test database: $testDbName"
$output = & $createdbExe -U postgres $testDbName 2>&1 | Out-String
if ($LASTEXITCODE -eq 0) {
Write-Host "✅ Database created successfully"
# Verify database exists
Write-Host "Verifying database exists..."
$verifyOutput = & $psqlExe -U postgres -d postgres -c "\l" 2>&1 | Out-String
if ($verifyOutput -match $testDbName) {
Write-Host "✅ Database verified in database list"
# Create a test table
Write-Host "Creating test table..."
$tableOutput = & $psqlExe -U postgres -d $testDbName -c "CREATE TABLE test_table (id SERIAL PRIMARY KEY, name VARCHAR(100), created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP);" 2>&1 | Out-String
if ($LASTEXITCODE -eq 0) {
Write-Host "✅ Test table created"
# Insert test data
Write-Host "Inserting test data..."
$insertOutput = & $psqlExe -U postgres -d $testDbName -c "INSERT INTO test_table (name) VALUES ('Bearsampp Test 1'), ('Bearsampp Test 2');" 2>&1 | Out-String
if ($LASTEXITCODE -eq 0) {
Write-Host "✅ Test data inserted"
# Query test data
Write-Host "Querying test data..."
$queryOutput = & $psqlExe -U postgres -d $testDbName -c "SELECT * FROM test_table;" 2>&1 | Out-String
Write-Host $queryOutput
if ($LASTEXITCODE -eq 0) {
Write-Host "✅ Test data queried successfully"
echo "success=true" >> $env:GITHUB_OUTPUT
echo "test-db=$testDbName" >> $env:GITHUB_OUTPUT
} else {
Write-Host "❌ Failed to query test data"
echo "success=false" >> $env:GITHUB_OUTPUT
}
} else {
Write-Host "❌ Failed to insert test data"
echo "success=false" >> $env:GITHUB_OUTPUT
}
} else {
Write-Host "❌ Failed to create test table"
echo "success=false" >> $env:GITHUB_OUTPUT
}
} else {
Write-Host "❌ Database not found in list"
echo "success=false" >> $env:GITHUB_OUTPUT
}
} else {
Write-Host "❌ Database creation failed"
Write-Host $output
echo "success=false" >> $env:GITHUB_OUTPUT
exit 1
}
} catch {
Write-Host "❌ Error creating database: $_"
echo "success=false" >> $env:GITHUB_OUTPUT
exit 1
}
- name: Phase 3.3 - Test Database Deletion
id: test-delete-db
if: steps.test-create-db.outputs.success == 'true'
continue-on-error: true
run: |
$ErrorActionPreference = "Continue"
$binPath = "${{ steps.verify-postgresql.outputs.bin-path }}"
$testDbName = "${{ steps.test-create-db.outputs.test-db }}"
Write-Host "=== Phase 3.3: Test Database Deletion ==="
try {
$dropdbExe = Join-Path $binPath "dropdb.exe"
$psqlExe = Join-Path $binPath "psql.exe"
# Drop test database
Write-Host "Dropping test database: $testDbName"
$output = & $dropdbExe -U postgres $testDbName 2>&1 | Out-String
if ($LASTEXITCODE -eq 0) {
Write-Host "✅ Database dropped successfully"
# Verify database no longer exists
Write-Host "Verifying database was deleted..."
$verifyOutput = & $psqlExe -U postgres -d postgres -c "\l" 2>&1 | Out-String
if ($verifyOutput -notmatch $testDbName) {
Write-Host "✅ Database successfully removed from database list"
echo "success=true" >> $env:GITHUB_OUTPUT
} else {
Write-Host "❌ Database still exists in list"
echo "success=false" >> $env:GITHUB_OUTPUT
}
} else {
Write-Host "❌ Database deletion failed"
Write-Host $output
echo "success=false" >> $env:GITHUB_OUTPUT
exit 1
}
} catch {
Write-Host "❌ Error deleting database: $_"
echo "success=false" >> $env:GITHUB_OUTPUT
exit 1
}
- name: Phase 4 - Cleanup and Stop Server
if: always() && steps.start-server.outputs.success == 'true'
run: |
$ErrorActionPreference = "Continue"
$binPath = "${{ steps.verify-postgresql.outputs.bin-path }}"
$dataDir = "${{ steps.init-database.outputs.data-dir }}"
Write-Host "=== Phase 4: Cleanup and Stop Server ==="
try {
$pgCtlExe = Join-Path $binPath "pg_ctl.exe"
# Stop the server
Write-Host "Stopping PostgreSQL server..."
$output = & $pgCtlExe -D $dataDir stop -m fast 2>&1 | Out-String
Write-Host $output
# Wait for server to stop
Start-Sleep -Seconds 3
# Verify server stopped
$statusOutput = & $pgCtlExe -D $dataDir status 2>&1 | Out-String
if ($statusOutput -match "no server running") {
Write-Host "✅ PostgreSQL server stopped successfully"
} else {
Write-Host "⚠️ Server may still be running"
}
} catch {
Write-Host "⚠️ Error during cleanup: $_"
}
- name: Generate Test Summary
if: always()
run: |
$version = "${{ matrix.version }}"
Write-Host "`n=== Test Summary for PostgreSQL $version ==="
$phase1_1 = "${{ steps.download-postgresql.outputs.success }}" -eq "true"
$phase1_2 = "${{ steps.verify-postgresql.outputs.success }}" -eq "true"
$phase2_1 = "${{ steps.init-database.outputs.success }}" -eq "true"
$phase2_2 = "${{ steps.start-server.outputs.success }}" -eq "true"
$phase3_1 = "${{ steps.test-connection.outputs.success }}" -eq "true"
$phase3_2 = "${{ steps.test-create-db.outputs.success }}" -eq "true"
$phase3_3 = "${{ steps.test-delete-db.outputs.success }}" -eq "true"
# Get error messages if any
$error1_1 = "${{ steps.download-postgresql.outputs.error }}"
$summary = "### PostgreSQL $version`n`n"
$summary += "**Phase 1: Installation Validation**`n"
$summary += "- Download & Extract: $(if ($phase1_1) { '✅ PASS' } else { '❌ FAIL' })`n"
if (-not $phase1_1 -and $error1_1) {
$summary += " - Error: $error1_1`n"
}
$summary += "- Verify Executables: $(if ($phase1_2) { '✅ PASS' } else { '❌ FAIL' })`n`n"
if ($phase1_2) {
$summary += "**Phase 2: Server Initialization**`n"
$summary += "- Initialize Cluster: $(if ($phase2_1) { '✅ PASS' } else { '❌ FAIL' })`n"
if ($phase2_1) {
$summary += "- Start Server: $(if ($phase2_2) { '✅ PASS' } else { '❌ FAIL' })`n"
}
$summary += "`n"
}
if ($phase2_2) {
$summary += "**Phase 3: Database Operations**`n"
$summary += "- Test Connection: $(if ($phase3_1) { '✅ PASS' } else { '❌ FAIL' })`n"
if ($phase3_1) {
$summary += "- Create Database: $(if ($phase3_2) { '✅ PASS' } else { '❌ FAIL' })`n"
if ($phase3_2) {
$summary += "- Delete Database: $(if ($phase3_3) { '✅ PASS' } else { '❌ FAIL' })`n"
}
}
$summary += "`n"
}
# Overall status
$allPassed = $phase1_1 -and $phase1_2 -and $phase2_1 -and $phase2_2 -and $phase3_1 -and $phase3_2 -and $phase3_3
if ($allPassed) {
$summary += "**Overall Status:** ✅ ALL TESTS PASSED`n"
} else {
$summary += "**Overall Status:** ❌ SOME TESTS FAILED`n"
$summary += "`n"
$summary += "<details>`n"
$summary += "<summary>💡 Click here for troubleshooting tips</summary>`n`n"
$summary += "- Check the workflow logs for detailed error messages`n"
$summary += "- Download the test artifacts for complete logs`n"
$summary += "- Review the server logs if server startup failed`n"
$summary += "- Verify the .7z archive structure matches expected format`n"
$summary += "</details>`n"
}
Write-Host $summary
$summary | Out-File "test-results/summary.md"
- name: Upload Test Results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results-postgresql-${{ matrix.version }}
path: test-results/
retention-days: 30
- name: Upload Server Logs
if: always() && steps.start-server.outputs.success == 'true'
uses: actions/upload-artifact@v4
with:
name: server-logs-postgresql-${{ matrix.version }}
path: test-results/postgresql.log
retention-days: 7
report-results:
name: Report Test Results
needs: [detect-versions, test-postgresql]
if: always() && needs.detect-versions.outputs.has-changes == 'true' && needs.test-postgresql.result != 'cancelled'
runs-on: ubuntu-latest
steps:
- name: Download all test results
uses: actions/download-artifact@v4
with:
path: all-results
continue-on-error: true
- name: Generate PR Comment
run: |
echo "## 🐘 PostgreSQL Module Tests - Complete Results" > comment.md
echo "" >> comment.md
echo "**Test Date:** $(date -u '+%Y-%m-%d %H:%M:%S UTC')" >> comment.md
echo "" >> comment.md
# Check if artifacts exist
if [ -d "all-results" ]; then
for version_dir in all-results/test-results-postgresql-*; do
if [ -d "$version_dir" ]; then
for summary_file in "$version_dir"/summary.md; do
if [ -f "$summary_file" ]; then
cat "$summary_file" >> comment.md
echo "" >> comment.md
fi
done
fi
done
else
echo "⚠️ No test results available" >> comment.md
echo "" >> comment.md
fi
echo "---" >> comment.md
echo "" >> comment.md
echo "### 📋 Test Phases" >> comment.md
echo "" >> comment.md
echo "✅ **Completed:**" >> comment.md
echo "- Phase 1: Installation Validation (Download, Extract, Verify)" >> comment.md
echo "- Phase 2: Server Initialization (Init Cluster, Start Server)" >> comment.md
echo "- Phase 3: Database Operations (Connect, Create DB, Delete DB)" >> comment.md
echo "- Phase 4: Cleanup (Stop Server)" >> comment.md
echo "" >> comment.md
echo "_All phases of PostgreSQL testing are complete! Check artifacts for detailed logs._" >> comment.md
cat comment.md
- name: Comment on PR
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const comment = fs.readFileSync('comment.md', 'utf8');
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const botComment = comments.find(comment =>
comment.user.type === 'Bot' &&
comment.body.includes('🐘 PostgreSQL Module Tests')
);
if (botComment) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body: comment
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: comment
});
}
- name: Display Results Summary (Manual Run)
if: github.event_name == 'workflow_dispatch'
run: |
echo "## 🐘 PostgreSQL Module Tests - Manual Run Results"
echo ""
cat comment.md