From ee385db5bf5b6a778240b4269079d173c193192a Mon Sep 17 00:00:00 2001 From: psteinroe Date: Wed, 20 Aug 2025 08:46:28 +0200 Subject: [PATCH 01/13] chore: run tests on macos in ci --- .github/workflows/pull_request.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 20218378..20095150 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -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 @@ -163,9 +164,18 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # 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 == 'Linux' + if: runner.os == 'macOS' || runner.os == 'Linux' run: | docker build -t postgres-plpgsql-check:latest . docker run -d --name postgres \ From 15bb299a0f1dc19032d1d3958b7f25d52ea1d49a Mon Sep 17 00:00:00 2001 From: psteinroe Date: Wed, 20 Aug 2025 09:32:38 +0200 Subject: [PATCH 02/13] progress --- .github/workflows/pull_request.yml | 50 +++++++++++++++++++++++++----- 1 file changed, 43 insertions(+), 7 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 20095150..a4d013c8 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -164,18 +164,53 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # 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 + # for macOS, setup postgres manually since the macos runner does not support docker + - name: Setup PostgreSQL 15 + if: runner.os == 'macOS' + uses: ikalnytskyi/action-setup-postgres@v7 + id: postgres + with: + postgres-version: "15" + username: postgres + password: postgres + database: test_db + port: 5432 + + - name: Install PostgreSQL development tools if: runner.os == 'macOS' run: | - brew install docker - colima start + brew install postgresql@15 + echo "/opt/homebrew/opt/postgresql@15/bin" >> $GITHUB_PATH + + - name: Compile and install plpgsql_check + if: runner.os == 'macOS' + run: | + # Clone the official repository + git clone https://github.com/okbob/plpgsql_check.git + cd plpgsql_check + + # Clean any previous build artifacts + make USE_PGXS=1 clean + + # Compile the extension + make USE_PGXS=1 all + + # Install extension files (requires sudo) + sudo make USE_PGXS=1 install + + - name: Create extension in database + if: runner.os == 'macOS' + 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 == 'macOS' || runner.os == 'Linux' + if: runner.os == 'Linux' run: | docker build -t postgres-plpgsql-check:latest . docker run -d --name postgres \ @@ -191,6 +226,7 @@ jobs: 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' From 8583dba9343eaa4061974afa40543a8f86812f88 Mon Sep 17 00:00:00 2001 From: psteinroe Date: Wed, 20 Aug 2025 09:33:09 +0200 Subject: [PATCH 03/13] progress --- .github/workflows/pull_request.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index a4d013c8..34dfe69e 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -165,6 +165,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # for macOS, setup postgres manually since the macos runner does not support docker + # Part 1 - name: Setup PostgreSQL 15 if: runner.os == 'macOS' uses: ikalnytskyi/action-setup-postgres@v7 @@ -176,12 +177,14 @@ jobs: database: test_db port: 5432 + # Part 2 - name: Install PostgreSQL development tools if: runner.os == 'macOS' run: | brew install postgresql@15 echo "/opt/homebrew/opt/postgresql@15/bin" >> $GITHUB_PATH + # Part 3 - name: Compile and install plpgsql_check if: runner.os == 'macOS' run: | From 4fcf8f71f4dbb815f80a2f61201456a014893cde Mon Sep 17 00:00:00 2001 From: psteinroe Date: Wed, 20 Aug 2025 09:35:57 +0200 Subject: [PATCH 04/13] progress --- .github/workflows/pull_request.yml | 34 +++++++----------------------- 1 file changed, 8 insertions(+), 26 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 34dfe69e..d0ce81d3 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -164,27 +164,21 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # for macOS, setup postgres manually since the macos runner does not support docker - # Part 1 - - name: Setup PostgreSQL 15 - if: runner.os == 'macOS' - uses: ikalnytskyi/action-setup-postgres@v7 + # 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 - with: - postgres-version: "15" - username: postgres - password: postgres - database: test_db - port: 5432 + uses: ikalnytskyi/action-setup-postgres@v7 - # Part 2 + # Install the pglpgsql_check extension on macOS (Part 1) - name: Install PostgreSQL development tools if: runner.os == 'macOS' run: | brew install postgresql@15 echo "/opt/homebrew/opt/postgresql@15/bin" >> $GITHUB_PATH - # Part 3 + # Install the pglpgsql_check extension on macOS (Part 2) - name: Compile and install plpgsql_check if: runner.os == 'macOS' run: | @@ -201,6 +195,7 @@ jobs: # Install extension files (requires sudo) sudo make USE_PGXS=1 install + # Install the pglpgsql_check extension on macOS (Part 3) - name: Create extension in database if: runner.os == 'macOS' env: @@ -230,19 +225,6 @@ jobs: 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: Run tests run: cargo test --workspace From b014571ba5a6441c010b9ae4547a6b1d73c06aba Mon Sep 17 00:00:00 2001 From: psteinroe Date: Wed, 20 Aug 2025 09:38:54 +0200 Subject: [PATCH 05/13] progress --- .github/workflows/pull_request.yml | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index d0ce81d3..59a3620a 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -176,25 +176,38 @@ jobs: if: runner.os == 'macOS' run: | brew install postgresql@15 - echo "/opt/homebrew/opt/postgresql@15/bin" >> $GITHUB_PATH + echo "/opt/homebrew/opt/postgresql@15/bin" >> "$GITHUB_PATH" # Install the pglpgsql_check extension on macOS (Part 2) - - name: Compile and install plpgsql_check + - name: Install and compile plpgsql_check if: runner.os == 'macOS' run: | - # Clone the official repository + # 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 any previous build artifacts + # Clean and compile make USE_PGXS=1 clean - - # Compile the extension make USE_PGXS=1 all - # Install extension files (requires sudo) + # 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 3) - name: Create extension in database if: runner.os == 'macOS' From 244a37a1f87bc949d0cf01f93b9d57ae1e7e9650 Mon Sep 17 00:00:00 2001 From: psteinroe Date: Wed, 20 Aug 2025 09:41:24 +0200 Subject: [PATCH 06/13] progress --- .github/workflows/pull_request.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 59a3620a..4d784e03 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -170,6 +170,8 @@ jobs: if: runner.os == 'Windows' || runner.os == 'macOS' id: postgres uses: ikalnytskyi/action-setup-postgres@v7 + with: + postgres-version: "15" # Install the pglpgsql_check extension on macOS (Part 1) - name: Install PostgreSQL development tools From 13f33f4469586c0badf575d536ea0718ce21ea78 Mon Sep 17 00:00:00 2001 From: psteinroe Date: Wed, 20 Aug 2025 09:48:59 +0200 Subject: [PATCH 07/13] progress --- .github/actions/setup-postgres/action.yml | 83 +++++++++++++++++++++++ .github/workflows/pull_request.yml | 77 +-------------------- .github/workflows/release.yml | 35 +--------- 3 files changed, 87 insertions(+), 108 deletions(-) create mode 100644 .github/actions/setup-postgres/action.yml diff --git a/.github/actions/setup-postgres/action.yml b/.github/actions/setup-postgres/action.yml new file mode 100644 index 00000000..f9c5a334 --- /dev/null +++ b/.github/actions/setup-postgres/action.yml @@ -0,0 +1,83 @@ +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' + 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' + 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' + 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 + diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 4d784e03..72474527 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -164,81 +164,8 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # 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: "15" - - # Install the pglpgsql_check extension on macOS (Part 1) - - name: Install PostgreSQL development tools - if: runner.os == 'macOS' - run: | - brew install postgresql@15 - echo "/opt/homebrew/opt/postgresql@15/bin" >> "$GITHUB_PATH" - - # Install the pglpgsql_check extension on macOS (Part 2) - - name: Install and compile plpgsql_check - if: runner.os == 'macOS' - 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 3) - - name: Create extension in database - if: runner.os == 'macOS' - 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' - 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 + - name: Setup Postgres + uses: ./.github/actions/setup-postgres - name: Run tests run: cargo test --workspace diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4b427889..c2f8eeff 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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 From 036e5b4e5424b6678bc0a710c7c59d3aa3430882 Mon Sep 17 00:00:00 2001 From: psteinroe Date: Wed, 20 Aug 2025 09:50:25 +0200 Subject: [PATCH 08/13] progress --- .github/actions/setup-postgres/action.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/actions/setup-postgres/action.yml b/.github/actions/setup-postgres/action.yml index f9c5a334..8d6e42a1 100644 --- a/.github/actions/setup-postgres/action.yml +++ b/.github/actions/setup-postgres/action.yml @@ -24,6 +24,7 @@ runs: # 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" @@ -65,6 +66,7 @@ runs: # 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 \ From 44b4be0b70ac46fd8730fa8b5de3a5a05f413781 Mon Sep 17 00:00:00 2001 From: psteinroe Date: Wed, 20 Aug 2025 09:51:36 +0200 Subject: [PATCH 09/13] progress --- .github/actions/setup-postgres/action.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/actions/setup-postgres/action.yml b/.github/actions/setup-postgres/action.yml index 8d6e42a1..12c04357 100644 --- a/.github/actions/setup-postgres/action.yml +++ b/.github/actions/setup-postgres/action.yml @@ -55,6 +55,7 @@ runs: # 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: | From 581be625143a860c335a2b7b5763f4a3f99d5a0e Mon Sep 17 00:00:00 2001 From: psteinroe Date: Wed, 20 Aug 2025 09:53:15 +0200 Subject: [PATCH 10/13] progress --- .github/actions/setup-postgres/action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/actions/setup-postgres/action.yml b/.github/actions/setup-postgres/action.yml index 12c04357..57c37500 100644 --- a/.github/actions/setup-postgres/action.yml +++ b/.github/actions/setup-postgres/action.yml @@ -23,7 +23,7 @@ runs: # Install the pglpgsql_check extension on macOS (Part 1) - name: Install and compile plpgsql_check - if: runner.os == 'macOS' + if: runner.os == 'Windows' || runner.os == 'macOS' shell: bash run: | # First, ensure we're using the same PostgreSQL that the action installed @@ -54,7 +54,7 @@ runs: # Install the pglpgsql_check extension on macOS (Part 2) - name: Create extension in database - if: runner.os == 'macOS' + if: runner.os == 'Windows' || runner.os == 'macOS' shell: bash env: PGSERVICE: ${{ steps.postgres.outputs.service-name }} From 6542bfb8da6032b4228d94c6b35b1a10cb942757 Mon Sep 17 00:00:00 2001 From: psteinroe Date: Wed, 20 Aug 2025 09:54:58 +0200 Subject: [PATCH 11/13] progress --- .github/actions/setup-postgres/action.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/actions/setup-postgres/action.yml b/.github/actions/setup-postgres/action.yml index 57c37500..3a0ed5ea 100644 --- a/.github/actions/setup-postgres/action.yml +++ b/.github/actions/setup-postgres/action.yml @@ -8,8 +8,8 @@ inputs: 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 + # For Windows and macOS, use the action + # 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 @@ -21,7 +21,7 @@ runs: database: postgres port: 5432 - # Install the pglpgsql_check extension on macOS (Part 1) + # Install the pglpgsql_check extension on macOS and Windows (Part 1) - name: Install and compile plpgsql_check if: runner.os == 'Windows' || runner.os == 'macOS' shell: bash @@ -52,7 +52,7 @@ 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) + # Install the pglpgsql_check extension on macOS and Windows (Part 2) - name: Create extension in database if: runner.os == 'Windows' || runner.os == 'macOS' shell: bash From 1bd191b462cc6815535f0ffd10e5477524a9c276 Mon Sep 17 00:00:00 2001 From: psteinroe Date: Wed, 20 Aug 2025 10:13:37 +0200 Subject: [PATCH 12/13] progress --- .github/actions/setup-postgres/action.yml | 71 ++++++++++++++--------- 1 file changed, 42 insertions(+), 29 deletions(-) diff --git a/.github/actions/setup-postgres/action.yml b/.github/actions/setup-postgres/action.yml index 3a0ed5ea..2b2df480 100644 --- a/.github/actions/setup-postgres/action.yml +++ b/.github/actions/setup-postgres/action.yml @@ -4,13 +4,14 @@ inputs: postgres-version: description: Postgres Version default: 15 - + install-plpgsql-check: + description: Install plpgsql_check extension (only supported on macOS/Linux) + default: 'true' runs: using: composite steps: # For Windows and macOS, use the action - # PostgreSQL Docker image doesn't support Windows containers and macOS runners do not support Docker - - name: Setup postgres (Windows) + - name: Setup postgres (Windows/macOS) if: runner.os == 'Windows' || runner.os == 'macOS' id: postgres uses: ikalnytskyi/action-setup-postgres@v7 @@ -21,50 +22,63 @@ runs: database: postgres port: 5432 - # Install the pglpgsql_check extension on macOS and Windows (Part 1) - - name: Install and compile plpgsql_check - if: runner.os == 'Windows' || runner.os == 'macOS' + # Install build tools on Windows if extension is requested + - name: Install build tools (Windows) + if: runner.os == 'Windows' && inputs.install-plpgsql-check == 'true' + shell: bash + run: | + echo "Installing MSYS2 for compilation..." + choco install msys2 -y --timeout=600 + + # Initialize MSYS2 and install build tools + C:/tools/msys64/usr/bin/bash.exe -lc "pacman -S --noconfirm base-devel mingw-w64-x86_64-toolchain git" + + # Install and compile plpgsql_check (Windows with build tools) + - name: Install and compile plpgsql_check (Windows) + if: runner.os == 'Windows' && inputs.install-plpgsql-check == 'true' + shell: bash + run: | + export PATH="/c/tools/msys64/usr/bin:$PATH" + + echo "PostgreSQL version: $(pg_config --version)" + echo "Extension directory: $(pg_config --sharedir)/extension" + + git clone https://github.com/okbob/plpgsql_check.git + cd plpgsql_check + + # Use MSYS2 make with full paths + C:/tools/msys64/usr/bin/make.exe USE_PGXS=1 clean + C:/tools/msys64/usr/bin/make.exe USE_PGXS=1 all + C:/tools/msys64/usr/bin/make.exe USE_PGXS=1 install + + # Install and compile plpgsql_check (macOS) + - name: Install and compile plpgsql_check (macOS) + if: runner.os == 'macOS' && inputs.install-plpgsql-check == 'true' 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 and Windows (Part 2) + # Create extension in database (Windows/macOS) - name: Create extension in database - if: runner.os == 'Windows' || runner.os == 'macOS' + if: (runner.os == 'Windows' || runner.os == 'macOS') && inputs.install-plpgsql-check == 'true' 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';" + psql -c "CREATE EXTENSION plpgsql_check;" || echo "Extension creation failed - this is expected if compilation failed" + psql -c "SELECT extname, extversion FROM pg_extension WHERE extname = 'plpgsql_check';" || echo "Extension not available" - # For Linux, use custom Docker image with plpgsql_check + # For Linux, use custom Docker image - name: Build and start PostgreSQL with plpgsql_check if: runner.os == 'Linux' shell: bash @@ -76,11 +90,10 @@ runs: -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 - From 157654a80c29c83206b57b375d94154b52910082 Mon Sep 17 00:00:00 2001 From: psteinroe Date: Wed, 20 Aug 2025 10:21:53 +0200 Subject: [PATCH 13/13] progress --- .github/actions/setup-postgres/action.yml | 74 ++++++++++------------- 1 file changed, 31 insertions(+), 43 deletions(-) diff --git a/.github/actions/setup-postgres/action.yml b/.github/actions/setup-postgres/action.yml index 2b2df480..a07fdfbc 100644 --- a/.github/actions/setup-postgres/action.yml +++ b/.github/actions/setup-postgres/action.yml @@ -4,14 +4,14 @@ inputs: postgres-version: description: Postgres Version default: 15 - install-plpgsql-check: - description: Install plpgsql_check extension (only supported on macOS/Linux) - default: 'true' + runs: using: composite steps: - # For Windows and macOS, use the action - - name: Setup postgres (Windows/macOS) + # 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 @@ -22,63 +22,50 @@ runs: database: postgres port: 5432 - # Install build tools on Windows if extension is requested - - name: Install build tools (Windows) - if: runner.os == 'Windows' && inputs.install-plpgsql-check == 'true' - shell: bash - run: | - echo "Installing MSYS2 for compilation..." - choco install msys2 -y --timeout=600 - - # Initialize MSYS2 and install build tools - C:/tools/msys64/usr/bin/bash.exe -lc "pacman -S --noconfirm base-devel mingw-w64-x86_64-toolchain git" - - # Install and compile plpgsql_check (Windows with build tools) - - name: Install and compile plpgsql_check (Windows) - if: runner.os == 'Windows' && inputs.install-plpgsql-check == 'true' - shell: bash - run: | - export PATH="/c/tools/msys64/usr/bin:$PATH" - - echo "PostgreSQL version: $(pg_config --version)" - echo "Extension directory: $(pg_config --sharedir)/extension" - - git clone https://github.com/okbob/plpgsql_check.git - cd plpgsql_check - - # Use MSYS2 make with full paths - C:/tools/msys64/usr/bin/make.exe USE_PGXS=1 clean - C:/tools/msys64/usr/bin/make.exe USE_PGXS=1 all - C:/tools/msys64/usr/bin/make.exe USE_PGXS=1 install - - # Install and compile plpgsql_check (macOS) - - name: Install and compile plpgsql_check (macOS) - if: runner.os == 'macOS' && inputs.install-plpgsql-check == 'true' + # 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 - # Create extension in database (Windows/macOS) + # 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 == 'Windows' || runner.os == 'macOS') && inputs.install-plpgsql-check == 'true' + if: runner.os == 'macOS' shell: bash env: PGSERVICE: ${{ steps.postgres.outputs.service-name }} run: | - psql -c "CREATE EXTENSION plpgsql_check;" || echo "Extension creation failed - this is expected if compilation failed" - psql -c "SELECT extname, extversion FROM pg_extension WHERE extname = 'plpgsql_check';" || echo "Extension not available" + 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 + # For Linux, use custom Docker image with plpgsql_check - name: Build and start PostgreSQL with plpgsql_check if: runner.os == 'Linux' shell: bash @@ -90,10 +77,11 @@ runs: -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 +