| 1 |
name: Build |
| 2 |
|
| 3 |
on: |
| 4 |
push: |
| 5 |
branches: [ master ] |
| 6 |
pull_request: |
| 7 |
branches: [ master ] |
| 8 |
workflow_dispatch: |
| 9 |
|
| 10 |
jobs: |
| 11 |
test: |
| 12 |
strategy: |
| 13 |
matrix: |
| 14 |
go-version: [1.16.x, 1.17.x, 1.18.x, 1.19.x, 1.20.x, 1.21.x, 1.22.x, 1.23.x, 1.24.x, 1.25.x, 1.26.x, tip] |
| 15 |
full-tests: [false] |
| 16 |
include: |
| 17 |
- go-version: 1.27.x |
| 18 |
full-tests: true |
| 19 |
|
| 20 |
runs-on: ubuntu-latest |
| 21 |
|
| 22 |
steps: |
| 23 |
- name: Setup go |
| 24 |
run: | |
| 25 |
curl -sL https://raw.githubusercontent.com/maxatome/install-go/v3.8/install-go.pl | |
| 26 |
perl - ${{ matrix.go-version }} $HOME/go |
| 27 |
|
| 28 |
- name: Checkout code |
| 29 |
uses: actions/checkout@v2 |
| 30 |
|
| 31 |
- name: Miscellaneous checks |
| 32 |
if: matrix.full-tests |
| 33 |
run: | |
| 34 |
./tools/gen_funcs.pl |
| 35 |
git diff --exit-code |
| 36 |
if fgrep 'interface{}' $(find . -name '*.go' -not -name any.go -not -name any_test.go); then |
| 37 |
echo '*** At least one interface{} occurrence found. Use any instead.' |
| 38 |
false |
| 39 |
fi |
| 40 |
|
| 41 |
- name: Linting |
| 42 |
if: matrix.full-tests |
| 43 |
run: | |
| 44 |
curl -sL https://golangci-lint.run/install.sh | |
| 45 |
sh -s -- -b $HOME/go/bin v2.13.0 |
| 46 |
$HOME/go/bin/golangci-lint run |
| 47 |
|
| 48 |
- name: Testing |
| 49 |
continue-on-error: ${{ matrix.go-version == 'tip' }} |
| 50 |
run: | |
| 51 |
go version |
| 52 |
go env |
| 53 |
if [ -z "$(go env GOPROXY)" ]; then |
| 54 |
echo "Fix empty GOPROXY" |
| 55 |
export GOPROXY=https://proxy.golang.org,direct |
| 56 |
fi |
| 57 |
if [ ${{ matrix.full-tests }} = true ]; then |
| 58 |
cover_flags="-coverpkg=./... -covermode=atomic -test.gocoverdir=$(pwd)/cov/" |
| 59 |
GO_TEST_BASE_FLAGS="$cover_flags"base |
| 60 |
GO_TEST_SAFE_FLAGS="$cover_flags"safe |
| 61 |
GO_TEST_RACE_FLAGS="$cover_flags"race |
| 62 |
GO_TEST_RACE_SAFE_FLAGS="$cover_flags"race-safe |
| 63 |
GO_TEST_RACE_CGO_FLAGS="$cover_flags"cgo |
| 64 |
mkdir -p cov/base cov/safe cov/race cov/race-safe cov/cgo |
| 65 |
fi |
| 66 |
|
| 67 |
export GORACE="halt_on_error=1" |
| 68 |
echo "BASE ===========================================" |
| 69 |
go test ./... $GO_TEST_BASE_FLAGS |
| 70 |
echo "SAFE ==============================================" |
| 71 |
go test -tags safe ./... $GO_TEST_SAFE_FLAGS |
| 72 |
echo "RACE ==============================================" |
| 73 |
go test -race ./... $GO_TEST_RACE_FLAGS |
| 74 |
echo "RACE + SAFE =======================================" |
| 75 |
go test -race -tags safe ./... $GO_TEST_RACE_SAFE_FLAGS |
| 76 |
echo "RACE + CGO (internal/spew only) ===================" |
| 77 |
CGO_ENABLED=1 \ |
| 78 |
go test -race -tags testcgo ./internal/spew $GO_TEST_RACE_CGO_FLAGS |
| 79 |
|
| 80 |
- name: Reporting |
| 81 |
if: matrix.full-tests |
| 82 |
env: |
| 83 |
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 84 |
run: | |
| 85 |
dirs= |
| 86 |
for d in cov/*; do |
| 87 |
[ -d $d ] && dirs="${dirs:+"$dirs,"}$d" |
| 88 |
done |
| 89 |
go tool covdata textfmt -i="$dirs" -o /dev/fd/1 | |
| 90 |
egrep -v '^github\.com/maxatome/go-testdeep/internal/(json/parser\.go:|test/)' > coverage.out |
| 91 |
go install github.com/mattn/[email protected] |
| 92 |
goveralls -coverprofile=coverage.out -service=github |