Skip to content

Commit

Permalink
Merge pull request #2489 from oasislabs/yawning/feature/2473
Browse files Browse the repository at this point in the history
build: Make `go generate optional
  • Loading branch information
Yawning committed Dec 18, 2019
2 parents b39faf7 + cde3073 commit b619f1d
Show file tree
Hide file tree
Showing 7 changed files with 1,762 additions and 25 deletions.
10 changes: 10 additions & 0 deletions .buildkite/go/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,19 @@
# https://buildkite.com/docs/pipelines/writing-build-scripts
set -euxo pipefail

RED='\033[0;31m'
OFF='\033[0m'

####################
# Build the Go parts
####################
pushd go
# Ensure that the `go generate` output in git is up-to-date.
make generate
if [ -n "$(git status --porcelain)" ]; then
echo -e "${RED}ERROR: go/ directory is dirty after 'go generate'${OFF}"
exit 1
fi

make all integrationrunner
popd
2 changes: 0 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install gcc g++ protobuf-compiler make cmake libssl-dev libseccomp-dev
go get github.com/golang/protobuf/protoc-gen-go
sudo GOBIN=/usr/local/bin go install github.com/golang/protobuf/protoc-gen-go
- name: Install GoReleaser
run: |
cd $(mktemp --directory /tmp/goreleaser.XXXXX)
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ clean-go:
clean: $(clean-targets)

# Prepare release.
release: build-go-generate
release:
@goreleaser $(GORELEASER_ARGS)

# Develop in a Docker container.
Expand Down
30 changes: 17 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,6 @@ Prerequisites:
export OASIS_GO=go1.13
```

* [protoc-gen-go](https://github.com/golang/protobuf).

Download and install it with:
```
${OASIS_GO:-go} get github.com/golang/protobuf/protoc-gen-go
```

_NOTE: If you didn't/can't add `$GOPATH/bin` to your `PATH`, you can install
`protoc-gen-go` to `/usr/local/bin` (which is in `$PATH`) with:_
```
sudo GOBIN=/usr/local/bin ${OASIS_GO:-go} install github.com/golang/protobuf/protoc-gen-go
```

* [Rust](https://www.rust-lang.org) and the nightly toolchain.

Once you have [`rustup` installed](https://www.rust-lang.org/tools/install),
Expand All @@ -104,6 +91,23 @@ Prerequisites:
cargo install fortanix-sgx-tools sgxs-tools
```

* (**OPTIONAL**) [protoc-gen-go](https://github.com/golang/protobuf).

Download and install it with:
```
${OASIS_GO:-go} get github.com/golang/protobuf/protoc-gen-go
```

_NOTE: If you didn't/can't add `$GOPATH/bin` to your `PATH`, you can install
`protoc-gen-go` to `/usr/local/bin` (which is in `$PATH`) with:_
```
sudo GOBIN=/usr/local/bin ${OASIS_GO:-go} install github.com/golang/protobuf/protoc-gen-go
```

_NOTE: The repository has the most up-to-date files generated by protoc-gen-go
committed for convenience. Installing protoc-gen-go is only required if you
are a developer making changes to protobuf definitions used by Go._

In the following instructions, the top-level directory is the directory
where the code has been checked out.

Expand Down
3 changes: 0 additions & 3 deletions go/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,3 @@ oasis-node/integrationrunner/integrationrunner.test
oasis-test-runner/oasis-test-runner
oasis-net-runner/oasis-net-runner
storage/mkvs/urkel/interop/urkel-test-helpers

# Ignore output from protoc created via `go generate`.
common/sgx/aesm/*.pb.go
12 changes: 6 additions & 6 deletions go/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ $(go-binaries):
@$(ECHO) "$(MAGENTA)*** Building $@...$(OFF)"
$(GO) build $(GOFLAGS) $(GO_EXTRA_FLAGS) -o ./$@/$@ ./$@

oasis-node: generate
oasis-node:

build: $(go-binaries)

# Build test helpers.
# Urkel interoperability test helpers.
urkel: generate
urkel:
@$(ECHO) "$(MAGENTA)*** Building test helpers for $@...$(OFF)"
@$(GO) build $(GOFLAGS) $(GO_EXTRA_FLAGS) -o ./$(GO_TEST_HELPER_URKEL_PATH) ./$(shell dirname $(GO_TEST_HELPER_URKEL_PATH))

Expand All @@ -40,7 +40,7 @@ $(test-vectors):
@$(ECHO) "$(MAGENTA)*** Generating test vectors for $@...$(OFF)"
@$(GO) run ./$@/gen_vectors

staking: generate
staking:

gen-test-vectors: $(test-vectors)

Expand All @@ -50,17 +50,17 @@ fmt:
@$(GO) fmt ./...

# Lint.
lint: generate
lint:
@$(ECHO) "$(CYAN)*** Running Go linters...$(OFF)"
@env -u GOPATH golangci-lint run

# Test.
test: generate
test:
@$(ECHO) "$(CYAN)*** Running Go unit tests...$(OFF)"
@$(GO) test -timeout 5m -race -v ./...

# Test oasis-node with coverage.
integrationrunner: generate
integrationrunner:
@$(ECHO) "$(CYAN)*** Testing oasis-node with coverate...$(OFF)"
@$(GO) test $(GOFLAGS) -c -covermode=atomic -coverpkg=./... -o oasis-node/$@/$@.test ./oasis-node/$@

Expand Down
Loading

0 comments on commit b619f1d

Please sign in to comment.