Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

incorporate latest boilerplate changes #53

Merged
merged 7 commits into from
Jan 24, 2020
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ compile:
go build -o pflags ./cli/pflags/main.go && mv ./pflags ./bin

gen-config:
# Note that installing it via download_tooling.sh doesn't work
honnix marked this conversation as resolved.
Show resolved Hide resolved
which pflags || (go get github.com/lyft/flytestdlib/cli/pflags)
@go generate ./...

Expand Down
23 changes: 17 additions & 6 deletions boilerplate/lyft/golang_test_targets/Makefile
Original file line number Diff line number Diff line change
@@ -1,19 +1,30 @@
# WARNING: THIS FILE IS MANAGED IN THE 'BOILERPLATE' REPO AND COPIED TO OTHER REPOSITORIES.
# ONLY EDIT THIS FILE FROM WITHIN THE 'LYFT/BOILERPLATE' REPOSITORY:
#
# TO OPT OUT OF UPDATES, SEE https://github.com/lyft/boilerplate/blob/master/Readme.rst


.PHONY: download_tooling
download_tooling: #download dependencies (including test deps) for the package
@boilerplate/lyft/golang_test_targets/download_tooling.sh

.PHONY: lint
lint: #lints the package for common code smells
# install outside of current module, workaround https://github.com/golang/go/issues/30515
which golangci-lint || (cd /tmp && go get github.com/golangci/golangci-lint/cmd/golangci-lint && cd -)
golangci-lint run
lint: download_tooling #lints the package for common code smells
GL_DEBUG=linters_output,env golangci-lint run --deadline=5m --exclude deprecated -v

# If code is failing goimports linter, this will fix.
# skips 'vendor'
.PHONY: goimports
goimports:
@boilerplate/lyft/golang_test_targets/goimports

.PHONY: install
install: #download dependencies (including test deps) for the package
.PHONY: mod_download
mod_download: #download dependencies (including test deps) for the package
go mod download

.PHONY: install
install: download_tooling mod_download

.PHONY: test_unit
test_unit:
go test -cover ./... -race
Expand Down
33 changes: 33 additions & 0 deletions boilerplate/lyft/golang_test_targets/download_tooling.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash

# Everything in this file needs to be installed outside of current module
# The reason we cannot turn off module entirely and install is that we need the replace statement in go.mod
# because we are installing a mockery fork. Turning it off would result installing the original not the fork.
# However, because the installation of these tools themselves sometimes modifies the go.mod/go.sum files. We don't
# want this either. So instead, we're going to copy those files into a temporary directory, do the installation, and
# ignore any changes made to the go mod files.
# (See https://github.com/golang/go/issues/30515 for some background context)

set -e

go_install_tool () {
tmp_dir=$(mktemp -d -t gotooling-XXXXXXXXXX)
echo "Installing $1 inside $tmp_dir"
cp go.mod go.sum "$tmp_dir"
pushd "$tmp_dir"
go get "$1"
popd
}

# List of tools to go get
# In the format of "<cli>:<package>" or ":<package>" if no cli
tools=(
"golangci-lint:github.com/golangci/golangci-lint/cmd/golangci-lint"
)

for tool in "${tools[@]}"
do
cli=$(echo "$tool" | cut -d':' -f1)
package=$(echo "$tool" | cut -d':' -f2)
command -v "$cli" || go_install_tool "$package"
done