From b0077f34ad3782ae47094bda9fd292f485cc8f20 Mon Sep 17 00:00:00 2001 From: Dan Kortschak Date: Sat, 21 Sep 2024 18:37:11 +0930 Subject: [PATCH] ci: add postgres support --- .github/workflows/ci.yml | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 877f377..6317202 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,6 +20,11 @@ jobs: 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 @@ -40,7 +45,7 @@ jobs: 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 + 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 postgresql echo "DISPLAY=${DISPLAY}" # Start a virtual frame buffer and wait a bit for it to be ready... Xvfb :99 -screen 0 1920x1024x24 & @@ -56,8 +61,22 @@ jobs: 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' + run: | + sudo -u postgres 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" + + go test ./cmd/worklog/pgstore + - name: integration tests uses: nick-fields/retry@v3 with: