Skip to content

In CI ​

pgembed needs no Docker, so it runs on any CI runner with .NET: Linux, macOS and Windows, including runners that cannot run containers. These steps are from a GitHub Actions workflow.

Cache the Postgres downloads:

yaml
# Postgres downloads once per version, then comes from the cache
- name: Cache Postgres binaries
  uses: actions/cache@v4
  with:
    path: ~/.cache/pgembed/binaries
    key: pgembed-${{ runner.os }}-${{ runner.arch }}-pg17
snippet source | anchor

Start an instance and pass its connection string to the tests:

yaml
- name: Start Postgres
  run: |
    dotnet tool install --global pgembed
    pgembed start app --version 17
    echo "ConnectionStrings__App=$(pgembed connstr app --format npgsql)" >> "$GITHUB_ENV"
snippet source | anchor
yaml
# tests using InstanceName = "app" attach to it; anything else reads ConnectionStrings__App
- name: Test
  run: dotnet test
snippet source | anchor

Test against several versions at once:

yaml
- name: Test on every supported major
  run: |
    pgembed start ci --version 16,17,18
    dotnet test --filter "Category=EveryVersion"
snippet source | anchor

On Linux, Postgres refuses to run as root. GitHub's hosted runners are not root; in a container job, run the tests as a normal user.

Released under the MIT License.