This repository has been archived by the owner on Aug 7, 2023. It is now read-only.
forked from decred/dcrd
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Run testing and linting in a Dockerfile.
This simplifies the use of travis significantly and should speed things up as parts of the setup are now done once when the docker image is created. Tests may be run locally (no docker) by using the 'local' arg to run_tests.sh.
- Loading branch information
1 parent
e7b128a
commit 9987b02
Showing
7 changed files
with
193 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
*~ | ||
vendor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,13 @@ | ||
dist: trusty | ||
sudo: required | ||
|
||
language: go | ||
go: | ||
- 1.7.x | ||
- 1.8.x | ||
sudo: false | ||
install: | ||
- go get -v github.com/Masterminds/glide | ||
- glide install | ||
- go install -v . ./cmd/... | ||
- go get -v github.com/alecthomas/gometalinter | ||
- gometalinter --install | ||
|
||
services: | ||
- docker | ||
|
||
env: | ||
- GOVERSION = 1.7 | ||
- GOVERSION = 1.8 | ||
|
||
script: | ||
- export PATH=$PATH:$HOME/gopath/bin | ||
- ./goclean.sh | ||
- ./run_tests.sh $GOVERSION |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#decred-golang-builder-1.7 | ||
FROM golang:1.7.6 | ||
|
||
LABEL description="Decred golang builder image" | ||
LABEL version="1.0" | ||
LABEL maintainer "[email protected]" | ||
|
||
ENV TERM linux | ||
ENV USER build | ||
|
||
# create user | ||
RUN adduser --disabled-password --gecos '' build | ||
|
||
# update base distro & install build tooling | ||
ENV DEBIAN_FRONTEND noninteractive | ||
|
||
RUN apt-get update && \ | ||
apt-get install -qy rsync | ||
|
||
# create directory for build artifacts, adjust user permissions | ||
RUN mkdir /release && \ | ||
chown $USER /release | ||
|
||
# create directory to get source from | ||
RUN mkdir /src && \ | ||
chown $USER /src && \ | ||
mkdir -p /go/src/github.com/decred/dcrd && \ | ||
mkdir -p /go/src/github.com/decred/dcrwallet && \ | ||
mkdir -p /go/src/github.com/decred/dcrctl && \ | ||
mkdir -p /go/src/github.com/decred/dcrrpcclient && \ | ||
chown -R $USER /go/src/github.com/decred | ||
|
||
# switch user | ||
USER $USER | ||
ENV HOME /home/$USER | ||
|
||
#Get deps | ||
ENV GLIDE_TAG v0.12.3 | ||
ENV GOMETALINTER_TAG v1.2.1 | ||
|
||
WORKDIR /go/src | ||
RUN go get -v github.com/Masterminds/glide && \ | ||
cd /go/src/github.com/Masterminds/glide && \ | ||
git checkout $GLIDE_TAG && \ | ||
make build && \ | ||
mv glide `which glide` && \ | ||
go get -v github.com/alecthomas/gometalinter && \ | ||
cd /go/src/github.com/alecthomas/gometalinter && \ | ||
git checkout $GOMETALINTER_TAG && \ | ||
go install && \ | ||
gometalinter --install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#decred-golang-builder-1.8 | ||
FROM golang:1.8.3 | ||
|
||
LABEL description="Decred golang builder image" | ||
LABEL version="1.0" | ||
LABEL maintainer "[email protected]" | ||
|
||
ENV TERM linux | ||
ENV USER build | ||
|
||
# create user | ||
RUN adduser --disabled-password --gecos '' build | ||
|
||
# update base distro & install build tooling | ||
ENV DEBIAN_FRONTEND noninteractive | ||
|
||
RUN apt-get update && \ | ||
apt-get install -qy rsync | ||
|
||
# create directory for build artifacts, adjust user permissions | ||
RUN mkdir /release && \ | ||
chown $USER /release | ||
|
||
# create directory to get source from | ||
RUN mkdir /src && \ | ||
chown $USER /src && \ | ||
mkdir -p /go/src/github.com/decred/dcrd && \ | ||
mkdir -p /go/src/github.com/decred/dcrwallet && \ | ||
mkdir -p /go/src/github.com/decred/dcrctl && \ | ||
mkdir -p /go/src/github.com/decred/dcrrpcclient && \ | ||
chown -R $USER /go/src/github.com/decred | ||
|
||
# switch user | ||
USER $USER | ||
ENV HOME /home/$USER | ||
|
||
#Get deps | ||
ENV GLIDE_TAG v0.12.3 | ||
ENV GOMETALINTER_TAG v1.2.1 | ||
|
||
WORKDIR /go/src | ||
RUN go get -v github.com/Masterminds/glide && \ | ||
cd /go/src/github.com/Masterminds/glide && \ | ||
git checkout $GLIDE_TAG && \ | ||
make build && \ | ||
mv glide `which glide` && \ | ||
go get -v github.com/alecthomas/gometalinter && \ | ||
cd /go/src/github.com/alecthomas/gometalinter && \ | ||
git checkout $GOMETALINTER_TAG && \ | ||
go install && \ | ||
gometalinter --install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/usr/bin/env bash | ||
set -ex | ||
|
||
# The script does automatic checking on a Go package and its sub-packages, | ||
# including: | ||
# 1. gofmt (http://golang.org/cmd/gofmt/) | ||
# 2. go vet (http://golang.org/cmd/vet) | ||
# 3. unconvert (https://github.com/mdempsky/unconvert) | ||
# 4. race detector (http://blog.golang.org/race-detector) | ||
|
||
# gometalinter (github.com/alecthomas/gometalinter) 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=${1:-1.8} | ||
REPO=dcrd | ||
|
||
TESTCMD="test -z \"\$(gometalinter --disable-all \ | ||
--enable=gofmt \ | ||
--enable=vet \ | ||
--enable=unconvert \ | ||
--vendor \ | ||
--deadline=10m . | tee /dev/stderr)\"&& \ | ||
env GORACE='halt_on_error=1' go test -short -race \$(glide novendor)" | ||
|
||
if [ $GOVERSION == "local" ]; then | ||
eval $TESTCMD | ||
exit | ||
fi | ||
|
||
DOCKER_IMAGE_TAG=decred-golang-builder-$GOVERSION | ||
|
||
docker pull decred/$DOCKER_IMAGE_TAG | ||
|
||
docker run --rm -it -v $(pwd):/src decred/$DOCKER_IMAGE_TAG /bin/bash -c "\ | ||
rsync -ra --filter=':- .gitignore' \ | ||
/src/ /go/src/github.com/decred/$REPO/ && \ | ||
cd github.com/decred/$REPO/ && \ | ||
glide install && \ | ||
go install \$(glide novendor) && \ | ||
$TESTCMD | ||
" | ||
|
||
echo "------------------------------------------" | ||
echo "Tests complete." |