Skip to content

cmd/worklog: add postgres support #500

cmd/worklog: add postgres support

cmd/worklog: add postgres support #500

Workflow file for this run

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'
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
- 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 -run 'Test(Amendments|Continuation|DashboardData)$' ./cmd/worklog
- 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
postgres-test:
runs-on: ubuntu-latest
services:
postgres:
image: postgres
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
POSTGRES_DB: postgres
options: >-
--name postgres
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
env:
PGHOST: localhost
PGPORT: 5432
PGUSER: test_user
PGPASSWORD: password
POSTGRES_DB: postgres
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: non-Go linux dependencies
run: |
sudo apt-get update
sudo apt-get install -qq libudev-dev
- name: set up postgres users
run: |
psql --host $PGHOST \
--username="postgres" \
--dbname="postgres" \
--command="CREATE USER $PGUSER PASSWORD '$PGPASSWORD'" \
--command="ALTER USER $PGUSER CREATEDB" \
--command="CREATE USER ${PGUSER}_ro PASSWORD '$PGPASSWORD'" \
--command="\du"
echo ${PGHOST}:${PGPORT}:*:${PGUSER}:${PGPASSWORD} >> ~/.pgpass
echo ${PGHOST}:${PGPORT}:*:${PGUSER}_ro:${PGPASSWORD} >> ~/.pgpass
chmod 600 ~/.pgpass
- name: unit tests postgres
run: |
go test ./cmd/worklog/pgstore
- name: integration tests postgres
uses: nick-fields/retry@v3
with:
timeout_minutes: 10
max_attempts: 3
command: |
go test -tags postgres -run TestScripts/worklog_load_postgres