Skip to content

Commit e8b32ea

Browse files
Gomod Updates (#4)
This updates the boilerplate to use go modules instead of dep and follows the changes that have already been made: * flyteorg/datacatalog#21 * flyteorg/flytepropeller#38 * flyteorg/flyteadmin#35 * flyteorg/flyteplugins#36 * flyteorg/flytestdlib#50 * flyteorg/flyteidl#27 (depends on flyteorg/flytestdlib#50 to be merged and released)
1 parent d8af7c7 commit e8b32ea

File tree

8 files changed

+634
-14
lines changed

8 files changed

+634
-14
lines changed

boilerplate-repo/boilerplate/lyft/golang_dockerfile/Dockerfile.GoTemplate

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55

66
# Using go1.10.4
77
FROM golang:1.10.4-alpine3.8 as builder
8-
RUN apk add git openssh-client make curl dep
8+
RUN apk add git openssh-client make curl
99

10-
# COPY only the dep files for efficient caching
11-
COPY Gopkg.* /go/src/github.com/lyft/{{REPOSITORY}}/
10+
# COPY only the go mod files for efficient caching
11+
COPY go.mod go.sum /go/src/github.com/lyft/{{REPOSITORY}}/
1212
WORKDIR /go/src/github.com/lyft/{{REPOSITORY}}
1313

1414
# Pull dependencies
15-
RUN dep ensure -vendor-only
15+
RUN go mod download
1616

1717
# COPY the rest of the source code
1818
COPY . /go/src/github.com/lyft/{{REPOSITORY}}/
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module github.com/lyft/boilerplate
2+
3+
go 1.13
4+
5+
require (
6+
github.com/golangci/golangci-lint v1.22.2
7+
github.com/lyft/flytestdlib v0.2.31
8+
github.com/vektra/mockery v0.0.0-20181123154057-e78b021dcbb5
9+
github.com/alvaroloes/enumer v1.1.2
10+
)
11+
12+
replace github.com/vektra/mockery => github.com/enghabu/mockery v0.0.0-20191009061720-9d0c8670c2f0

boilerplate-repo/boilerplate/lyft/golang_support_tools/go.sum

Lines changed: 553 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// +build tools
2+
3+
package tools
4+
5+
import (
6+
_ "github.com/golangci/golangci-lint/cmd/golangci-lint"
7+
_ "github.com/lyft/flytestdlib/cli/pflags"
8+
_ "github.com/vektra/mockery/cmd/mockery"
9+
_ "github.com/alvaroloes/enumer"
10+
)

boilerplate-repo/boilerplate/lyft/golang_test_targets/Makefile

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,32 @@
11
# WARNING: THIS FILE IS MANAGED IN THE 'BOILERPLATE' REPO AND COPIED TO OTHER REPOSITORIES.
22
# ONLY EDIT THIS FILE FROM WITHIN THE 'LYFT/BOILERPLATE' REPOSITORY:
3-
#
3+
#
44
# TO OPT OUT OF UPDATES, SEE https://github.com/lyft/boilerplate/blob/master/Readme.rst
55

6-
DEP_SHA=1f7c19e5f52f49ffb9f956f64c010be14683468b
6+
7+
.PHONY: download_tooling
8+
download_tooling: #download dependencies (including test deps) for the package
9+
@boilerplate/lyft/golang_test_targets/download_tooling.sh
710

811
.PHONY: lint
9-
lint: #lints the package for common code smells
10-
which golangci-lint || curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s -- -b $$GOPATH/bin v1.16.0
11-
golangci-lint run --exclude deprecated
12+
lint: download_tooling #lints the package for common code smells
13+
GL_DEBUG=linters_output,env golangci-lint run --deadline=5m --exclude deprecated -v
1214

1315
# If code is failing goimports linter, this will fix.
1416
# skips 'vendor'
1517
.PHONY: goimports
1618
goimports:
1719
@boilerplate/lyft/golang_test_targets/goimports
1820

21+
.PHONY: mod_download
22+
mod_download: #download dependencies (including test deps) for the package
23+
go mod download
24+
1925
.PHONY: install
20-
install: #download dependencies (including test deps) for the package
21-
which dep || (curl "https://raw.githubusercontent.com/golang/dep/${DEP_SHA}/install.sh" | sh)
22-
dep ensure
26+
install: download_tooling mod_download
27+
28+
.PHONY: show
29+
show: go list -m all
2330

2431
.PHONY: test_unit
2532
test_unit:
@@ -36,3 +43,4 @@ test_unit_cover:
3643
.PHONY: test_unit_visual
3744
test_unit_visual:
3845
go test ./... -coverprofile /tmp/cover.out -covermode=count; go tool cover -html=/tmp/cover.out
46+

boilerplate-repo/boilerplate/lyft/golang_test_targets/Readme.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Golang Test Targets
22
~~~~~~~~~~~~~~~~~~~
33

4-
Provides an ``install`` make target that uses ``dep`` install golang dependencies.
4+
Provides an ``install`` make target that uses ``go mod`` to install golang dependencies.
55

66
Provides a ``lint`` make target that uses golangci to lint your code.
77

@@ -17,7 +17,7 @@ Provides a ``test_benchmark`` target for benchmark tests.
1717

1818
Add ``lyft/golang_test_targets`` to your ``boilerplate/update.cfg`` file.
1919

20-
Make sure you're using ``dep`` for dependency management.
20+
Make sure you're using ``go mod`` for dependency management.
2121

2222
Provide a ``.golangci`` configuration (the lint target requires it).
2323

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
3+
# Everything in this file needs to be installed outside of current module
4+
# The reason we cannot turn off module entirely and install is that we need the replace statement in go.mod
5+
# because we are installing a mockery fork. Turning it off would result installing the original not the fork.
6+
# We also want to version all the other tools. We also want to be able to run go mod tidy without removing the version
7+
# pins. To facilitate this, we're maintaining two sets of go.mod/sum files - the second one only for tooling. This is
8+
# the same approach that go 1.14 will take as well.
9+
# See:
10+
# https://github.com/lyft/flyte/issues/129
11+
# https://github.com/golang/go/issues/30515 for some background context
12+
# https://github.com/go-modules-by-example/index/blob/5ec250b4b78114a55001bd7c9cb88f6e07270ea5/010_tools/README.md
13+
14+
set -e
15+
16+
# List of tools to go get
17+
# In the format of "<cli>:<package>" or ":<package>" if no cli
18+
tools=(
19+
"github.com/vektra/mockery/cmd/mockery"
20+
"github.com/lyft/flytestdlib/cli/pflags"
21+
"github.com/golangci/golangci-lint/cmd/golangci-lint"
22+
"github.com/alvaroloes/enumer"
23+
)
24+
25+
tmp_dir=$(mktemp -d -t gotooling-XXX)
26+
echo "Using temp directory ${tmp_dir}"
27+
cp -R boilerplate/lyft/golang_support_tools/* $tmp_dir
28+
pushd "$tmp_dir"
29+
30+
for tool in "${tools[@]}"
31+
do
32+
echo "Installing ${tool}"
33+
GO111MODULE=on go install $tool
34+
done
35+
36+
popd

boilerplate-repo/boilerplate/update.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ if [ -z "$REPOSITORY" ]; then
3434
fi
3535

3636
while read directory; do
37+
# TODO: Skip empty lines, whitespace only lines, and comment lines
3738
echo "***********************************************************************************"
3839
echo "$directory is configured in update.cfg."
3940
echo "-----------------------------------------------------------------------------------"

0 commit comments

Comments
 (0)