Skip to content

Commit 42ae51d

Browse files
all: change package manager from dep to go mod (#1542)
Converts the mono repo from using the `dep` package manager to using the [go mod](https://github.com/golang/go/wiki/Modules) that has become the standard dependency manager in recent releases of Go. Make the monorepo more accessible to Go developers using standard Go tooling. Modules will be enabled by default in Go 1.13, and were enabled by default when not using a GOPATH in Go 1.11+. Summary of changes: * [x] Add a `go.mod` file that contains the same dependencies and dependency versions/hashes/sources. * [x] Add a `go.sum` which is the smallest set of hashes required to validate that the dependencies at those versions remain consistent. * [x] Add a `go.list` which is a way for us to visibly see when our dependencies change. Note: This is not a standard file, but is something we can use to validate reproducibility until the `go mod` commands provide something similar. * [x] Update CircleCI and TravisCI builds so that they succeed * [x] Update CircleCI and TravisCI builds so that they fail if any of the above `go.*` files are out of date. * [x] Update documentation within the repository * [x] Test that other projects can import this repo. (This will be much easier, unfortunately, to test after merging, but I am currently attempting to test this before merging.) * [x] Remove the existing `dep` files, `Gopkg.toml` and `Gopkg.lock`. (This will occur just before merging.) Known limitations & issues: This change bumps our minimum supported version of Go to 1.11.4. Versions prior to that version contained a bug when Modules are in use that prevented the importing of some packages. There are more details about the issue here: golang/go#30446 (comment). All changes: * all: update ci config to use modules instead of dep * all: go mod init * all: go mod tidy -v * all: go get github.com/gobuffalo/[email protected] * all: go get github.com/spf13/cobra@9c28e4bbd74e * all: go mod tidy -v * all: go get github.com/BurntSushi/toml@99064174e013 * all: go get github.com/spf13/viper@db7ff930a189, go mod tidy * all: go get github.com/mitchellh/mapstructure@2caf8efc9366, go mod tidy * all: go get github.com/kr/pretty@e6ac2fc51e89, go mod tidy * all: go get github.com/kr/text@e373e137fafd, go mod tidy * all: go get github.com/sirupsen/logrus@070c81def33f, go mod tidy * all: go get github.com/spf13/pflag@4bd69631f475, go mod tidy * all: go get github.com/spf13/jwalterweatherman@3d60171a6431, go mod tidy * all: go get github.com/magiconair/[email protected], go mod tidy * all: go get github.com/spf13/cast@4d07383ffe94, go mod tidy * all: go get github.com/davecgh/go-spew@5215b55f46b2, go mod tidy * all: go get github.com/stretchr/testify@976c720a22c8, go mod tidy * all: go get github.com/stretchr/objx@1a9d0bb9f541, go mod tidy * all: commit go.sum file * all: commit go.list file generated with go list -m all > go.list * all: download dependencies in an earlier step * all: change the install process for staticcheck to leverage modules * all: add check of dependencies * all: add checks and tests running with go1.13rc1 * all: allow install of a newer versions of some packages for buster images * all: do a check of deps before building for publishing * doc: update readmes with new building instructions * all: update travis.yml with modules and go1.13rc1 * all: update dockerfiles with modules * all: set go.mod's go directive to go 1.11 * all: run travis builds on the latest minor release of each * doc: increase min version of Go to 1.11.4 * all: cache go mod download * all: use new git repo for gocheck * all: skip go.sum checks for go 1.11.* because it is inconsistent with other versions of go * all: remove reference to dep in dockerfile * all: remove reference to dep in horizon dockerfile * all: remove curl in horizon dockerfile because was only needed for dep * doc: remove mention of go-dep * doc: remove mention of dep in developing documentation * doc: update min Go required to go1.11.4 * doc: improve developer building instructions * all: install postgres-client-9.6 via postgres apt * all: go get github.com/rcrowley/go-metrics@51425a2415d2, go mod tidy * all: remove duplicate steps from poor copy and paste * all: go get golang.org/x/net@ba9fcec4b297b415637633c5a6e8fa592e4a16c3, go mod tidy * all: use a cache key that references go.mod too * all: remove dep files: Gopkg.*
1 parent 263f2d4 commit 42ae51d

File tree

16 files changed

+648
-1210
lines changed

16 files changed

+648
-1210
lines changed

.circleci/config.yml

Lines changed: 70 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,20 +64,25 @@ commands:
6464
install_go_deps:
6565
steps:
6666
- checkout
67-
- run:
68-
name: Install dep
69-
command: curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
7067
- restore_cache:
7168
keys:
72-
- v1-pkg-cache
69+
- go-mod-v1-{{ checksum "go.mod" }}-{{ checksum "go.sum" }}
7370
- run:
74-
name: Install project dependencies using dep
75-
command: dep ensure -v
71+
name: Download dependencies
72+
command: |
73+
go mod download
7674
- save_cache:
77-
key: v1-pkg-cache
75+
key: go-mod-v1-{{ checksum "go.mod" }}-{{ checksum "go.sum" }}
7876
paths:
79-
- "/go/src/github.com/stellar/go/vendor"
80-
- "/go/src/pkg/dep"
77+
- /go/pkg/mod
78+
79+
# check_go_deps validates that the dependencies are expected.
80+
check_go_deps:
81+
steps:
82+
- checkout
83+
- run:
84+
name: Check dependencies
85+
command: ./gomod.sh
8186

8287
check_ingest_state:
8388
steps:
@@ -108,7 +113,17 @@ commands:
108113
steps:
109114
- run:
110115
name: Install dependencies
111-
command: sudo apt-get update && sudo apt-get install postgresql-client-9.6 mariadb-client-10.1
116+
command: |
117+
sudo apt-get update
118+
(
119+
sudo apt-get install postgresql-client-9.6 || (
120+
echo "deb http://apt.postgresql.org/pub/repos/apt/ $(env -i bash -c '. /etc/os-release; echo $VERSION_CODENAME')-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list &&
121+
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - &&
122+
sudo apt-get update &&
123+
sudo apt-get install postgresql-client-9.6
124+
)
125+
)
126+
(sudo apt-get install mariadb-client-10.1 || sudo apt-get install mariadb-client-10.3)
112127
- run:
113128
name: Install dockerize
114129
command: wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz && sudo tar -C /usr/local/bin -xzvf dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz && rm dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz
@@ -149,16 +164,35 @@ jobs:
149164
working_directory: /go/src/github.com/stellar/go
150165
docker:
151166
- image: circleci/golang:1.11-stretch
167+
environment:
168+
GO111MODULE: "on"
152169
steps:
170+
- install_go_deps
171+
- check_go_deps
153172
- govet
154173

155174
# check_code_1_12 performs code checks using Go 1.12.
156175
check_code_1_12:
157176
working_directory: /go/src/github.com/stellar/go
158177
docker:
159178
- image: circleci/golang:1.12-stretch
179+
environment:
180+
GO111MODULE: "on"
181+
steps:
182+
- install_go_deps
183+
- check_go_deps
184+
- gofmt
185+
- govet
186+
- staticcheck
187+
188+
# check_code_1_13 performs code checks using Go 1.13.
189+
check_code_1_13:
190+
working_directory: /go/src/github.com/stellar/go
191+
docker:
192+
- image: circleci/golang:1.13rc1-buster
160193
steps:
161194
- install_go_deps
195+
- check_go_deps
162196
- gofmt
163197
- govet
164198
- staticcheck
@@ -169,6 +203,7 @@ jobs:
169203
docker:
170204
- image: circleci/golang:1.11-stretch
171205
environment:
206+
GO111MODULE: "on"
172207
PGHOST: localhost
173208
PGPORT: 5432
174209
PGUSER: circleci
@@ -189,6 +224,28 @@ jobs:
189224
docker:
190225
- image: circleci/golang:1.12-stretch
191226
environment:
227+
GO111MODULE: "on"
228+
PGHOST: localhost
229+
PGPORT: 5432
230+
PGUSER: circleci
231+
MYSQL_HOST: 127.0.0.1
232+
MYSQL_PORT: 3306
233+
- image: circleci/postgres:9.6.5-alpine-ram
234+
environment:
235+
POSTGRES_USER: circleci
236+
- image: circleci/mysql:5.7
237+
- image: circleci/redis:5.0-alpine
238+
steps:
239+
- install_go_deps
240+
- test_packages
241+
242+
# test_code_1_13 performs all package tests using Go 1.13.
243+
test_code_1_13:
244+
working_directory: /go/src/github.com/stellar/go
245+
docker:
246+
- image: circleci/golang:1.13rc1-buster
247+
environment:
248+
GO111MODULE: "on"
192249
PGHOST: localhost
193250
PGPORT: 5432
194251
PGUSER: circleci
@@ -214,6 +271,7 @@ jobs:
214271
steps:
215272
- check_deprecations
216273
- install_go_deps
274+
- check_go_deps
217275
- build_packages
218276
- attach_workspace:
219277
at: ./dist
@@ -257,8 +315,10 @@ workflows:
257315
jobs:
258316
- check_code_1_11
259317
- check_code_1_12
318+
- check_code_1_13
260319
- test_code_1_11
261320
- test_code_1_12
321+
- test_code_1_13
262322
- ingest_state_diff:
263323
filters:
264324
branches:

Dockerfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
FROM golang:1.12
2-
RUN curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
32
WORKDIR /go/src/github.com/stellar/go
43

54
COPY . .
6-
RUN dep ensure -v
5+
ENV GO111MODULE=on
76
RUN go install github.com/stellar/go/tools/...
87
RUN go install github.com/stellar/go/services/...

0 commit comments

Comments
 (0)