Skip to content

Upgrade all PostgreSQL minor versions + Spock version #12

Upgrade all PostgreSQL minor versions + Spock version

Upgrade all PostgreSQL minor versions + Spock version #12

Workflow file for this run

name: PR Test Latest Images
# This workflow runs on pull requests and tests the latest images
# from the internal repository to ensure they still work with any changes.
on:
pull_request:
branches:
- main
permissions:
contents: read
packages: read
env:
IMAGE_REGISTRY: ghcr.io/pgedge
PACKAGE_REPOSITORY: pgedge-postgres-internal
jobs:
# Get latest tags and generate test matrix
setup:
# Skip for forked PRs since they won't have access to internal packages
if: github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.generate.outputs.matrix }}
tags: ${{ steps.get-tags.outputs.tags }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Get latest tags
id: get-tags
run: |
set -e
TAGS=$(make latest-tags)
# Validate that tags were retrieved successfully
if [ -z "$TAGS" ]; then
echo "Error: Failed to retrieve latest tags. make latest-tags returned empty output."
exit 1
fi
echo "tags=$TAGS" >> $GITHUB_OUTPUT
echo "Latest tags: $TAGS"
- name: Generate test matrix
id: generate
run: |
# Parse tags from make output
TAGS="${{ steps.get-tags.outputs.tags }}"
IFS=',' read -ra TAG_ARRAY <<< "$TAGS"
# Test on both architectures
ARCHS=("x86" "arm")
# Build matrix JSON
matrix_items=""
for tag in "${TAG_ARRAY[@]}"; do
tag=$(echo "$tag" | xargs) # trim whitespace
# Determine flavor from tag
if [[ "$tag" == *"-minimal"* ]]; then
flavor="minimal"
elif [[ "$tag" == *"-standard"* ]]; then
flavor="standard"
else
# Default to standard if not specified
flavor="standard"
fi
for arch in "${ARCHS[@]}"; do
arch=$(echo "$arch" | xargs) # trim whitespace
# Map user-friendly arch names to runner names
if [[ "$arch" == "arm" ]] || [[ "$arch" == "arm64" ]]; then
runner="ubuntu-24.04-arm"
arch_display="arm"
elif [[ "$arch" == "x86" ]] || [[ "$arch" == "amd64" ]]; then
runner="ubuntu-latest"
arch_display="x86"
else
echo "Error: Unknown architecture '$arch'. Use 'x86' or 'arm'"
exit 1
fi
if [[ -n "$matrix_items" ]]; then
matrix_items+=","
fi
matrix_items+="{\"tag\":\"$tag\",\"arch\":\"$arch_display\",\"flavor\":\"$flavor\",\"runner\":\"$runner\"}"
done
done
echo "matrix={\"include\":[$matrix_items]}" >> $GITHUB_OUTPUT
echo "Generated matrix: {\"include\":[$matrix_items]}"
test:
# Skip for forked PRs since they won't have access to internal packages
if: github.event.pull_request.head.repo.full_name == github.repository
needs: setup
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.setup.outputs.matrix) }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
cache-dependency-path: tests/go.sum
- name: Pull image
run: |
IMAGE="${{ env.IMAGE_REGISTRY }}/${{ env.PACKAGE_REPOSITORY }}:${{ matrix.tag }}"
echo "Pulling image: $IMAGE"
docker pull "$IMAGE"
- name: Run tests
run: |
IMAGE="${{ env.IMAGE_REGISTRY }}/${{ env.PACKAGE_REPOSITORY }}:${{ matrix.tag }}"
make test-image IMAGE="$IMAGE" FLAVOR="${{ matrix.flavor }}"
results:
# Skip for forked PRs since they won't have access to internal packages
# Also use always() to ensure results are shown even if test job fails
if: github.event.pull_request.head.repo.full_name == github.repository && always()
needs: [setup, test]
runs-on: ubuntu-latest
steps:
- name: Output
run: |
echo "## Test Results" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Input | Value |" >> $GITHUB_STEP_SUMMARY
echo "|-------|-------|" >> $GITHUB_STEP_SUMMARY
echo "| Package Repository | ${{ env.PACKAGE_REPOSITORY }} |" >> $GITHUB_STEP_SUMMARY
echo "| Tags | ${{ needs.setup.outputs.tags }} |" >> $GITHUB_STEP_SUMMARY
echo "| Architectures | x86,arm |" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [[ "${{ needs.test.result }}" == "success" ]]; then
echo "✅ **All tests passed!**" >> $GITHUB_STEP_SUMMARY
else
echo "❌ **Some tests failed.** Check the job logs for details." >> $GITHUB_STEP_SUMMARY
fi