Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lock binary dependencies to a specific commits / versions #2464

Merged
merged 7 commits into from
Oct 12, 2018
Merged
Show file tree
Hide file tree
Changes from all 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 .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ jobs:
name: Get metalinter
command: |
export PATH="$GOBIN:$PATH"
make get_tools
make get_dev_tools
- run:
name: Lint source
Expand Down
29 changes: 19 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ BUILD_FLAGS = -tags "${BUILD_TAGS}" -ldflags "-X github.com/cosmos/cosmos-sdk/ve
GCC := $(shell command -v gcc 2> /dev/null)
LEDGER_ENABLED ?= true
UNAME_S := $(shell uname -s)
GOTOOLS = \
github.com/golang/dep/cmd/dep \
github.com/alecthomas/gometalinter \
github.com/rakyll/statik
all: get_tools get_vendor_deps install install_examples install_cosmos-sdk-cli test_lint test

########################################
Expand Down Expand Up @@ -91,22 +95,27 @@ dist:
### Tools & dependencies

check_tools:
cd tools && $(MAKE) check_tools

check_dev_tools:
cd tools && $(MAKE) check_dev_tools
@# https://stackoverflow.com/a/25668869
@echo "Found tools: $(foreach tool,$(notdir $(GOTOOLS)),\
$(if $(shell which $(tool)),$(tool),$(error "No $(tool) in PATH")))"

update_tools:
cd tools && $(MAKE) update_tools
@echo "--> Updating tools to correct version"
./scripts/get_tools.sh

update_dev_tools:
cd tools && $(MAKE) update_dev_tools
@echo "--> Downloading linters (this may take awhile)"
$(GOPATH)/src/github.com/alecthomas/gometalinter/scripts/install.sh -b $(GOBIN)
go get -u github.com/tendermint/lint/golint

get_tools:
cd tools && $(MAKE) get_tools
@echo "--> Installing tools"
./scripts/get_tools.sh

get_dev_tools:
cd tools && $(MAKE) get_dev_tools
@echo "--> Downloading linters (this may take awhile)"
$(GOPATH)/src/github.com/alecthomas/gometalinter/scripts/install.sh -b $(GOBIN)
go get github.com/tendermint/lint/golint

get_vendor_deps:
@echo "--> Generating vendor directory via dep ensure"
Expand Down Expand Up @@ -181,8 +190,8 @@ test_cover:
@export VERSION=$(VERSION); bash tests/test_cover.sh

test_lint:
gometalinter.v2 --config=tools/gometalinter.json ./...
!(gometalinter.v2 --exclude /usr/lib/go/src/ --exclude client/lcd/statik/statik.go --disable-all --enable='errcheck' --vendor ./... | grep -v "client/")
gometalinter --config=tools/gometalinter.json ./...
!(gometalinter --exclude /usr/lib/go/src/ --exclude client/lcd/statik/statik.go --exclude 'vendor/*' --disable-all --enable='errcheck' --vendor ./... | grep -v "client/")
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" | xargs gofmt -d -s
dep status >> /dev/null
!(grep -n branch Gopkg.toml)
Expand Down
1 change: 1 addition & 0 deletions PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ IMPROVEMENTS
calls which includes dynamic consumption of value length.
* [types/decimal] \#2378 - Added truncate functionality to decimal
* [client] [\#1184](https://github.com/cosmos/cosmos-sdk/issues/1184) Remove unused `client/tx/sign.go`.
* [tools] \#2464 Lock binary dependencies to a specific version

* Tendermint

Expand Down
2 changes: 1 addition & 1 deletion client/lcd/certificates.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func generateSelfSignedCert(host string) (certBytes []byte, priv *ecdsa.PrivateK
KeyUsage: x509.KeyUsageKeyEncipherment | x509.KeyUsageDigitalSignature | x509.KeyUsageCertSign,
ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth},
BasicConstraintsValid: true,
IsCA: true,
IsCA: true,
}
hosts := strings.Split(host, ",")
for _, h := range hosts {
Expand Down
49 changes: 49 additions & 0 deletions scripts/get_tools.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/usr/bin/env bash
set -e

# This file downloads all of the binary dependencies we have, and checks out a
# specific git hash.
#
# repos it installs:
# github.com/golang/dep/cmd/dep
# gopkg.in/alecthomas/gometalinter.v2
# github.com/rakyll/statiik

## check if GOPATH is set
if [ -z ${GOPATH+x} ]; then
echo "please set GOPATH (https://github.com/golang/go/wiki/SettingGOPATH)"
exit 1
fi

mkdir -p "$GOPATH/src/github.com"
cd "$GOPATH/src/github.com" || exit 1

installFromGithub() {
repo=$1
commit=$2
# optional
subdir=$3
echo "--> Installing $repo ($commit)..."
if [ ! -d "$repo" ]; then
mkdir -p "$repo"
git clone "https://github.com/$repo.git" "$repo"
fi
if [ ! -z ${subdir+x} ] && [ ! -d "$repo/$subdir" ]; then
echo "ERROR: no such directory $repo/$subdir"
exit 1
fi
pushd "$repo" && \
git fetch origin && \
git checkout -q "$commit" && \
if [ ! -z ${subdir+x} ]; then cd "$subdir" || exit 1; fi && \
go install && \
if [ ! -z ${subdir+x} ]; then cd - || exit 1; fi && \
popd || exit 1
echo "--> Done"
echo ""
}

installFromGithub golang/dep 22125cfaa6ddc71e145b1535d4b7ee9744fefff2 cmd/dep
## gometalinter v2.0.11
installFromGithub alecthomas/gometalinter 17a7ffa42374937bfecabfb8d2efbd4db0c26741
installFromGithub rakyll/statik v0.1.5
170 changes: 0 additions & 170 deletions tools/Makefile

This file was deleted.

2 changes: 1 addition & 1 deletion tools/gometalinter.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
"Deadline": "500s",
"Vendor": true,
"Cyclo": 11,
"Exclude": ["/usr/lib/go/src/", "client/lcd/statik/statik.go"]
"Exclude": ["/usr/lib/go/src/", "client/lcd/statik/statik.go", "vendor/*"]
cwgoes marked this conversation as resolved.
Show resolved Hide resolved
}
6 changes: 3 additions & 3 deletions x/distribution/types/validator_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ func NewValidatorDistInfo(operatorAddr sdk.ValAddress, currentHeight int64) Vali
return ValidatorDistInfo{
OperatorAddr: operatorAddr,
FeePoolWithdrawalHeight: currentHeight,
Pool: DecCoins{},
PoolCommission: DecCoins{},
DelAccum: NewTotalAccum(currentHeight),
Pool: DecCoins{},
PoolCommission: DecCoins{},
DelAccum: NewTotalAccum(currentHeight),
}
}

Expand Down