Skip to content
Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Latest commit

 

History

13 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitHub Action to Install and Configure PostgreSQL

⚖️ PostgreSQL 🎬 Action 🧪 Test

This action sets up a PostgreSQL server on the GitHub runner VM to enable the automated testing of PGXN extensions against multiple versions of PostgreSQL. It currently supports:

  • Ubuntu Runners with PGDG-installed PostgreSQL 8.2-19
  • macOS Runners with Homebrew-installed PostreSQL 14-18
  • Windows Runners with Chocolatey-installed PostreSQL 10-181

In addition, each provies the pgxn client to simplify installing additional extension from [PGXN]. The Windows images also adds sudo to minimize differences in the commands required to install extension on each OS.

Example workflow:

name: 🧪 Test
on:
  push:
defaults:
  run: { shell: bash }
jobs:
  test:
    strategy:
      fail-fast: false
      matrix:
        include:
          - { img: 🐧, os: Ubuntu,  vm: latest,    arch: amd64, pg: 19 }
          - { img: 🐧, os: Ubuntu,  vm: latest,    arch: amd64, pg: 18 }
          - { img: 🐧, os: Ubuntu,  vm: latest,    arch: amd64, pg: 17 }
          - { img: 🐧, os: Ubuntu,  vm: 26.04-arm, arch: arm64, pg: 19 }
          - { img: 🐧, os: Ubuntu,  vm: 26.04-arm, arch: arm64, pg: 18 }
          - { img: 🐧, os: Ubuntu,  vm: 26.04-arm, arch: arm64, pg: 17 }
          - { img: 🍎, os: macOS,   vm: latest,    arch: arm64, pg: 18 }
          - { img: 🍎, os: macOS,   vm: latest,    arch: arm64, pg: 17 }
          - { img: 🍎, os: macOS,   vm: 26-intel,  arch: amd64, pg: 18 }
          - { img: 🍎, os: macOS,   vm: 26-intel,  arch: amd64, pg: 17 }
          - { img: 🪟, os: Windows, vm: latest,    arch: amd64, pg: 18 }
          - { img: 🪟, os: Windows, vm: latest,    arch: amd64, pg: 17 }
          - { img: 🪟, os: Windows, vm: 11-arm,    arch: arm64, pg: 18 }
          - { img: 🪟, os: Windows, vm: 11-arm,    arch: arm64, pg: 17 }
    name: ${{ matrix.img }} ${{ matrix.arch }} 🐘 ${{ matrix.pg }}
    runs-on: ${{ matrix.os }}-${{ matrix.vm }}
    steps:
      - name: Check out the repo
        uses: actions/checkout@v7
      - name: Start Postgres ${{ matrix.pg }}
        uses: pgxn/postgres-action@v0
        with: { version: "${{ matrix.pg }}" }
      - name: Build
        run:  make
      - name: Install
        run:  sudo make
      - name: Test
        id:   test
        run:  make installcheck
      - name: Show Diffs
        if:   failure() && steps.test.outcome == 'failure'
        run:  find . -name regression.diffs -exec cat {} +

Input Parameters

This action takes the following parameters:

Key Type Default Description
version string "" PostgreSQL major version to install
port integer 55432 Port on which PostreSQL should listen for cnnections
packages string "" List of additional OS-specific packages to install
start boolean true Start the PostgreSQL server after installing
encoding string "" The encoding to use for databases in the cluster
locale string "" The locale to use for databases in the cluster

The locale and encoding inputs have no effect if start is false.

For the packages input, use package names specific to the OS packaging system:

Environment Variables

On completion, this action sets the following environment variables:

Variable Value Description
PGUSER "postgres" The name of the PostgreSQL super user
PGPORT input.port The port on which the PostgreSQL server listens
PG_CONFIG varies The path pg_config, used to build extensions

Path

On completion, this action adds the path to the PostgreSQLl executables to the PATH environment varaible, so they can be called without needing to know the full, often version-specific path.

Prior Art/Inspirations

Footnotes

  1. Although currently the standard include $(PGXS) pattern in Makefiles appears to work only on Postgres 17 and later, because pg_config --pgxs returns a path with spaces in it on earlier versions.

About

Install, configure, and start a local Postgres cluster

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages