Skip to content

Commit

Permalink
Merge pull request #382 from moul/dev/moul/switch-to-go-mod
Browse files Browse the repository at this point in the history
switch from dep to go mod
  • Loading branch information
moul committed Oct 15, 2018
2 parents deb6257 + 61cb24d commit 88fdc7e
Show file tree
Hide file tree
Showing 45 changed files with 1,495 additions and 1,194 deletions.
34 changes: 25 additions & 9 deletions .circleci/config.yml
Expand Up @@ -5,21 +5,25 @@ version: 2
environment:
GOPATH: /go
GOTEST_TIMEOUT: 5m
GOPROXY: http://goproxy.berty.io:3000/
GO111MODULE: "on"
docker:
- image: circleci/golang:latest

jobs:
lint:
<<: *golang_workspace
docker:
- image: bertychat/linter:latest
working_directory: /go/src/berty.tech
environment:
GOPATH: /go
steps:
- checkout
- restore_cache:
keys:
- v1-go-cache
- run:
name: fetch deps
command: |
cd core; go mod download
- run:
name: prepare CI
command: |
Expand All @@ -34,7 +38,7 @@ jobs:

generate:
docker:
- image: bertychat/protoc:latest
- image: bertychat/protoc:v2
working_directory: /go/src/berty.tech
environment:
GOPATH: /go
Expand All @@ -46,11 +50,20 @@ jobs:
command: |
cd core
make clean
- run:
name: make generate_prepare
command: |
cd core
make generate_prepare
- run:
name: make generate_local
command: |
cd core
make generate_local
- run:
name: ignore some files
command: |
git checkout core/go.mod # this file regularly changes with useless information (adding `// indirect`)
- run:
name: check if files changed
command: |
Expand Down Expand Up @@ -123,15 +136,18 @@ jobs:
- run:
name: test client (bot)
command: |
cd client/go
go test -v ./... | tee /tmp/test-results/go-test-report.out
go install -v ./...
cd client/go/bot
go test -v . | tee /tmp/test-results/go-test-report.out
go install -v .
cd ./examples/berty-bot-example
go test -v . | tee /tmp/test-results/go-test-report.out
go install -v .
- run:
name: test gomobile
command: |
cd client/react-native/gomobile
go test -v ./... | tee /tmp/test-results/go-test-report.out
GOARCH=386 go test -v ./... | tee /tmp/test-results/go-test-report.out
go test -v . | tee /tmp/test-results/go-test-report.out
GOARCH=386 go test -v . | tee /tmp/test-results/go-test-report.out
- run:
name: integration core
command: |
Expand Down
17 changes: 11 additions & 6 deletions .circleci/docker/Dockerfile.android-ci
@@ -1,18 +1,23 @@
FROM circleci/android:api-27-node8-alpha

COPY ./gomobile-env-flag.diff /tmp/gomobile-env-flag.diff

RUN cd ~ && git clone https://github.com/udhos/update-golang && sudo ~/update-golang/update-golang.sh
RUN cd ~ \
&& git clone https://github.com/udhos/update-golang \
&& sudo ~/update-golang/update-golang.sh

RUN echo "export PATH=/usr/local/go/bin/:~/go/bin:$PATH" >> ~/.bashrc

ENV PATH="/usr/local/go/bin/:/home/circleci/go/bin:${PATH}"

RUN go get golang.org/x/mobile/cmd/gomobile

RUN patch -l < /tmp/gomobile-env-flag.diff ~/go/src/golang.org/x/mobile/cmd/gomobile/env.go && go install golang.org/x/mobile/cmd/gomobile
RUN sdkmanager ndk-bundle

COPY ./gomobile-env-flag.diff /tmp/gomobile-env-flag.diff

RUN patch -l < /tmp/gomobile-env-flag.diff ~/go/src/golang.org/x/mobile/cmd/gomobile/env.go \
&& go install golang.org/x/mobile/cmd/gomobile

# see https://github.com/RedCoolBeans/dockerlint/issues/49
ENV ANDROID_NDK_HOME=/opt/android/android-ndk-r17b
RUN gomobile init -v -ndk /opt/android/sdk/ndk-bundle

RUN gomobile init -v -ndk ${ANDROID_NDK_HOME}
RUN mkdir -p /opt/android/sdk/ndk-bundle/toolchains/mips64el-linux-android/prebuilt/linux-x86_64
15 changes: 12 additions & 3 deletions .circleci/docker/Dockerfile.protoc
@@ -1,4 +1,6 @@
FROM moul/protoc-gen-gotemplate
FROM moul/protoc-gen-gotemplate as pgg

FROM golang:1.11-alpine as builder

RUN apk --update add make git go rsync libc-dev openssh docker

Expand All @@ -15,6 +17,13 @@ RUN go get -u -v \
github.com/spf13/cobra

RUN cd /go/src/github.com/99designs/gqlgen && git checkout v0.4.4 && go install github.com/99designs/gqlgen
RUN rm -f /go/bin/web-editor

ENV GOPATH=/go \
PATH=/go/bin:${PATH}
FROM golang:1.11-alpine
RUN apk --update add git make protobuf gcc libc-dev && mkdir -p /.cache/go-build && chmod -R 777 /.cache
COPY --from=pgg /go/bin/* /go/bin/
COPY --from=builder /go/bin/* /go/bin/
COPY --from=pgg /protobuf /protobuf
ENV GOPATH=/go \
PATH=/go/bin:${PATH} \
GOROOT=/usr/local/go
10 changes: 5 additions & 5 deletions .circleci/docker/gomobile-env-flag.diff
@@ -1,9 +1,9 @@
--- env.go 2018-08-02 10:10:17.801306783 +0000
+++ env.go.orig 2018-08-02 10:14:56.172659686 +0000
@@ -129,7 +129,7 @@
"CC="+clang,
"CXX="+clang,
--- env.go
+++ env.go
@@ -130,7 +130,7 @@ func envInit() (err error) {
"CXX="+clang+"++",
"CGO_CFLAGS="+cflags+" -arch "+archClang(arch),
"CGO_CXXFLAGS="+cflags+" -arch "+archClang(arch),
- "CGO_LDFLAGS="+cflags+" -arch "+archClang(arch),
+ "CGO_LDFLAGS="+cflags+" -arch "+archClang(arch)+" "+os.Getenv("CGO_LDFLAGS"),
"CGO_ENABLED=1",
Expand Down
1 change: 1 addition & 0 deletions .dockerignore
@@ -1,6 +1,7 @@
.git/
contrib/
client/
vendor/
node_modules/
gin-bin
!client/go
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Expand Up @@ -11,9 +11,15 @@ gin-bin

# emacs
.projectile
*~
*#
.#*

# sub projects
/depviz/

# version
./package.json

# go
vendor/
2 changes: 1 addition & 1 deletion .golangci.yml
Expand Up @@ -30,6 +30,6 @@ linters:
- staticcheck
- unconvert
- gofmt
- goimports
# - goimports # disabling goimports while we can't configure it to ignore vendors (github.com/whyrusleeping/go-logging seems to be badly formated)
- golint
- ineffassign
8 changes: 5 additions & 3 deletions Dockerfile
@@ -1,9 +1,11 @@
# build core
FROM golang:1.11-alpine as core-builder
RUN apk --no-cache --update add nodejs-npm make gcc g++ musl-dev openssl-dev
COPY vendor /go/src/berty.tech/vendor
COPY core /go/src/berty.tech/core
RUN apk --no-cache --update add nodejs-npm make gcc g++ musl-dev openssl-dev git
ENV GO111MODULE=on GOPROXY=http://goproxy.berty.io:3000
COPY core/go.* /go/src/berty.tech/core/
WORKDIR /go/src/berty.tech
RUN cd core && go get .
COPY core /go/src/berty.tech/core
RUN cd core && make _ci_prepare # touching generated files
RUN cd core && make install

Expand Down

0 comments on commit 88fdc7e

Please sign in to comment.