Skip to content

Commit

Permalink
RE-2822: Enable go race test ENV
Browse files Browse the repository at this point in the history
  • Loading branch information
njegosrailic authored and chudilka1 committed Jul 25, 2024
1 parent 5b41615 commit e97f55f
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
4 changes: 3 additions & 1 deletion .github/workflows/pull-request-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ jobs:
actions: read
steps:
- name: ci-test
uses: smartcontractkit/.github/actions/ci-test-go@5b1046c28343660ecb84844c6fa95a66d1cdb52e # ci-test-go@0.1.2
uses: smartcontractkit/.github/actions/ci-test-go@a15f84fcc168830a5341c7f08592eed85bb34913 # ci-test-go@0.3.1
with:
# grafana inputs
metrics-job-name: ci-test
Expand All @@ -104,6 +104,7 @@ jobs:
go-cache-dep-path: "**/go.sum"
go-version-file: go.mod
go-test-cmd: make test-ci
enable-go-test-race: "true"

ci-sonarqube:
needs: [ci-lint, ci-test]
Expand All @@ -115,6 +116,7 @@ jobs:
with:
# grafana inputs
metrics-job-name: ci-sonarqube
include-lint: "true"
gc-basic-auth: ${{ secrets.GRAFANA_INTERNAL_BASIC_AUTH }}
gc-host: ${{ secrets.GRAFANA_INTERNAL_HOST }}
gc-org-id: ${{ secrets.GRAFANA_INTERNAL_TENANT_ID }}
Expand Down
39 changes: 39 additions & 0 deletions fail_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package main

import (
"errors"
"os"
"sync"
"testing"
)

func TestFail(t *testing.T) {
if testing.Short() {
t.Skip()
}
t.Fatal("fake failure")
}

func TestRace(t *testing.T) {
var v int
var wg sync.WaitGroup
wg.Add(100)
for i := 0; i < 100; i++ {
go func() {
defer wg.Done()
v++
v--
}()
}
wg.Wait()
t.Log(v)
}

func TestLint(t *testing.T) {
const ALL_CAPS = 10 // should be AllCaps

Check failure on line 33 in fail_test.go

View workflow job for this annotation

GitHub Actions / ci-lint

var-naming: don't use ALL_CAPS in Go names; use CamelCase (revive)
err := os.ErrNotExist
if err == os.ErrNotExist { // should use errors.Is

Check failure on line 35 in fail_test.go

View workflow job for this annotation

GitHub Actions / ci-lint

comparing with == will fail on wrapped errors. Use errors.Is to check for a specific error (errorlint)
err := errors.New("fake error") // shadowed variable
t.Log(err)
}
}

0 comments on commit e97f55f

Please sign in to comment.