Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run go generate in Travis #1762

Merged
merged 57 commits into from
Apr 21, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
35a5a67
Fix go generate command in metrics.
jsha Apr 11, 2016
36c7232
Add mockgen to test setup.
jsha Apr 11, 2016
85d9ece
Fix github-pr-status output.
jsha Apr 11, 2016
7c7f308
Fix envvar style.
jsha Apr 12, 2016
beec986
Set xtrace.
jsha Apr 12, 2016
e50642f
Fix test.sh
jsha Apr 12, 2016
bf6e169
Fix test.sh some more.
jsha Apr 12, 2016
1aa0d60
Fix mockgen command.
jsha Apr 12, 2016
2fc350e
Merge branch 'master' of github.com:letsencrypt/boulder into fix-go-g…
jsha Apr 13, 2016
f56570d
Add dependencies for running `go generate`.
jsha Apr 13, 2016
44fc980
Add protoc-gen-go.
jsha Apr 13, 2016
79457ae
Fix go get command.
jsha Apr 14, 2016
6a4162e
Fix generate.
jsha Apr 14, 2016
61a6165
Wait for all.
jsha Apr 14, 2016
e87b1d2
Fix generate.
jsha Apr 14, 2016
e22753a
Update generated pb.
jsha Apr 14, 2016
543205e
Merge branch 'master' into fix-go-generate
jsha Apr 18, 2016
36d7d4a
Fix generate commands for vendored world.
jsha Apr 18, 2016
e8c0fe9
Update documentation for new vendor style.
jsha Apr 18, 2016
332587b
Merge branch 'master' into fix-go-generate
jsha Apr 18, 2016
f6b3be9
Merge branch 'master' into fix-go-generate
jsha Apr 19, 2016
9b9e877
Update grpc package to latest.
jsha Apr 19, 2016
13f3b95
Merge branch 'fix-go-generate' of github.com:letsencrypt/boulder into…
jsha Apr 19, 2016
a3f6b5d
Update caaChecker proto with latest.
jsha Apr 19, 2016
e334555
Run go generate only over TESTPATHS
jsha Apr 19, 2016
cd6eef5
See if Travis passes under 1.6
jsha Apr 19, 2016
997c850
Switch back to 1.5.
jsha Apr 19, 2016
b036f29
Trim run command.
jsha Apr 19, 2016
cf56f6c
Run stringer from correct directory.
jsha Apr 19, 2016
b3f6f89
Move generate command.
jsha Apr 19, 2016
9153856
Restore and generate
jsha Apr 20, 2016
ad8958b
Fix path.
jsha Apr 20, 2016
ec5f243
list contents of GOPATH.
jsha Apr 20, 2016
aabe3bb
Fix stringer by prebuilding.
jsha Apr 20, 2016
01a0ffd
Try another import path.
jsha Apr 20, 2016
98402a0
regenerate bcode_string.
jsha Apr 20, 2016
3200c99
remove excess package
jsha Apr 20, 2016
513478c
pull jsha fork of protoc-gen-go that echoes
jsha Apr 20, 2016
cfef721
Echo protoc version.
jsha Apr 20, 2016
0eecee7
install from source
jsha Apr 20, 2016
53f117d
CD back.
jsha Apr 20, 2016
eaccf3c
Go back to normal protoc-gen-go
jsha Apr 20, 2016
d3d0968
Fix path
jsha Apr 20, 2016
084463a
Move protobuf install into test/setup.sh
jsha Apr 20, 2016
4cf74ef
Move before_install to install.
jsha Apr 20, 2016
958320b
Set PATH.
jsha Apr 20, 2016
924d123
Follow 301 with curl.
jsha Apr 20, 2016
7493233
Shuffle test order.
jsha Apr 20, 2016
785fed3
Swap back test order.
jsha Apr 20, 2016
c170b35
Restore all tests.
jsha Apr 20, 2016
e99b897
Restore 1.5.3 to Travis.
jsha Apr 20, 2016
fc8f3ec
Merge branch 'master' into test-fix-go-generate
jsha Apr 20, 2016
b6e433c
Remove unnecessary wait-or-exit
jsha Apr 20, 2016
5fcaf8b
Generate metrics mock with latest mockgen.
jsha Apr 21, 2016
eea7c3d
Wrap TESTPATHS in curlies
jsha Apr 21, 2016
090a304
Remove spurious bracket
jsha Apr 21, 2016
7c30f89
Merge branch 'master' into test-fix-go-generate
jsha Apr 21, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
```
3 changes: 1 addition & 2 deletions metrics/mock_statsd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
package metrics

import (
time "time"

gomock "github.com/golang/mock/gomock"
time "time"
Copy link
Contributor

@riking riking Apr 21, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are these being renamed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's just something mockgen does.

)

// Mock of Statter interface
Expand Down
54 changes: 37 additions & 17 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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
Expand All @@ -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
}

Expand All @@ -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

Expand Down Expand Up @@ -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}
18 changes: 13 additions & 5 deletions test/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,29 @@
set -ev

go get \
golang.org/x/tools/cover \
github.com/golang/lint/golint \
github.com/tools/godep \
github.com/mattn/goveralls \
github.com/modocache/gover \
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/jsha/listenbuddy &
github.com/mattn/goveralls \
github.com/modocache/gover \
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 &&
zcat goose.gz > $GOPATH/bin/goose &&
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 &

Expand Down
4 changes: 1 addition & 3 deletions va/gsb.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down