cmd/worklog: add postgres support #461
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
pull_request: | |
branches: [ master ] | |
jobs: | |
build: | |
strategy: | |
fail-fast: false | |
matrix: | |
go-version: [1.22.x] | |
platform: | |
- ubuntu-latest | |
- macos-latest | |
runs-on: ${{ matrix.platform }} | |
env: | |
DISPLAY: ':99.0' | |
XDG_SESSION_TYPE: 'x11' | |
EGL_PLATFORM: 'x11' | |
PGHOST: localhost | |
PGPORT: 5432 | |
PGDATABASE: test_database | |
PGUSER: test_user | |
PGPASSWORD: password | |
steps: | |
- name: install Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: ${{ matrix.go-version }} | |
- name: checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 1 | |
- name: govulncheck | |
run: | | |
go run golang.org/x/vuln/cmd/govulncheck@latest | |
- name: non-Go linux dependencies | |
if: matrix.platform == 'ubuntu-latest' | |
run: | | |
sudo apt-get update | |
sudo apt-get install -qq libudev-dev libxss-dev libxres-dev gcc pkg-config libwayland-dev libx11-dev libx11-xcb-dev libxkbcommon-x11-dev libgles2-mesa-dev libegl1-mesa-dev libffi-dev libxcursor-dev libvulkan-dev xdotool x11-utils xdotool i3-wm | |
echo "DISPLAY=${DISPLAY}" | |
# Start a virtual frame buffer and wait a bit for it to be ready... | |
Xvfb :99 -screen 0 1920x1024x24 & | |
sleep 1 | |
# and a window manager to get focus for testers and wait again. | |
i3 & | |
sleep 1 | |
# add PostgreSQL binaries to PATH | |
echo "$(pg_config --bindir)" >> $GITHUB_PATH | |
export PGHOST="${RUNNER_TEMP}/postgres" | |
export PGDATA="$PGHOST/pgdata" | |
mkdir -p "$PGDATA" | |
export PWFILE="${RUNNER_TEMP}/pwfile" | |
echo "postgres" > "$PWFILE" | |
/usr/lib/postgresql/14/bin/initdb --pgdata="$PGDATA" --username="postgres" --pwfile="$PWFILE" | |
echo "unix_socket_directories = '$PGHOST'" >> "$PGDATA/postgresql.conf" | |
pg_ctl start | |
psql --host "$PGHOST" --username="postgres" --dbname="postgres" --command="CREATE USER $PGUSER PASSWORD '$PGPASSWORD'" --command="\du" | |
createdb --owner="$PGUSER" --username="postgres" "$PGDATABASE" | |
- name: unit tests | |
uses: nick-fields/retry@v3 | |
with: | |
timeout_minutes: 10 | |
max_attempts: 3 | |
command: | | |
go test ./rpc ./internal/... ./cmd/*/api ./cmd/worklog/store | |
go test ./cmd/worklog/pgstore | |
go test -run 'Test(Amendments|Continuation|DashboardData)$' ./cmd/worklog | |
- name: unit tests postgres | |
if: matrix.platform == 'ubuntu-latest' | |
uses: nick-fields/retry@v3 | |
with: | |
timeout_minutes: 10 | |
max_attempts: 3 | |
command: | | |
go test ./cmd/worklog/pgstore | |
- name: integration tests | |
uses: nick-fields/retry@v3 | |
with: | |
timeout_minutes: 10 | |
max_attempts: 3 | |
command: | | |
go test . | |
go test -p=1 -run TestDaemon ./cmd/* -verbose_log | |
go test -run TestDaemon ./cmd/watcher -dynamic_timezone=false -verbose_log | |
go test -run TestDaemon ./cmd/watcher -dynamic_timezone=true -verbose_log | |
- name: no xorg watcher | |
if: matrix.platform == 'ubuntu-latest' | |
run: | | |
sudo apt-get remove -qq libxss-dev libxres-dev libx11-dev | |
sudo apt-get autoremove -qq | |
go build -tags no_xorg ./cmd/watcher |