travis: run goveralls inside the docker container

Factor code and reorganize location of go cache and go paths such
that subsequent invocations reuse both dirs.
This commit is contained in:
Simone Basso 2019-12-26 18:36:41 +01:00
parent 1e16f28634
commit 6cccfeb97a
6 changed files with 28 additions and 18 deletions

View File

@ -1 +1,2 @@
/dist /dist
/testdata/gotmp

3
.gitignore vendored
View File

@ -1,5 +1,6 @@
/dist /dist
/ooni.cov /ooni.cov
/coverage.txt /coverage.cov
/testdata/gotmp
*.njson *.njson
.DS_Store .DS_Store

View File

@ -3,12 +3,6 @@ dist: xenial
language: minimal language: minimal
services: services:
- docker - docker
env:
- OS_NAME: linux
before_script:
- go get golang.org/x/tools/cmd/cover
- go get github.com/mattn/goveralls
script: script:
- ./build.sh _travis-${TRAVIS_OS_NAME} - ./build.sh _travis-${TRAVIS_OS_NAME}
- $GOPATH/bin/goveralls -coverprofile=coverage.cov -service=travis-ci
- ./scripts/travis_test.sh - ./scripts/travis_test.sh

View File

@ -1,3 +1,2 @@
FROM openobservatory/mk-alpine:latest FROM openobservatory/mk-alpine:latest
RUN apk add --no-progress git go RUN apk add --no-progress git go
ADD . /oonibuild

View File

@ -17,11 +17,7 @@ if [ "$1" = "windows" ]; then
elif [ "$1" = "linux" ]; then elif [ "$1" = "linux" ]; then
set -x set -x
docker build -t oonibuild . $0 __docker go build $buildtags -ldflags="$ldflags" \
docker run -v `pwd`:/oonibuild -w /oonibuild -t --cap-drop=all \
--user `id -u`:`id -g` -e 'GOCACHE=/tmp/go/cache' -e 'GOPATH=/tmp/go/path' \
oonibuild \
go build $buildtags -ldflags="$ldflags" \
-o dist/linux/amd64/ooniprobe -v ./cmd/ooniprobe -o dist/linux/amd64/ooniprobe -v ./cmd/ooniprobe
elif [ "$1" = "macos" ]; then elif [ "$1" = "macos" ]; then
@ -47,12 +43,31 @@ elif [ "$1" = "release" ]; then
echo "" echo ""
echo "Now sign ooniprobe_checksums.txt and upload it along with tarballs to GitHub" echo "Now sign ooniprobe_checksums.txt and upload it along with tarballs to GitHub"
elif [ "$1" = "__docker" ]; then
set -x
shift
docker build -t oonibuild .
docker run -v `pwd`:/oonibuild \
-w /oonibuild \
-t \
--cap-drop=all \
--user `id -u`:`id -g` \
-e 'GOCACHE=/oonibuild/testdata/gotmp/cache' \
-e 'GOPATH=/oonibuild/testdata/gotmp/path' \
-e "TRAVIS_JOB_ID=$TRAVIS_JOB_ID" \
-e "TRAVIS_PULL_REQUEST=$TRAVIS_PULL_REQUEST" \
oonibuild "$@"
elif [ "$1" = "_travis-linux" ]; then elif [ "$1" = "_travis-linux" ]; then
set -x set -x
$0 linux $0 linux
# TODO -race does not work on alpine. See: https://travis-ci.org/ooni/probe-cli/builds/619631256#L962 # TODO -race does not work on alpine.
docker run -v `pwd`:/oonibuild -w /oonibuild -t oonibuild \ # See: https://travis-ci.org/ooni/probe-cli/builds/619631256#L962
go test -v -coverprofile=coverage.cov -coverpkg=./... ./... $0 __docker go get -v golang.org/x/tools/cmd/cover
$0 __docker go get -v github.com/mattn/goveralls
$0 __docker go test -v -coverprofile=coverage.cov -coverpkg=./... ./...
$0 __docker /oonibuild/testdata/gotmp/path/bin/goveralls \
-coverprofile=coverage.cov -service=travis-ci
elif [ "$1" = "_travis-osx" ]; then elif [ "$1" = "_travis-osx" ]; then
set -x set -x

View File

@ -2,5 +2,5 @@
set -ex set -ex
./dist/${OS_NAME}/amd64/ooniprobe onboard --yes ./dist/${TRAVIS_OS_NAME}/amd64/ooniprobe onboard --yes
./dist/${OS_NAME}/amd64/ooniprobe run --config testdata/testing-config.json -v --no-collector ./dist/${TRAVIS_OS_NAME}/amd64/ooniprobe run --config testdata/testing-config.json -v --no-collector