diff --git a/.dockerignore b/.dockerignore index 9b1c8b1..f16335c 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1 +1,2 @@ /dist +/testdata/gotmp diff --git a/.gitignore b/.gitignore index 5ee9870..d0a8ac5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ /dist /ooni.cov -/coverage.txt +/coverage.cov +/testdata/gotmp *.njson .DS_Store diff --git a/.travis.yml b/.travis.yml index d9312eb..7566f6a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,12 +3,6 @@ dist: xenial language: minimal services: - docker -env: -- OS_NAME: linux -before_script: -- go get golang.org/x/tools/cmd/cover -- go get github.com/mattn/goveralls script: - ./build.sh _travis-${TRAVIS_OS_NAME} -- $GOPATH/bin/goveralls -coverprofile=coverage.cov -service=travis-ci - ./scripts/travis_test.sh diff --git a/Dockerfile b/Dockerfile index db8b1c6..4e4b5d7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,2 @@ FROM openobservatory/mk-alpine:latest RUN apk add --no-progress git go -ADD . /oonibuild diff --git a/build.sh b/build.sh index 5e69e7d..d01cde8 100755 --- a/build.sh +++ b/build.sh @@ -17,11 +17,7 @@ if [ "$1" = "windows" ]; then elif [ "$1" = "linux" ]; then set -x - docker build -t oonibuild . - 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" \ + $0 __docker go build $buildtags -ldflags="$ldflags" \ -o dist/linux/amd64/ooniprobe -v ./cmd/ooniprobe elif [ "$1" = "macos" ]; then @@ -47,12 +43,31 @@ elif [ "$1" = "release" ]; then echo "" 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 set -x $0 linux - # TODO -race does not work on alpine. See: https://travis-ci.org/ooni/probe-cli/builds/619631256#L962 - docker run -v `pwd`:/oonibuild -w /oonibuild -t oonibuild \ - go test -v -coverprofile=coverage.cov -coverpkg=./... ./... + # TODO -race does not work on alpine. + # See: https://travis-ci.org/ooni/probe-cli/builds/619631256#L962 + $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 set -x diff --git a/scripts/travis_test.sh b/scripts/travis_test.sh index 12575e9..fef26ca 100755 --- a/scripts/travis_test.sh +++ b/scripts/travis_test.sh @@ -2,5 +2,5 @@ set -ex -./dist/${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 onboard --yes +./dist/${TRAVIS_OS_NAME}/amd64/ooniprobe run --config testdata/testing-config.json -v --no-collector