From 2270c211e0ddecc1a6ae212bef22ad7c5f2b631e Mon Sep 17 00:00:00 2001 From: Alessandro Resta Date: Wed, 18 Oct 2023 19:45:22 +0300 Subject: [PATCH] Enhance test coverage: Add Go 1.21 to matrix and enable data race detection (#119) * Expand test matrix to include Go 1.20 * Enable data race detection flag in test command * Bump GH workflow Go versions to include 1.21 * enable CGO with race test * use string for versions value to avoid rounding issue --------- Co-authored-by: Lucas Medeiros --- .github/workflows/testing.yml | 2 +- Taskfile.yaml | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 70e6ef7..9e8b95a 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -28,7 +28,7 @@ jobs: timeout-minutes: 10 strategy: matrix: - go-version: [ 1.18, 1.19 ] + go-version: [ '1.19', '1.20', '1.21' ] steps: - uses: actions/checkout@v3 diff --git a/Taskfile.yaml b/Taskfile.yaml index b3ef2d0..5832af8 100644 --- a/Taskfile.yaml +++ b/Taskfile.yaml @@ -10,6 +10,9 @@ tasks: cmds: - task: test-deps-up - task: test-run + - task: test-run + vars: + RACE: true - task: test-deps-down test-deps-up: @@ -28,7 +31,7 @@ tasks: test-run: summary: Runs tests, must have dependencies running in the docker-compose cmds: - - cmd: go test -timeout 2m -cover -coverprofile=coverage.txt -covermode=atomic ./... + - cmd: go test {{if .RACE}} -race {{end}} -timeout 2m -cover -coverprofile=coverage.txt -covermode=atomic ./... vars: PG_PQ_HOST: sh: docker-compose port pg-pq 5432 @@ -56,6 +59,7 @@ tasks: sh: docker-compose port nats 4222 env: + CGO_ENABLED: '{{if .RACE}}1{{else}}0{{end}}' HEALTH_GO_PG_PQ_DSN: 'postgres://test:test@{{.PG_PQ_HOST}}/test?sslmode=disable' HEALTH_GO_PG_PGX4_DSN: 'postgres://test:test@{{.PG_PGX4_HOST}}/test?sslmode=disable' HEALTH_GO_PG_PGX5_DSN: 'postgres://test:test@{{.PG_PGX5_HOST}}/test?sslmode=disable'