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
74 changes: 66 additions & 8 deletions .github/actions/setup-postgres/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ runs:
echo "Extension directory: $(pg_config --sharedir)/extension"
echo "Library directory: $(pg_config --pkglibdir)"

# Clone and build plpgsql_check (pinned to v2.7.11 for PG15 compatibility)
# Clone and build plpgsql_check (clone to /tmp to avoid workspace conflicts, pinned to v2.7.11)
cd /tmp
git clone --branch v2.7.11 --depth 1 https://github.com/okbob/plpgsql_check.git
cd plpgsql_check

Expand All @@ -59,30 +60,77 @@ runs:
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
# Install the pglinter extension on macOS (pgrx-based Rust extension)
- name: Install and compile pglinter
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"

# Install cargo-pgrx (version must match pglinter's pgrx dependency)
cargo install cargo-pgrx --version 0.16.1 --locked

# Determine postgres version for pgrx init
PG_VERSION=$(pg_config --version | grep -oE '[0-9]+' | head -1)
echo "PostgreSQL version: $PG_VERSION"

# Initialize pgrx for the installed PostgreSQL version
cargo pgrx init --pg${PG_VERSION} $(which pg_config)

# Clone and build pglinter (requires v1.1.0+ for get_violations API + rule_messages table)
cd /tmp
git clone --depth 1 https://github.com/pmpetit/pglinter.git
cd pglinter

# Install using pgrx
cargo pgrx install --pg-config $(which pg_config) --release

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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we fail early here? right now this would be cachted after creating extension plpgsql_check, if I'm not mistaken


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

# Create extensions in database on macOS
- name: Create extensions in database
if: runner.os == 'macOS'
shell: bash
env:
PGSERVICE: ${{ steps.postgres.outputs.service-name }}
run: |
psql -c "CREATE EXTENSION plpgsql_check;"
psql -c "CREATE EXTENSION pglinter;"

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

# For Linux, use custom Docker image with plpgsql_check and pglinter
- name: Set up Docker Buildx
if: runner.os == 'Linux'
uses: docker/setup-buildx-action@v3

# For Linux, use custom Docker image with plpgsql_check
- name: Build and start PostgreSQL with plpgsql_check
- name: Build PostgreSQL image with cache
if: runner.os == 'Linux'
uses: docker/build-push-action@v5
with:
context: .
load: true
tags: postgres-language-server-dev:latest
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Start PostgreSQL container
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
postgres-language-server-dev:latest
# Wait for postgres to be ready
for _ in {1..30}; do
if docker exec postgres pg_isready -U postgres; then
Expand All @@ -91,3 +139,13 @@ runs:
sleep 1
done

# Create extensions in postgres database only (NOT template1)
# This avoids polluting test databases - tests that need extensions can create them explicitly
echo "Creating extensions in postgres database..."
docker exec postgres psql -U postgres -c "CREATE SCHEMA IF NOT EXISTS extensions;"
docker exec postgres psql -U postgres -c "CREATE EXTENSION IF NOT EXISTS plpgsql_check SCHEMA extensions;"
docker exec postgres psql -U postgres -c "CREATE EXTENSION IF NOT EXISTS pglinter SCHEMA extensions;"

# Show extension status
docker exec postgres psql -U postgres -c "SELECT extname, extversion FROM pg_extension WHERE extname IN ('plpgsql_check', 'pglinter');"

17 changes: 14 additions & 3 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,26 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# we need to use the same database as we do locally for sqlx prepare to output the same hashes
- name: Build and start PostgreSQL with plpgsql_check
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build PostgreSQL image with cache
uses: docker/build-push-action@v5
with:
context: .
load: true
tags: postgres-language-server-dev:latest
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Start PostgreSQL
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
postgres-language-server-dev:latest
# Wait for postgres to be ready
for _ in {1..30}; do
if docker exec postgres pg_isready -U postgres; then
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,5 @@ site/

biome-main/
.review/
pglinter_repo/
.review/

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading