From d73b4443efde8f9a88f01c08f5225bd3120a4564 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Mon, 8 Feb 2021 15:38:27 -0800 Subject: [PATCH] ci: enable -race from matrix Add a new test matrix dimension so all tests are run twice, with and without race detector. Signed-off-by: Kir Kolyshkin --- .github/workflows/test.yml | 5 +++-- Makefile | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 683977c1c..62c665d8e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,6 +21,7 @@ jobs: matrix: go-version: [1.14.x, 1.15.x, 1.16.0-rc1] rootless: ["rootless", ""] + race: ["-race", ""] steps: @@ -41,7 +42,7 @@ jobs: go-version: ${{ matrix.go-version }} - name: build - run: sudo -E PATH="$PATH" make all + run: sudo -E PATH="$PATH" make EXTRA_FLAGS="${{ matrix.race }}" all - name: install bats uses: mig4/setup-bats@v1 @@ -50,7 +51,7 @@ jobs: - name: unit test if: matrix.rootless != 'rootless' - run: sudo -E PATH="$PATH" -- make localunittest + run: sudo -E PATH="$PATH" -- make TESTFLAGS="${{ matrix.race }}" localunittest - name: add rootless user if: matrix.rootless == 'rootless' diff --git a/Makefile b/Makefile index e13d8f1d4..bb5c17c94 100644 --- a/Makefile +++ b/Makefile @@ -20,7 +20,9 @@ ifneq ($(GO111MODULE),off) endif ifeq ($(shell $(GO) env GOOS),linux) ifeq (,$(filter $(shell $(GO) env GOARCH),mips mipsle mips64 mips64le ppc64)) - GO_BUILDMODE := "-buildmode=pie" + ifeq (,$(findstring -race,$(EXTRA_FLAGS))) + GO_BUILDMODE := "-buildmode=pie" + endif endif endif GO_BUILD := $(GO) build -trimpath $(MOD_VENDOR) $(GO_BUILDMODE) $(EXTRA_FLAGS) -tags "$(BUILDTAGS)" \