Skip to content

Commit

Permalink
feat: Update to go 1.13 (#1557)
Browse files Browse the repository at this point in the history
feat: Update to go 1.13
  • Loading branch information
moul committed Dec 20, 2019
2 parents 5753167 + e13a01e commit 3b0d1e3
Show file tree
Hide file tree
Showing 31 changed files with 551 additions and 472 deletions.
2 changes: 1 addition & 1 deletion .buildkite/agent_setup/linux/user/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
AGENT_GO_VERSION=1.12.10
AGENT_GO_VERSION=1.13.5
AGENT_BAZEL_VERSION=0.29.1
AGENT_GOLANGCILINT_VERSION=1.21.0
AGENT_KEY_TYPE=ed25519
Expand Down
121 changes: 70 additions & 51 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,42 @@ steps:
agents:
queue: "bigcores"
commands:
- cd go
- docker build .
- set -x
- cd go
- docker build .

- label: go-generate
plugins:
- n0izn0iz/docker#v3.5.4:
image: bertytech/protoc:21
image: bertytech/protoc:22
propagate-uid-gid: true
workdir: /go/src/berty.tech
environment: [ "GO111MODULE=on", "GOPATH=/go"]
volumes: [
"~/go/pkg/mod:/go/pkg/mod"
]
environment: ["GO111MODULE=on", "GOPATH=/go"]
volumes: ["~/go/pkg/mod:/go/pkg/mod"]
commands:
- go version
- find . -name gen.sum -delete
- cd go
- time go mod vendor
- make generate_local
- make tidy
- cd ../docs
- make generate_local
- cd ..
- git status | cat
- git diff -w | cat
- git diff-index -w --quiet HEAD --
- set -x
- go version
- find . -name gen.sum -delete
- cd go
- time go mod vendor
- make generate_local
- make tidy
- cd ../docs
- make generate_local
- cd ..
- git status | cat
- git diff -w | cat
- git diff-index -w --quiet HEAD --

- label: githooks
plugins:
- n0izn0iz/docker#v3.5.4:
image: bertytech/githooks:v1
propagate-uid-gid: true
workdir: /go/src/berty.tech
environment: [ "GO111MODULE=on", "GOPATH=/go" ]
environment: ["GO111MODULE=on", "GOPATH=/go"]
commands:
- set -x
- ./githooks/pre-commit
- git status | cat
- git diff -w | cat
Expand All @@ -46,17 +47,16 @@ steps:
- label: js-generate
plugins:
- n0izn0iz/docker#v3.5.4:
image: bertytech/protoc:21
image: bertytech/protoc:22
propagate-uid-gid: true
workdir: /go/src/berty.tech
environment: [ "GO111MODULE=on", "GOPATH=/go", "HOME=/home/buildkite-agent" ]
volumes: [
"~:/home/buildkite-agent",
"~/go/pkg/mod:/go/pkg/mod",
]
environment:
["GO111MODULE=on", "GOPATH=/go", "HOME=/home/buildkite-agent"]
volumes: ["~:/home/buildkite-agent", "~/go/pkg/mod:/go/pkg/mod"]
agents:
queue: "bigcores"
commands:
- set -x
- cd js
- make gen.clean
- make gen
Expand All @@ -68,35 +68,43 @@ steps:
- label: js-lint
plugins:
- n0izn0iz/docker#v3.5.4:
image: bertytech/protoc:21
image: bertytech/protoc:22
propagate-uid-gid: true
workdir: /go/src/berty.tech
environment: [ "GO111MODULE=on", "GOPATH=/go", "HOME=/home/buildkite-agent" ]
volumes: [
"~:/home/buildkite-agent",
"~/go/pkg/mod:/go/pkg/mod",
]
environment:
["GO111MODULE=on", "GOPATH=/go", "HOME=/home/buildkite-agent"]
volumes: ["~:/home/buildkite-agent", "~/go/pkg/mod:/go/pkg/mod"]
agents:
queue: "bigcores"
commands:
- set -x
- cd js
- make lint

- label: go-build-112
key: go-build-112
env:
GO111MODULE: "on"
- label: go-build
plugins:
- n0izn0iz/docker#v3.5.4:
image: bertytech/build-go:v2
propagate-uid-gid: true
workdir: /go/src/berty.tech
propagate-environment: true
environment:
[
"GO111MODULE=on",
"GOPATH=/home/buildkite-agent/go",
"HOME=/home/buildkite-agent",
"GOSUMDB=off",
"CODECOV_TOKEN",
]
volumes: ["~:/home/buildkite-agent"]
agents:
queue: "golint"
# this is needed because golangci-lint is not multiuser
# https://github.com/golangci/golangci-lint/blob/fa69ddfc14ff9da080e14607d07d73e34750b426/pkg/commands/executor.go#L209
# + this job is not run in a container + go's os.TempDir seems to ignore TMPDIR in this case
# another solution is to put this job in a container or other kind of sandbox
queue: "bigcores"
commands:
- set -x

- go version
- cd go

# TODO: cache $GOPATH/pkg/mod
- go mod download

# https://circleci.com/orbs/registry/orb/gotest/tools#commands-mod-tidy-check
Expand All @@ -108,18 +116,29 @@ steps:
- SKIP_SLOW_TESTS=1 make go.unittest GO_TEST_OPTS="-v -test.timeout=120s -count 10"
- SKIP_SLOW_TESTS=0 make go.unittest GO_TEST_OPTS="-v -test.timeout=120s -count 2"
- make tidy
# we can do this rm because we're in special queue
- rm -f /tmp/golangci-lint.lock
- make lint
- cd ..
- codecov -f ./go/coverage.txt

- label: bazel-go
env:
BAZEL_CMD_ARGS: '--test_output=errors --action_env="GTEST_COLOR=1"'
plugins:
- n0izn0iz/docker#v3.5.4:
image: bertytech/bazel:2.0.0-buster-r0
propagate-uid-gid: true
workdir: /go/src/berty.tech
environment:
[
"GO111MODULE=on",
"GOPATH=/home/buildkite-agent/go",
"HOME=/home/buildkite-agent",
'BAZEL_CMD_ARGS=--test_output=errors --action_env="GTEST_COLOR=1"',
]
volumes: ["~:/home/buildkite-agent"]
commands:
- bazel --version
- go version
- cd go
- make bazel.unittest
- make bazel.build
- set -x
- export USER=$(id -u)
- bazel --version
- go version
- cd go
- make bazel.unittest
- make bazel.build
66 changes: 66 additions & 0 deletions build/bazel/com_github_libp2p_go_openssl.BUILD.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("@bazel_gazelle//:def.bzl", "gazelle")

# gazelle:ignore

go_library(
name = "go_default_library",
srcs = [
"bio.go",
"build.go",
"cert.go",
"ciphers.go",
"ciphers_gcm.go",
"conn.go",
"ctx.go",
"dh.go",
"dhparam.go",
"digest.go",
"engine.go",
"fips.go",
"hmac.go",
"hostname.c",
"hostname.go",
"http.go",
"init.go",
"init_posix.go",
"init_windows.go",
"key.go",
"mapping.go",
"md4.go",
"md5.go",
"net.go",
"nid.go",
"pem.go",
"sha1.go",
"sha256.go",
"shim.c",
"shim.h",
"sni.c",
"ssl.go",
"tickets.go",
],
cgo = True,
clinkopts = select({
"@bazel_tools//src/conditions:darwin": [
"-L/usr/local/opt/openssl/lib"
],
"//conditions:default": [],
}) + [
"-lssl",
"-lcrypto",
],
copts = select({
"@bazel_tools//src/conditions:darwin": [
"-I/usr/local/opt/openssl/include"
],
"//conditions:default": [],
}),
importmap = "berty.tech/go/vendor/github.com/libp2p/go-openssl",
importpath = "github.com/libp2p/go-openssl",
visibility = ["//visibility:public"],
deps = [
"//vendor/github.com/libp2p/go-openssl/utils:go_default_library",
"//vendor/github.com/spacemonkeygo/spacelog:go_default_library",
],
)
2 changes: 1 addition & 1 deletion docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ $(GEN_SUM): $(GEN_SRC)
--workdir="/go/src/berty.tech/docs" \
--entrypoint="sh" \
--rm \
bertytech/protoc:21 \
bertytech/protoc:22 \
-xec 'make generate_local' \
)

Expand Down
2 changes: 1 addition & 1 deletion docs/gen.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion go/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ load("@bazel_gazelle//:def.bzl", "gazelle")

# gazelle:prefix berty.tech/go
# gazelle:proto disable_global
# gazelle:exclude vendor/golang.org/x/crypto/ed25519/ed25519_go113.go
gazelle(
name = "gazelle",
external = "vendored",
Expand Down
2 changes: 1 addition & 1 deletion go/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# build
FROM golang:1.12-alpine as builder
FROM golang:1.13.5-alpine as builder
RUN apk add --no-cache git gcc musl-dev make
ENV GO111MODULE=on
WORKDIR /go/src/berty.tech/go
Expand Down
8 changes: 4 additions & 4 deletions go/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ re: clean build
.PHONY: go.lint
go.lint: pb.generate
$(call check-program, golangci-lint)
golangci-lint run --verbose ./...
golangci-lint run --timeout=120s --verbose ./...

.PHONY: nobazel.unittest
go.unittest: pb.generate
Expand All @@ -98,7 +98,7 @@ go.install: pb.generate
##

SAMPLE_GAZELLE_GENERATED_FILE ?= pkg/bertyprotocol/BUILD.bazel # should be the path of a git-ignored bazel-generated file
VENDOR_BAZEL_OVERRIDEN_FILES = vendor/github.com/spacemonkeygo/openssl/BUILD.bazel
VENDOR_BAZEL_OVERRIDEN_FILES = vendor/github.com/libp2p/go-openssl/BUILD.bazel


.PHONY: bazel.lint
Expand Down Expand Up @@ -163,7 +163,7 @@ ibazel.unittest: bazel.generate
## Deps
##

vendor/github.com/spacemonkeygo/openssl/BUILD.bazel: $(abspath ../build/bazel/com_github_spacemonkeygo_openssl.BUILD.bazel) vendor
vendor/github.com/libp2p/go-openssl/BUILD.bazel: $(abspath ../build/bazel/com_github_libp2p_go_openssl.BUILD.bzl) vendor
cp $< $@

$(SAMPLE_GAZELLE_GENERATED_FILE): WORKSPACE vendor $(VENDOR_BAZEL_OVERRIDEN_FILES)
Expand Down Expand Up @@ -202,7 +202,7 @@ $(GEN_SUM): $(GEN_SRC)
--workdir="/go/src/berty.tech/go" \
--entrypoint="sh" \
--rm \
bertytech/protoc:21 \
bertytech/protoc:22 \
-xec 'make generate_local'; \
$(MAKE) tidy \
)
Expand Down
2 changes: 1 addition & 1 deletion go/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ berty_go_repositories()

load("@build_bazel_rules_nodejs//:index.bzl", "check_bazel_version")

check_bazel_version("0.29.1")
check_bazel_version("2.0.0")

# config go berty

Expand Down
1 change: 0 additions & 1 deletion go/cmd/berty/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"time"

"berty.tech/go/internal/banner"
_ "berty.tech/go/internal/buildconstraints" // fail if bad go version
"berty.tech/go/internal/grpcutil"
"berty.tech/go/pkg/bertyprotocol"
"berty.tech/go/pkg/errcode"
Expand Down
2 changes: 1 addition & 1 deletion go/config.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def berty_go_config():

go_rules_dependencies()

go_register_toolchains(go_version = "1.12.10")
go_register_toolchains(go_version = "1.13.5")

# gazelle config

Expand Down
3 changes: 1 addition & 2 deletions go/framework/bpbridge/bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import (
"sync"
"time"

_ "berty.tech/go/internal/buildconstraints" // fail if bad go version
_ "github.com/jinzhu/gorm/dialects/sqlite" // required by gorm
_ "github.com/jinzhu/gorm/dialects/sqlite" // required by gorm
"github.com/pkg/errors"

"berty.tech/go/internal/grpcutil"
Expand Down
2 changes: 1 addition & 1 deletion go/gen.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3b0d1e3

Please sign in to comment.