2022-04-05 07:30:10 +00:00
|
|
|
version: 2.1
|
|
|
|
|
|
|
|
jobs:
|
2022-04-06 15:45:46 +00:00
|
|
|
test:
|
2022-04-06 16:01:44 +00:00
|
|
|
parameters:
|
|
|
|
version:
|
|
|
|
type: string
|
2022-04-06 17:55:47 +00:00
|
|
|
default: latest
|
2022-04-05 07:30:10 +00:00
|
|
|
docker:
|
2022-04-06 16:13:12 +00:00
|
|
|
- image: cimg/go:<<parameters.version>>
|
2022-04-06 16:38:30 +00:00
|
|
|
environment:
|
2022-04-06 16:51:29 +00:00
|
|
|
TEST_RESULTS: /tmp/test-results
|
2022-04-06 17:55:47 +00:00
|
|
|
GOPATH: ${HOME}/go
|
2022-04-06 18:10:33 +00:00
|
|
|
PROJECT_PATH: ${GOPATH}/src/github.com/emirpasic/gods
|
|
|
|
working_directory: ~/src/github.com/emirpasic/gods
|
2022-04-05 07:30:10 +00:00
|
|
|
steps:
|
|
|
|
- checkout
|
|
|
|
- run:
|
2022-04-06 15:45:46 +00:00
|
|
|
name: Print Go version (go version)
|
|
|
|
command: |
|
|
|
|
go version
|
2022-04-06 17:58:14 +00:00
|
|
|
pwd
|
2022-04-06 15:45:46 +00:00
|
|
|
- run:
|
2022-04-06 16:45:45 +00:00
|
|
|
name: Run tests
|
|
|
|
command: |
|
2022-04-06 18:10:33 +00:00
|
|
|
mkdir -p $TEST_RESULTS
|
2022-04-06 16:45:45 +00:00
|
|
|
go test -v ./... | go tool test2json > $TEST_RESULTS/test2json-output.json
|
|
|
|
gotestsum --junitfile $TEST_RESULTS/gotestsum-report.xml
|
|
|
|
- run:
|
|
|
|
name: Calculate test coverage
|
2022-04-06 16:39:37 +00:00
|
|
|
command: |
|
2022-04-06 16:45:45 +00:00
|
|
|
go test -coverprofile=c.out ./... > /dev/null
|
2022-04-06 16:39:37 +00:00
|
|
|
go tool cover -html=c.out -o coverage.html
|
|
|
|
mv coverage.html $TEST_RESULTS
|
2022-04-06 09:34:35 +00:00
|
|
|
- run:
|
2022-04-06 15:45:46 +00:00
|
|
|
name: Lint (golint)
|
2022-04-06 09:34:35 +00:00
|
|
|
command: |
|
2022-04-06 16:23:04 +00:00
|
|
|
go install golang.org/x/lint/golint@latest
|
2022-04-06 16:03:28 +00:00
|
|
|
golint -set_exit_status ./...
|
2022-04-06 09:34:35 +00:00
|
|
|
- run:
|
2022-04-06 15:45:46 +00:00
|
|
|
name: Enforce formatted code (go fmt)
|
|
|
|
command: |
|
2022-04-06 16:03:28 +00:00
|
|
|
! go fmt ./... 2>&1 | read
|
2022-04-06 15:45:46 +00:00
|
|
|
- run:
|
|
|
|
name: Examine and report suspicious constructs (go vet)
|
2022-04-06 09:34:35 +00:00
|
|
|
command: |
|
2022-04-06 16:03:28 +00:00
|
|
|
go vet -v ./...
|
2022-04-06 15:45:46 +00:00
|
|
|
- run:
|
|
|
|
name: Calculate cyclomatic complexity (gocyclo)
|
|
|
|
command: |
|
2022-04-06 16:28:29 +00:00
|
|
|
go install github.com/fzipp/gocyclo/cmd/gocyclo@latest
|
2022-04-06 18:10:33 +00:00
|
|
|
gocyclo -avg -over 15 ../gods
|
2022-04-06 15:45:46 +00:00
|
|
|
- run:
|
|
|
|
name: Check for unchecked errors (errcheck)
|
|
|
|
command: |
|
|
|
|
go install github.com/kisielk/errcheck@latest
|
2022-04-06 16:03:28 +00:00
|
|
|
errcheck ./...
|
2022-04-06 16:51:29 +00:00
|
|
|
- store_artifacts:
|
|
|
|
path: /tmp/test-results
|
|
|
|
destination: raw-test-output
|
2022-04-05 07:30:10 +00:00
|
|
|
- store_test_results:
|
2022-04-06 16:51:29 +00:00
|
|
|
path: /tmp/test-results
|
2022-04-05 07:30:10 +00:00
|
|
|
|
|
|
|
workflows:
|
2022-04-06 15:45:46 +00:00
|
|
|
test:
|
2022-04-05 07:30:10 +00:00
|
|
|
jobs:
|
2022-04-06 15:45:46 +00:00
|
|
|
- test:
|
|
|
|
matrix:
|
|
|
|
parameters:
|
2022-04-06 16:12:01 +00:00
|
|
|
version: ["1.18", "1.17", "1.10"]
|