diff --git a/.github/workflows/cicd.yaml b/.github/workflows/cicd.yaml index b382af95..09dd8c11 100644 --- a/.github/workflows/cicd.yaml +++ b/.github/workflows/cicd.yaml @@ -12,7 +12,7 @@ permissions: contents: read jobs: - checks: + check-default: runs-on: ubuntu-22.04 steps: - name: Check out repository @@ -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 @@ -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]') diff --git a/internal/app/subsystems/aio/store/postgres/postgres.go b/internal/app/subsystems/aio/store/postgres/postgres.go index 05979dba..0ebe9622 100644 --- a/internal/app/subsystems/aio/store/postgres/postgres.go +++ b/internal/app/subsystems/aio/store/postgres/postgres.go @@ -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` diff --git a/internal/app/subsystems/aio/store/postgres/postgres_test.go b/internal/app/subsystems/aio/store/postgres/postgres_test.go index 02a9519f..2912ef01 100644 --- a/internal/app/subsystems/aio/store/postgres/postgres_test.go +++ b/internal/app/subsystems/aio/store/postgres/postgres_test.go @@ -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 {