Run go generate in Travis (#1762)
* Fix go generate command in metrics. The previous command only worked on OS X. This one works on Linux but not OS X. Also add generate phase of test.sh. * Add mockgen to test setup. * Fix github-pr-status output. * Fix envvar style. * Set xtrace. * Fix test.sh * Fix test.sh some more. * Fix mockgen command. * Add dependencies for running `go generate`. * Add protoc-gen-go. * Fix go get command. * Fix generate. * Wait for all. * Fix generate. * Update generated pb. * Fix generate commands for vendored world. * Update documentation for new vendor style. * Update grpc package to latest. * Update caaChecker proto with latest. * Run go generate only over TESTPATHS * See if Travis passes under 1.6 * Switch back to 1.5. * Trim run command. * Run stringer from correct directory. * Move generate command. * Restore and generate * Fix path. * list contents of GOPATH. * Fix stringer by prebuilding. * Try another import path. * regenerate bcode_string. * remove excess package * pull jsha fork of protoc-gen-go that echoes * Echo protoc version. * install from source * CD back. * Go back to normal protoc-gen-go * Fix path * Move protobuf install into test/setup.sh * Move before_install to install. * Set PATH. * Follow 301 with curl. * Shuffle test order. * Swap back test order. * Restore all tests. * Restore 1.5.3 to Travis. * Remove unnecessary wait-or-exit * Generate metrics mock with latest mockgen. * Wrap TESTPATHS in curlies * Remove spurious bracket
This commit is contained in:
parent
26de87dfa2
commit
6d5348f975
14
.travis.yml
14
.travis.yml
|
|
@ -43,22 +43,20 @@ branches:
|
|||
- release
|
||||
- /^test-.*$/
|
||||
|
||||
before_install:
|
||||
# By providing our own install command we avoid Travis' default Go install
|
||||
# command, which runs `go get`. We specifically want to avoid that because we
|
||||
# want to ensure all our dependencies are vendored.
|
||||
install:
|
||||
- travis_retry test/travis-before-install.sh
|
||||
- cd $GOPATH/src/github.com/letsencrypt/boulder
|
||||
|
||||
# Override default Travis install command to prevent it from adding
|
||||
# Godeps/_workspace to GOPATH. When that happens, it hides failures that should
|
||||
# arise from importing non-vendorized paths.
|
||||
install:
|
||||
- true
|
||||
|
||||
env:
|
||||
global:
|
||||
- PATH=$HOME/bin:$PATH # protoc gets installed here
|
||||
- LETSENCRYPT_PATH=$HOME/letsencrypt
|
||||
- GO15VENDOREXPERIMENT=1
|
||||
matrix:
|
||||
- RUN="vet fmt migrations integration godep-restore errcheck"
|
||||
- RUN="vet fmt migrations integration godep-restore errcheck generate"
|
||||
# Config changes that have landed in master but not yet been applied to
|
||||
# production can be made in boulder-config-next.json.
|
||||
- RUN="integration" BOULDER_CONFIG="test/boulder-config-next.json"
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ Thanks for helping us build Boulder! This page contains requirements and guideli
|
|||
* New commits pushed to a branch invalidate previous reviews. In other words, two reviewers must give positive reviews of a branch after its most recent pushed commit.
|
||||
* You cannot review your own code.
|
||||
* If a branch contains commits from multiple authors, it needs two reviewers who are not authors of commits on that branch.
|
||||
* If a branch contains updates to files in the Godeps/ directory, the author is responsible for running tests in all updated dependencies, and commenting in the review thread that they have done so. Reviewers must not approve reviews that have changes in Godeps/ but lack a comment about tests.
|
||||
* If a branch contains updates to files in the vendor/ directory, the author is responsible for running tests in all updated dependencies, and commenting in the review thread that they have done so. Reviewers must not approve reviews that have changes in vendor/ but lack a comment about tests.
|
||||
* Review changes to or addition of tests just as rigorously as you review code changes. Consider: Do tests actually test what they mean to test? Is this the best way to test the functionality in question? Do the tests cover all the functionality in the patch, including error cases?
|
||||
* Are there new RPCs or config fields? Make sure the patch meets the Deployability rules below.
|
||||
|
||||
|
|
|
|||
|
|
@ -123,8 +123,8 @@ The full details of how the various ACME operations happen in Boulder are laid o
|
|||
Dependencies
|
||||
------------
|
||||
|
||||
All Go dependencies are vendored under the Godeps directory,
|
||||
to [make dependency management easier](https://groups.google.com/forum/m/#!topic/golang-dev/nMWoEAG55v8).
|
||||
All Go dependencies are vendored under the vendor directory,
|
||||
to [make dependency management easier](https://golang.org/cmd/go/#hdr-Vendor_Directories).
|
||||
|
||||
Local development also requires a RabbitMQ installation and MariaDB
|
||||
10 installation (see above). MariaDB should be run on port 3306 for the
|
||||
|
|
@ -145,7 +145,7 @@ go get -u github.com/cloudflare/cfssl/...
|
|||
godep update github.com/cloudflare/cfssl/...
|
||||
# Save the dependencies, rewriting any internal or external dependencies that
|
||||
# may have been added.
|
||||
godep save -r ./...
|
||||
git add Godeps
|
||||
godep save ./...
|
||||
git add Godeps vendor
|
||||
git commit
|
||||
```
|
||||
|
|
|
|||
|
|
@ -4,9 +4,8 @@
|
|||
package metrics
|
||||
|
||||
import (
|
||||
time "time"
|
||||
|
||||
gomock "github.com/golang/mock/gomock"
|
||||
time "time"
|
||||
)
|
||||
|
||||
// Mock of Statter interface
|
||||
|
|
|
|||
54
test.sh
54
test.sh
|
|
@ -77,26 +77,24 @@ function run() {
|
|||
|
||||
function run_and_comment() {
|
||||
echo "$@"
|
||||
result=$("$@" 2>&1)
|
||||
cat <<<"${result}"
|
||||
result_file=$(mktemp -t bouldertestXXXX)
|
||||
"$@" 2>&1 | tee ${result_file}
|
||||
|
||||
if [ "x${result}" == "x" ]; then
|
||||
update_status --state success
|
||||
else
|
||||
# Fail if result_file is nonempty.
|
||||
if [ -s ${result_file} ]; then
|
||||
echo "[!] FAILURE: $@"
|
||||
FAILURE=1
|
||||
update_status --state failure
|
||||
echo "[!] FAILURE: $@"
|
||||
fi
|
||||
|
||||
# If this is a travis PR run, post a comment
|
||||
if [ "x${TRAVIS}" != "x" ] && [ "${TRAVIS_PULL_REQUEST}" != "false" ] && [ -f "${GITHUB_SECRET_FILE}" ] ; then
|
||||
# If the output is non-empty, post a comment and mark this as a failure
|
||||
if [ -n "${result}" ] ; then
|
||||
echo $'```\n'${result}$'\n```' | github-pr-status --authfile $GITHUB_SECRET_FILE \
|
||||
# If this is a travis PR run, post a comment
|
||||
if [ "x${TRAVIS}" != "x" ] && [ "${TRAVIS_PULL_REQUEST}" != "false" ] && [ -f "${GITHUB_SECRET_FILE}" ] ; then
|
||||
(echo '```' ; cat ${result_file} ; echo -e '\n```') | github-pr-status --authfile $GITHUB_SECRET_FILE \
|
||||
--owner "letsencrypt" --repo "boulder" \
|
||||
comment --pr "${TRAVIS_PULL_REQUEST}" -b -
|
||||
fi
|
||||
else
|
||||
update_status --state success
|
||||
fi
|
||||
rm ${result_file}
|
||||
}
|
||||
|
||||
function die() {
|
||||
|
|
@ -122,7 +120,7 @@ function run_unit_tests() {
|
|||
# are not stdlib packages. We can then install them with the race
|
||||
# detector enabled to prevent our individual `go test` calls from
|
||||
# building them multiple times.
|
||||
all_shared_imports=$(go list -f '{{ join .Imports "\n" }}' $TESTPATHS | sort | uniq)
|
||||
all_shared_imports=$(go list -f '{{ join .Imports "\n" }}' ${TESTPATHS} | sort | uniq)
|
||||
deps=$(go list -f '{{ if not .Standard }}{{ .ImportPath }}{{ end }}' ${all_shared_imports})
|
||||
echo "go installing race detector enabled dependencies"
|
||||
go install -race $deps
|
||||
|
|
@ -148,7 +146,7 @@ function run_unit_tests() {
|
|||
# spuriously because one test is modifying a table (especially
|
||||
# registrations) while another test is reading it.
|
||||
# https://github.com/letsencrypt/boulder/issues/1499
|
||||
run go test -p 1 $GOTESTFLAGS $TESTPATHS
|
||||
run go test -p 1 $GOTESTFLAGS ${TESTPATHS}
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
@ -161,7 +159,7 @@ GOBIN=${GOBIN:-$HOME/gopath/bin}
|
|||
#
|
||||
if [[ "$RUN" =~ "vet" ]] ; then
|
||||
start_context "vet"
|
||||
run_and_comment go vet $TESTPATHS
|
||||
run_and_comment go vet ${TESTPATHS}
|
||||
end_context #vet
|
||||
fi
|
||||
|
||||
|
|
@ -287,8 +285,30 @@ if [[ "$RUN" =~ "errcheck" ]] ; then
|
|||
start_context "errcheck"
|
||||
run_and_comment errcheck \
|
||||
-ignore io:Write,os:Remove,net/http:Write,github.com/letsencrypt/boulder/metrics:.*,github.com/cactus/go-statsd-client/statsd:.* \
|
||||
$(echo $TESTPATHS | tr ' ' '\n' | grep -v test)
|
||||
$(echo ${TESTPATHS} | tr ' ' '\n' | grep -v test)
|
||||
end_context #errcheck
|
||||
fi
|
||||
|
||||
# Run generate to make sure all our generated code can be re-generated with
|
||||
# current tools.
|
||||
# Note: Some of the tools we use seemingly don't understand ./vendor yet, and
|
||||
# so will fail if imports are not available in $GOPATH. So, in travis, this
|
||||
# always needs to run after `godep restore`.
|
||||
if [[ "$RUN" =~ "generate" ]] ; then
|
||||
start_context "generate"
|
||||
# Additionally, we need to run go install before go generate because the stringer command
|
||||
# (using in ./grpc/) checks imports, and depends on the presence of a built .a
|
||||
# file to determine an import really exists. See
|
||||
# https://golang.org/src/go/internal/gcimporter/gcimporter.go#L30
|
||||
# Without this, we get error messages like:
|
||||
# stringer: checking package: grpc/bcodes.go:6:2: could not import
|
||||
# github.com/letsencrypt/boulder/probs (can't find import:
|
||||
# github.com/letsencrypt/boulder/probs)
|
||||
go install ./probs
|
||||
go install google.golang.org/grpc/codes
|
||||
run_and_comment go generate ${TESTPATHS}
|
||||
run_and_comment git diff --exit-code .
|
||||
end_context #"generate"
|
||||
fi
|
||||
|
||||
exit ${FAILURE}
|
||||
|
|
|
|||
|
|
@ -7,14 +7,18 @@
|
|||
set -ev
|
||||
|
||||
go get \
|
||||
golang.org/x/tools/cover \
|
||||
github.com/golang/lint/golint \
|
||||
github.com/tools/godep \
|
||||
github.com/golang/mock/mockgen \
|
||||
github.com/golang/protobuf/proto \
|
||||
github.com/golang/protobuf/protoc-gen-go \
|
||||
github.com/jcjones/github-pr-status \
|
||||
github.com/jsha/listenbuddy \
|
||||
github.com/kisielk/errcheck \
|
||||
github.com/mattn/goveralls \
|
||||
github.com/modocache/gover \
|
||||
github.com/jcjones/github-pr-status \
|
||||
github.com/kisielk/errcheck \
|
||||
github.com/jsha/listenbuddy &
|
||||
github.com/tools/godep \
|
||||
golang.org/x/tools/cmd/stringer \
|
||||
golang.org/x/tools/cover &
|
||||
|
||||
(wget https://github.com/jsha/boulder-tools/raw/master/goose.gz &&
|
||||
mkdir -p $GOPATH/bin &&
|
||||
|
|
@ -22,6 +26,10 @@ go get \
|
|||
chmod +x $GOPATH/bin/goose &&
|
||||
./test/create_db.sh) &
|
||||
|
||||
(curl -sL https://github.com/google/protobuf/releases/download/v2.6.1/protobuf-2.6.1.tar.gz | \
|
||||
tar -xzv &&
|
||||
cd protobuf-2.6.1 && ./configure --prefix=$HOME && make && make install) &
|
||||
|
||||
# Set up rabbitmq exchange
|
||||
go run cmd/rabbitmq-setup/main.go -server amqp://boulder-rabbitmq &
|
||||
|
||||
|
|
|
|||
|
|
@ -3,9 +3,7 @@
|
|||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
// This mockgen call requires the import_prefix flag that is only present in the
|
||||
// letsencrypt fork of mockgen.
|
||||
// go:generate mockgen -source ./gsb.go -destination mock_gsb_test.go -package va -import_prefix github.com/letsencrypt/boulder/Godeps/_workspace/src
|
||||
// go:generate mockgen -source ./gsb.go -destination mock_gsb_test.go -package va
|
||||
|
||||
package va
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue