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
snippet source | anchor# 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 }}-pg17Start an instance and pass its connection string to the tests:
yaml
snippet source | anchor- name: Start Postgres
run: |
dotnet tool install --global pgembed
pgembed start app --version 17
echo "ConnectionStrings__App=$(pgembed connstr app --format npgsql)" >> "$GITHUB_ENV"yaml
snippet source | anchor# tests using InstanceName = "app" attach to it; anything else reads ConnectionStrings__App
- name: Test
run: dotnet testTest against several versions at once:
yaml
snippet source | anchor- name: Test on every supported major
run: |
pgembed start ci --version 16,17,18
dotnet test --filter "Category=EveryVersion"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.
