Skip to content

Commit

Permalink
Add postgres service to CI and fix timeout promises query (#335)
Browse files Browse the repository at this point in the history
* Update cicd.yaml

* Update cicd.yaml

* Update cicd.yaml

* Update cicd.yaml

* Update cicd.yaml

* fix(postgres): unit tests

---------

Co-authored-by: Gabriel Guerra <[email protected]>
  • Loading branch information
guergabo and Gabriel Guerra committed May 23, 2024
1 parent 4a10c16 commit b88be18
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 4 deletions.
46 changes: 43 additions & 3 deletions .github/workflows/cicd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ permissions:
contents: read

jobs:
checks:
check-default:
runs-on: ubuntu-22.04
steps:
- name: Check out repository
Expand Down Expand Up @@ -61,8 +61,48 @@ jobs:
with:
token: ${{ secrets.CODECOV_TOKEN }}
codecov_yml_path: codecov.yml

check-postgres:
runs-on: ubuntu-22.04

env:
TEST_AIO_SUBSYSTEMS_STORE_CONFIG_POSTGRES_HOST: "localhost"
TEST_AIO_SUBSYSTEMS_STORE_CONFIG_POSTGRES_PORT: "5432"
TEST_AIO_SUBSYSTEMS_STORE_CONFIG_POSTGRES_USERNAME: "username"
TEST_AIO_SUBSYSTEMS_STORE_CONFIG_POSTGRES_PASSWORD: "password"
TEST_AIO_SUBSYSTEMS_STORE_CONFIG_POSTGRES_DATABASE: "resonate_test"

services:
postgres:
image: postgres:15
env:
POSTGRES_USER: ${{ env.TEST_AIO_SUBSYSTEMS_STORE_CONFIG_POSTGRES_USERNAME }}
POSTGRES_PASSWORD: ${{ env.TEST_AIO_SUBSYSTEMS_STORE_CONFIG_POSTGRES_PASSWORD }}
POSTGRES_DB: ${{ env.TEST_AIO_SUBSYSTEMS_STORE_CONFIG_POSTGRES_DATABASE }}
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432

steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: false

# Intentionally not using nix here as a workout around to the postgres dependency.
- name: Run go test and generate coverage report
run: |
go test -v -coverprofile=coverage.out -coverpkg=./... ./...
test:
check-linearizability:
runs-on: ubuntu-22.04
steps:
- name: Check out repository
Expand Down Expand Up @@ -99,7 +139,7 @@ jobs:
scan:
name: semgrep
runs-on: ubuntu-20.04
needs: [test]
needs: [check-default, check-postgres, check-linearizability]
env:
SEMGREP_RULES: "auto semgrep.yml"
if: (github.actor != 'dependabot[bot]')
Expand Down
3 changes: 2 additions & 1 deletion internal/app/subsystems/aio/store/postgres/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,8 @@ const (
state = CASE
WHEN tags ->> 'resonate:timeout' IS NOT NULL AND tags ->> 'resonate:timeout' = 'true' THEN 2
ELSE 16
END
END,
completed_on = timeout
WHERE
state = 1 AND timeout <= $1`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ func TestPostgresStore(t *testing.T) {
Username: username,
Password: password,
Database: database,
Query: map[string]string{"sslmode": "disable"},
TxTimeout: 250 * time.Millisecond,
}, 1)
if err != nil {
Expand Down

0 comments on commit b88be18

Please sign in to comment.