| 1 |
version: 2 |
| 2 |
|
| 3 |
templates: |
| 4 |
golang-template: &golang-template |
| 5 |
docker: |
| 6 |
- image: ghcr.io/hugelgupf/vmtest/ci-amd64:main |
| 7 |
working_directory: /home/circleci/go/src/github.com/hugelgupf/p9 |
| 8 |
environment: |
| 9 |
- CGO_ENABLED: 0 |
| 10 |
|
| 11 |
workflows: |
| 12 |
version: 2 |
| 13 |
build: |
| 14 |
jobs: |
| 15 |
- tidy |
| 16 |
- build: |
| 17 |
requires: |
| 18 |
- tidy |
| 19 |
- test: |
| 20 |
requires: |
| 21 |
- tidy |
| 22 |
|
| 23 |
jobs: |
| 24 |
tidy: |
| 25 |
<<: *golang-template |
| 26 |
steps: |
| 27 |
- checkout |
| 28 |
- run: go env |
| 29 |
- run: go vet ./... |
| 30 |
- run: |
| 31 |
name: go mod tidy |
| 32 |
command: | |
| 33 |
go mod tidy |
| 34 |
go mod verify |
| 35 |
git status |
| 36 |
if [[ -n "$(git status --porcelain .)" ]]; then |
| 37 |
echo 'go.mod/go.sum is out-of-date: run `go mod tidy` in the right module directories (see git status) and then check in the changes' |
| 38 |
echo 'If `go mod tidy` results in no changes, make sure you are using the latest relase of Go' |
| 39 |
git status --porcelain . |
| 40 |
exit 1 |
| 41 |
fi |
| 42 |
- run: |
| 43 |
name: gofmt |
| 44 |
command: test -z "$(gofmt -s -l $(find -name '*.go'))" |
| 45 |
|
| 46 |
test: |
| 47 |
<<: *golang-template |
| 48 |
steps: |
| 49 |
- checkout |
| 50 |
- run: go env |
| 51 |
- run: go test -timeout 15m -v ./... |
| 52 |
- run: CGO_ENABLED=1 go test -race -timeout 15m -v ./... |
| 53 |
|
| 54 |
build: |
| 55 |
<<: *golang-template |
| 56 |
steps: |
| 57 |
- checkout |
| 58 |
- run: go env |
| 59 |
- run: | |
| 60 |
go install github.com/mitchellh/gox@latest |
| 61 |
|
| 62 |
# Exclude darwin/arm(64?). |
| 63 |
gox -osarch="darwin/amd64" ./... |
| 64 |
gox -parallel=2 -os="windows linux freebsd netbsd openbsd solaris" -arch="386 amd64 arm arm64 ppc64 ppc64le s390x mips mipsle mips64 mips64le" ./... |