From 20717c442fa06235df9727921e2f8affb374d2a3 Mon Sep 17 00:00:00 2001 From: Julian Brost Date: Wed, 17 Jul 2024 17:09:54 +0200 Subject: [PATCH] Don't run tests with database in parallel. By default, multiple packages may be tested in parallel in different processes. Passing -p 1 reduces this to one process to prevent test cases in different packages from accessing the same database. Note that t.Parallel() only affects parallelism within one process, i.e. within the tests of one package. Co-authored-by: Alvar Penning --- .github/workflows/tests_with_database.yml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests_with_database.yml b/.github/workflows/tests_with_database.yml index 965da5b3..c84393e6 100644 --- a/.github/workflows/tests_with_database.yml +++ b/.github/workflows/tests_with_database.yml @@ -71,7 +71,12 @@ jobs: - name: Run tests timeout-minutes: 10 - run: go test -v -timeout 5m ./... + # By default, multiple packages may be tested in parallel in different + # processes. Passing -p 1 reduces this to one process to prevent test + # cases in different packages from accessing the same database. Note + # that t.Parallel() only affects parallelism within one process, i.e. + # within the tests of one package. + run: go test -v -timeout 5m -p 1 ./... postgresql: name: PostgreSQL ${{ matrix.version }} @@ -125,4 +130,9 @@ jobs: - name: Run tests timeout-minutes: 10 - run: go test -v -timeout 5m ./... + # By default, multiple packages may be tested in parallel in different + # processes. Passing -p 1 reduces this to one process to prevent test + # cases in different packages from accessing the same database. Note + # that t.Parallel() only affects parallelism within one process, i.e. + # within the tests of one package. + run: go test -v -timeout 5m -p 1 ./...