CircleCI-Public / go-orb

https://circleci.com/orbs/registry/orb/circleci/go
MIT License
9 stars 36 forks source link

`go/test` with no parameters fails on versions > 1.7.1 #79

Open milesarmstrong opened 1 year ago

milesarmstrong commented 1 year ago

Hiya! My job looks like:

  test_golang:
    executor:
      name: go/default
      tag: "1.21"
    steps:
      - checkout:
      - go/load-cache
      - go/mod-download
      - go/save-cache
      - go/test

and I get this error

+ go test -count=1 -coverprofile=cover-source.out -p 1 -covermode=set ./... -coverpkg=./... -race -failfast -short -v
-covermode must be "atomic", not "set", when -race is enabled

Exited with code exit status 1

on any version > 1.7.1

eadderley commented 10 months ago

Hi, I think I know why this is. In the test.sh script, -race is being set as if race: true was in the config when the race env var itself is empty. In fact, that's the case with all of those if statements. Race's is simply the only one that's causing failures, because it's true requires an extra config step. The others being wrong just means people's tests aren't necessarily running how they want them to.

In our config we set covermode: atomic and everything worked again. Not sure if that's of use to everyone, however.

BenHalsteadTEG commented 2 months ago

We are also affected by this issue. This seems to be caused by a mistake in the underlying script which can be seen here: https://circleci.com/developer/orbs/orb/circleci/go#commands-test

The if statements are using the -n flag like:

if [ -n "$ORB_VAL_RACE" ]; then
    set -- "$@" -race
fi

ORB_VAL_RACE is either set to 0 (false) or 1 (true), but the -n flag on if checks for null/zero length strings so these blocks are always executed.

dixonwhitmire commented 2 months ago

I'm affected by this issue as well.