mirror of
https://github.com/FlipsideCrypto/dcrd.git
synced 2026-02-06 10:56:47 +00:00
travis: drop docker and test directly
This commit is contained in:
parent
599480f5c5
commit
8f48f1802b
52
.travis.yml
52
.travis.yml
@ -1,23 +1,35 @@
|
||||
language: go
|
||||
go:
|
||||
- 1.x
|
||||
|
||||
sudo: required
|
||||
services:
|
||||
- docker
|
||||
|
||||
sudo: false
|
||||
env:
|
||||
- GOVERSION=1.11
|
||||
- GOVERSION=1.12
|
||||
|
||||
before_install:
|
||||
- chmod +x ./run_tests.sh
|
||||
|
||||
install: true
|
||||
|
||||
cache:
|
||||
directories:
|
||||
- ~/.cache
|
||||
|
||||
- GO111MODULE=on
|
||||
matrix:
|
||||
include:
|
||||
- os: linux
|
||||
go: 1.12.x
|
||||
cache:
|
||||
directories:
|
||||
- $HOME/.cache/go-build
|
||||
- $HOME/gopath/pkg/mod
|
||||
- os: linux
|
||||
go: 1.11.x
|
||||
cache:
|
||||
directories:
|
||||
- $HOME/.cache/go-build
|
||||
- $HOME/gopath/pkg/mod
|
||||
- os: osx
|
||||
go: 1.12.x
|
||||
cache:
|
||||
directories:
|
||||
- $HOME/.cache/go-build
|
||||
- $HOME/gopath/pkg/mod
|
||||
- os: osx
|
||||
go: 1.11.x
|
||||
cache:
|
||||
directories:
|
||||
- $HOME/Library/Caches/go-build
|
||||
- $HOME/gopath/pkg/mod
|
||||
install:
|
||||
- go get -v github.com/golangci/golangci-lint/cmd/golangci-lint
|
||||
script:
|
||||
- ./run_tests.sh docker
|
||||
- env GO111MODULE=on go build ./...
|
||||
- env GO111MODULE=on ./run_tests.sh
|
||||
|
||||
94
run_tests.sh
94
run_tests.sh
@ -1,13 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# usage:
|
||||
# ./run_tests.sh # local, go 1.12
|
||||
# GOVERSION=1.11 ./run_tests.sh # local, go 1.11
|
||||
# ./run_tests.sh docker # docker, go 1.12
|
||||
# GOVERSION=1.11 ./run_tests.sh docker # docker, go 1.11
|
||||
# ./run_tests.sh podman # podman, go 1.12
|
||||
# GOVERSION=1.11 ./run_tests.sh podman # podman, go 1.11
|
||||
|
||||
set -ex
|
||||
|
||||
# The script does automatic checking on a Go package and its sub-packages,
|
||||
@ -22,66 +14,38 @@ set -ex
|
||||
# golangci-lint (github.com/golangci/golangci-lint) is used to run each each
|
||||
# static checker.
|
||||
|
||||
# To run on docker on windows, symlink /mnt/c to /c and then execute the script
|
||||
# from the repo path under /c. See:
|
||||
# https://github.com/Microsoft/BashOnWindows/issues/1854
|
||||
# for more details.
|
||||
|
||||
# Default GOVERSION
|
||||
[[ ! "$GOVERSION" ]] && GOVERSION=1.12
|
||||
REPO=dcrd
|
||||
|
||||
testrepo () {
|
||||
GO=go
|
||||
go version
|
||||
|
||||
$GO version
|
||||
# binary needed for RPC tests
|
||||
env CC=gcc go build
|
||||
cp "$REPO" "$GOPATH/bin/"
|
||||
|
||||
# binary needed for RPC tests
|
||||
env CC=gcc $GO build
|
||||
cp "$REPO" "$GOPATH/bin/"
|
||||
# run tests on all modules
|
||||
ROOTPATH=$(go list -m)
|
||||
ROOTPATHPATTERN=$(echo $ROOTPATH | sed 's/\\/\\\\/g' | sed 's/\//\\\//g')
|
||||
MODPATHS=$(go list -m all | grep "^$ROOTPATHPATTERN" | cut -d' ' -f1)
|
||||
for module in $MODPATHS; do
|
||||
echo "==> ${module}"
|
||||
env CC=gcc go test -short -tags rpctest ${module}/...
|
||||
|
||||
# run tests on all modules
|
||||
ROOTPATH=$($GO list -m)
|
||||
ROOTPATHPATTERN=$(echo $ROOTPATH | sed 's/\\/\\\\/g' | sed 's/\//\\\//g')
|
||||
MODPATHS=$($GO list -m all | grep "^$ROOTPATHPATTERN" | cut -d' ' -f1)
|
||||
for module in $MODPATHS; do
|
||||
echo "==> ${module}"
|
||||
env CC=gcc $GO test -short -tags rpctest ${module}/...
|
||||
# check linters
|
||||
MODNAME=$(echo $module | sed -E -e "s/^$ROOTPATHPATTERN//" \
|
||||
-e 's,^/,,' -e 's,/v[0-9]+$,,')
|
||||
if [ -z "$MODNAME" ]; then
|
||||
MODNAME=.
|
||||
fi
|
||||
(cd $MODNAME && \
|
||||
golangci-lint run --build-tags=rpctest --disable-all --deadline=10m \
|
||||
--enable=gofmt \
|
||||
--enable=gosimple \
|
||||
--enable=unconvert \
|
||||
--enable=ineffassign \
|
||||
--enable=govet \
|
||||
--enable=misspell \
|
||||
)
|
||||
done
|
||||
|
||||
# check linters
|
||||
MODNAME=$(echo $module | sed -E -e "s/^$ROOTPATHPATTERN//" \
|
||||
-e 's,^/,,' -e 's,/v[0-9]+$,,')
|
||||
if [ -z "$MODNAME" ]; then
|
||||
MODNAME=.
|
||||
fi
|
||||
(cd $MODNAME && \
|
||||
golangci-lint run --build-tags=rpctest --disable-all --deadline=10m \
|
||||
--enable=gofmt \
|
||||
--enable=gosimple \
|
||||
--enable=unconvert \
|
||||
--enable=ineffassign \
|
||||
--enable=govet \
|
||||
--enable=misspell \
|
||||
)
|
||||
done
|
||||
|
||||
echo "------------------------------------------"
|
||||
echo "Tests completed successfully!"
|
||||
}
|
||||
|
||||
DOCKER=
|
||||
[[ "$1" == "docker" || "$1" == "podman" ]] && DOCKER=$1
|
||||
if [ ! "$DOCKER" ]; then
|
||||
testrepo
|
||||
exit
|
||||
fi
|
||||
|
||||
# use Travis cache with docker
|
||||
DOCKER_IMAGE_TAG=decred-golang-builder-$GOVERSION
|
||||
$DOCKER pull decred/$DOCKER_IMAGE_TAG
|
||||
|
||||
$DOCKER run --rm -it -v $(pwd):/src:Z decred/$DOCKER_IMAGE_TAG /bin/bash -c "\
|
||||
rsync -ra --filter=':- .gitignore' \
|
||||
/src/ /go/src/github.com/decred/$REPO/ && \
|
||||
cd github.com/decred/$REPO/ && \
|
||||
env GOVERSION=$GOVERSION GO111MODULE=on bash run_tests.sh"
|
||||
echo "------------------------------------------"
|
||||
echo "Tests completed successfully!"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user