Debian Codegraph @

.github/workflows/go.yml

raw symbols SCIP
1 name: Tests and linters
2 on:
3 push:
4 branches:
5 - master
6 pull_request:
7
8 permissions:
9 contents: read
10
11 jobs:
12 test:
13 runs-on: ubuntu-latest
14 permissions:
15 id-token: write # for uploads to codecov
16 steps:
17 - name: Checkout code
18 uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
19 with:
20 persist-credentials: false
21 - name: Install Go
22 uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
23 with:
24 go-version: 'stable'
25 - name: Run linters
26 uses: golangci/golangci-lint-action@ba0d7d2ec06a0ea1cb5fa41b2e4a3ab91d21278a # v9.3.0
27 with:
28 version: "latest"
29 - name: Run tests
30 run: go test -race -shuffle=on ./...
31 # Run the quick tests many times to try and find flakyness.
32 - name: Run tests -count=1000
33 run: go test -count=1000 -shuffle=on -short ./...
34 # Testing on 32 bit architecture to find overflow problems as found in #731.
35 - name: Run tests on 32 bit architecture
36 run: GOARCH=386 go test -count=1 -shuffle=on ./...
37
38 # mimetype does not have many unit tests for the internal/magic package but
39 # the behaviour is tested at the root package. Bellow script accounts for that.
40 # https://github.com/golang/go/issues/6909#issuecomment-232878416
41 - name: Generate coverage
42 run: |
43 export PKGS=$(go list ./...)
44 export PKGS_DELIM=$(echo "$PKGS" | paste -sd "," -)
45 go list -f '{{if or (len .TestGoFiles) (len .XTestGoFiles)}}go test -covermode count -coverprofile {{.Name}}_{{len .Imports}}_{{len .Deps}}.coverprofile -coverpkg $PKGS_DELIM {{.ImportPath}}{{end}}' $PKGS | xargs -I {} bash -c {}
46 go install github.com/wadey/gocovmerge@b5bfa59ec0adc420475f97f89b58045c721d761c
47 gocovmerge `ls *.coverprofile` > cover.out
48 rm *.coverprofile
49 - uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0
50 with:
51 fail_ci_if_error: true
52 files: cover.out
53 use_oidc: true