git » summer » commit 5ad3c6d

test: Add a script to run tests with race detection

author Alberto Bertogli
2024-04-07 10:51:43 UTC
committer Alberto Bertogli
2024-04-07 10:55:24 UTC
parent 02813d6687cc6e24d45bb9996a52efc3066921f7

test: Add a script to run tests with race detection

This patch adds a script to run the tests with race detection enabled.

The binary is built with `-race`, and then the standard tests are run
against it.

This will help catch concurrency issues in the parallel code.

.github/workflows/tests.yaml +5 -1
test/race.sh +7 -0

diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml
index 96461be..6874a35 100644
--- a/.github/workflows/tests.yaml
+++ b/.github/workflows/tests.yaml
@@ -12,7 +12,7 @@ on:
 jobs:
   tests:
     runs-on: ubuntu-latest
-    timeout-minutes: 5
+    timeout-minutes: 7
     steps:
       - uses: actions/checkout@v3
       - uses: actions/setup-go@v3
@@ -25,6 +25,10 @@ jobs:
         run: ./test/cover.sh
         timeout-minutes: 2
 
+      - name: race
+        run: ./test/race.sh
+        timeout-minutes: 5
+
       - name: upload coverage codecov
         uses: codecov/codecov-action@v3
         with:
diff --git a/test/race.sh b/test/race.sh
new file mode 100755
index 0000000..cbb5dfb
--- /dev/null
+++ b/test/race.sh
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+set -e
+cd "$(realpath "$(dirname "$0")" )"
+
+export BUILDARGS="-race"
+exec ./test.sh