Setup PostgreSQL for Linux, Windows and macOS using GitHub Actions
GitHub Actions is a CI/CD platform that is widely used among open-source software hosted on GitHub. If you happened to host your software there, you may end up needing a SQL server to test your application. PostgreSQL is the most common choice nowadays.
As of today (Nov 24, 2021), there's only one action on the marketplace to setup a PostgreSQL server for Linux, Windows and macOS action runners. If you among those who want to test their software on all major platforms, you have no option but to use ikalnytskyi/action-setup-postgres. Below is the typical usage example:
steps:
- name: Setup PostgreSQL
uses: ikalnytskyi/action-setup-postgres@v4
id: postgres
- name: Run tests using connection URI
env:
CONNECTION_STR: ${{ steps.postgres.outputs.connection-uri }}
run: pytest -vv tests/
- name: Run tests using connection kv-string
env:
CONNECTION_STR: service=${{ steps.postgres.outputs.service-name }}
run: pytest -vv tests/
So why use that exact action and no other?
- Runs on Linux, macOS and Windows action runners.
- Adds PostgreSQL client applications to
PATH
. - Uses PostgreSQL binaries baked into GitHub Actions Runner Images.
- Easy to prove that it DOES NOT contain malicious code.