Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 87 additions & 0 deletions .github/actions/setup-postgres/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: Setup Postgres
description: Setup Postgres across operating systems
inputs:
postgres-version:
description: Postgres Version
default: 15

runs:
using: composite
steps:
# For Windows and macOS, use the action since
# PostgreSQL Docker image doesn't support Windows containers and
# macOS runners do not support Docker
- name: Setup postgres (Windows)
if: runner.os == 'Windows' || runner.os == 'macOS'
id: postgres
uses: ikalnytskyi/action-setup-postgres@v7
with:
postgres-version: ${{ inputs.postgres-version }}
username: postgres
password: postgres
database: postgres
port: 5432

# Install the pglpgsql_check extension on macOS (Part 1)
- name: Install and compile plpgsql_check
if: runner.os == 'macOS'
shell: bash
run: |
# First, ensure we're using the same PostgreSQL that the action installed
export PATH="$(pg_config --bindir):$PATH"

# Verify we're targeting the right PostgreSQL installation
echo "PostgreSQL version: $(pg_config --version)"
echo "Extension directory: $(pg_config --sharedir)/extension"
echo "Library directory: $(pg_config --pkglibdir)"

# Clone and build plpgsql_check
git clone https://github.com/okbob/plpgsql_check.git
cd plpgsql_check

# Clean and compile
make USE_PGXS=1 clean
make USE_PGXS=1 all

# Install (may need sudo depending on permissions)
sudo make USE_PGXS=1 install

# Verify installation
echo "Extension control files:"
ls -la "$(pg_config --sharedir)/extension/" | grep plpgsql || echo "No plpgsql_check found"

echo "Extension library files:"
ls -la "$(pg_config --pkglibdir)/" | grep plpgsql || echo "No plpgsql_check library found"

# Install the pglpgsql_check extension on macOS (Part 2)
- name: Create extension in database
if: runner.os == 'macOS'
shell: bash
env:
PGSERVICE: ${{ steps.postgres.outputs.service-name }}
run: |
psql -c "CREATE EXTENSION plpgsql_check;"

# Verify installation
psql -c "SELECT extname, extversion FROM pg_extension WHERE extname = 'plpgsql_check';"

# For Linux, use custom Docker image with plpgsql_check
- name: Build and start PostgreSQL with plpgsql_check
if: runner.os == 'Linux'
shell: bash
run: |
docker build -t postgres-plpgsql-check:latest .
docker run -d --name postgres \
-e POSTGRES_USER=postgres \
-e POSTGRES_PASSWORD=postgres \
-e POSTGRES_DB=postgres \
-p 5432:5432 \
postgres-plpgsql-check:latest
# Wait for postgres to be ready
for _ in {1..30}; do
if docker exec postgres pg_isready -U postgres; then
break
fi
sleep 1
done

35 changes: 4 additions & 31 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ jobs:
# use the same images we use for compiling
- os: windows-2022
- os: ubuntu-22.04
- os: macos-14
steps:
- name: Checkout PR branch
uses: actions/checkout@v4
Expand All @@ -163,37 +164,9 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# For Linux, use custom Docker image with plpgsql_check
- name: Build and start PostgreSQL with plpgsql_check
if: runner.os == 'Linux'
run: |
docker build -t postgres-plpgsql-check:latest .
docker run -d --name postgres \
-e POSTGRES_USER=postgres \
-e POSTGRES_PASSWORD=postgres \
-e POSTGRES_DB=postgres \
-p 5432:5432 \
postgres-plpgsql-check:latest
# Wait for postgres to be ready
for _ in {1..30}; do
if docker exec postgres pg_isready -U postgres; then
break
fi
sleep 1
done
# For Windows, use the action since PostgreSQL Docker image doesn't support Windows containers
- name: Setup postgres (Windows)
if: runner.os == 'Windows'
id: postgres
uses: ikalnytskyi/action-setup-postgres@v7
- name: Print Roles
run: |
if [[ "$RUNNER_OS" == "Linux" ]]; then
docker exec postgres psql -U postgres -c "select rolname from pg_roles;"
else
psql ${{ steps.postgres.outputs.connection-uri }} -c "select rolname from pg_roles;"
fi
shell: bash
- name: Setup Postgres
uses: ./.github/actions/setup-postgres

- name: Run tests
run: cargo test --workspace

Expand Down
35 changes: 2 additions & 33 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,39 +67,8 @@ jobs:
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu

# The Docker runtime is not available by default on macOS runners
# https://github.com/actions/runner-images/issues/2150
# https://blog.netnerds.net/2022/11/docker-macos-github-actions/
- name: Install Docker
if: runner.os == 'macOS'
run: |
brew install docker
colima start

# For Linux, use custom Docker image with plpgsql_check
- name: Build and start PostgreSQL with plpgsql_check
if: runner.os == 'macOS' || runner.os == 'Linux'
run: |
docker build -t postgres-plpgsql-check:latest .
docker run -d --name postgres \
-e POSTGRES_USER=postgres \
-e POSTGRES_PASSWORD=postgres \
-e POSTGRES_DB=postgres \
-p 5432:5432 \
postgres-plpgsql-check:latest
# Wait for postgres to be ready
for _ in {1..30}; do
if docker exec postgres pg_isready -U postgres; then
break
fi
sleep 1
done

# For Windows, use the action since PostgreSQL Docker image doesn't support Windows containers
- name: Setup postgres (Windows)
if: runner.os == 'Windows'
id: postgres
uses: ikalnytskyi/action-setup-postgres@v7
- name: Setup Postgres
uses: ./.github/actions/setup-postgres

- name: 🧪 Run Tests
run: cargo test --release
Expand Down