Skip to content
This repository was archived by the owner on Nov 30, 2021. It is now read-only.

Commit 69333ec

Browse files
authored
circleCI config and linting fixes (#3)
* Fixed circleci config and fixed linting warnings * Updated circleCI for go version 1.12 and split jobs for build/testing * updated go version to 1.12.5 for circleCI * Go mod tidy dependencies * Updated linting tools and cleared up code lint smells * Added workflow to run build and test jobs * Moved linting command to build workflow * Get dependencies before linting by default * Added go module flag to linter and increased deadline to pull packages
1 parent 18d57af commit 69333ec

File tree

15 files changed

+396
-97
lines changed

15 files changed

+396
-97
lines changed

.circleci/config.yml

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,51 @@ version: 2
22
jobs:
33
build:
44
docker:
5-
- image: circleci/golang:1.10
5+
- image: circleci/golang:1.12.5
66

77
working_directory: /go/src/github.com/cosmos/ethermint
88

99
steps:
1010
- checkout
11-
11+
- restore_cache:
12+
keys:
13+
- go-mod-v0-{{ checksum "go.sum" }}
14+
- run:
15+
name: Get tools and verify dependencies
16+
command: make tools verify
17+
- run:
18+
name: Run linter
19+
command: make test-lint
1220
- run:
13-
name: "Install tools and dependancies"
14-
command: make tools deps
21+
name: Compile binaries for daemon and cli
22+
command: make build
23+
- save_cache:
24+
key: go-mod-v0-{{ checksum "go.sum" }}
25+
paths:
26+
- "/go/pkg/mod"
27+
28+
test:
29+
docker:
30+
- image: circleci/golang:1.12.5
1531

32+
working_directory: /go/src/github.com/cosmos/ethermint
33+
34+
steps:
35+
- checkout
36+
- restore_cache:
37+
keys:
38+
- go-mod-v0-{{ checksum "go.sum" }}
1639
- run:
17-
name: "Run tests"
18-
command: make test-lint test-unit test-import
40+
name: Run all tests
41+
command: make test-unit test-import
42+
- save_cache:
43+
key: go-mod-v0-{{ checksum "go.sum" }}
44+
paths:
45+
- "/go/pkg/mod"
46+
47+
workflows:
48+
version: 2
49+
build-workflow:
50+
jobs:
51+
- build
52+
- test

Makefile

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ clean:
4545

4646
update-tools:
4747
@echo "--> Updating vendor dependencies"
48-
${GO_MOD} go get -u -v $(GOLINT) $(GOMETALINTER) $(UNCONVERT) $(INEFFASSIGN) $(MISSPELL) $(ERRCHECK) $(UNPARAM)
48+
${GO_MOD} go get -u -v $(GOLINT) $(UNCONVERT) $(INEFFASSIGN) $(MISSPELL) $(ERRCHECK) $(UNPARAM)
49+
${GO_MOD} go get -v $(GOCILINT)
4950

5051
verify:
5152
@echo "--> Verifying dependencies have not been modified"
@@ -61,15 +62,15 @@ verify:
6162
##########################################################
6263

6364
GOLINT = github.com/tendermint/lint/golint
64-
GOMETALINTER = gopkg.in/alecthomas/gometalinter.v2
65+
GOCILINT = github.com/golangci/golangci-lint/cmd/golangci-lint@v1.17.1
6566
UNCONVERT = github.com/mdempsky/unconvert
6667
INEFFASSIGN = github.com/gordonklaus/ineffassign
6768
MISSPELL = github.com/client9/misspell/cmd/misspell
6869
ERRCHECK = github.com/kisielk/errcheck
6970
UNPARAM = mvdan.cc/unparam
7071

7172
GOLINT_CHECK := $(shell command -v golint 2> /dev/null)
72-
GOMETALINTER_CHECK := $(shell command -v gometalinter.v2 2> /dev/null)
73+
GOCILINT_CHECK := $(shell command -v golangci-lint 2> /dev/null)
7374
UNCONVERT_CHECK := $(shell command -v unconvert 2> /dev/null)
7475
INEFFASSIGN_CHECK := $(shell command -v ineffassign 2> /dev/null)
7576
MISSPELL_CHECK := $(shell command -v misspell 2> /dev/null)
@@ -83,11 +84,11 @@ else
8384
@echo "--> Installing golint"
8485
${GO_MOD} go get -v $(GOLINT)
8586
endif
86-
ifdef GOMETALINTER_CHECK
87-
@echo "Gometalinter.v2 is already installed. Run 'make update-tools' to update."
87+
ifdef GOCILINT_CHECK
88+
@echo "golangci-lint is already installed. Run 'make update-tools' to update."
8889
else
89-
@echo "--> Installing gometalinter.v2"
90-
${GO_MOD} go get -v $(GOMETALINTER)
90+
@echo "--> Installing golangci-lint"
91+
${GO_MOD} go get -v $(GOCILINT)
9192
endif
9293
ifdef UNCONVERT_CHECK
9394
@echo "Unconvert is already installed. Run 'make update-tools' to update."
@@ -137,8 +138,8 @@ test-cli:
137138
@echo "NO CLI TESTS"
138139

139140
test-lint:
140-
@echo "--> Running gometalinter..."
141-
@gometalinter.v2 --config=gometalinter.json --exclude=vendor ./...
141+
@echo "--> Running golangci-lint..."
142+
@${GO_MOD} golangci-lint run --deadline=5m ./...
142143

143144
test-import:
144145
@${GO_MOD} go test ./importer -v --vet=off --run=TestImportBlocks --datadir tmp \

app/ante.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import (
1919

2020
const (
2121
memoCostPerByte sdk.Gas = 3
22-
secp256k1VerifyCost = 21000
22+
secp256k1VerifyCost uint64 = 21000
2323
)
2424

2525
// NewAnteHandler returns an ante handler responsible for attempting to route an

app/ante_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,12 @@ func TestValidEthTx(t *testing.T) {
5555
addr2, _ := newTestAddrKey()
5656

5757
acc1 := input.accKeeper.NewAccountWithAddress(input.ctx, addr1)
58+
// nolint:errcheck
5859
acc1.SetCoins(newTestCoins())
5960
input.accKeeper.SetAccount(input.ctx, acc1)
6061

6162
acc2 := input.accKeeper.NewAccountWithAddress(input.ctx, addr2)
63+
// nolint:errcheck
6264
acc2.SetCoins(newTestCoins())
6365
input.accKeeper.SetAccount(input.ctx, acc2)
6466

@@ -80,10 +82,12 @@ func TestValidTx(t *testing.T) {
8082
addr2, priv2 := newTestAddrKey()
8183

8284
acc1 := input.accKeeper.NewAccountWithAddress(input.ctx, addr1)
85+
// nolint:errcheck
8386
acc1.SetCoins(newTestCoins())
8487
input.accKeeper.SetAccount(input.ctx, acc1)
8588

8689
acc2 := input.accKeeper.NewAccountWithAddress(input.ctx, addr2)
90+
// nolint:errcheck
8791
acc2.SetCoins(newTestCoins())
8892
input.accKeeper.SetAccount(input.ctx, acc2)
8993

@@ -115,10 +119,12 @@ func TestSDKInvalidSigs(t *testing.T) {
115119
addr3, priv3 := newTestAddrKey()
116120

117121
acc1 := input.accKeeper.NewAccountWithAddress(input.ctx, addr1)
122+
// nolint:errcheck
118123
acc1.SetCoins(newTestCoins())
119124
input.accKeeper.SetAccount(input.ctx, acc1)
120125

121126
acc2 := input.accKeeper.NewAccountWithAddress(input.ctx, addr2)
127+
// nolint:errcheck
122128
acc2.SetCoins(newTestCoins())
123129
input.accKeeper.SetAccount(input.ctx, acc2)
124130

@@ -164,6 +170,7 @@ func TestSDKInvalidAcc(t *testing.T) {
164170
addr1, priv1 := newTestAddrKey()
165171

166172
acc1 := input.accKeeper.NewAccountWithAddress(input.ctx, addr1)
173+
// nolint:errcheck
167174
acc1.SetCoins(newTestCoins())
168175
input.accKeeper.SetAccount(input.ctx, acc1)
169176

@@ -211,7 +218,9 @@ func TestEthInvalidNonce(t *testing.T) {
211218
addr2, _ := newTestAddrKey()
212219

213220
acc := input.accKeeper.NewAccountWithAddress(input.ctx, addr1)
221+
// nolint:errcheck
214222
acc.SetCoins(newTestCoins())
223+
// nolint:errcheck
215224
acc.SetSequence(10)
216225
input.accKeeper.SetAccount(input.ctx, acc)
217226

@@ -253,6 +262,7 @@ func TestEthInvalidIntrinsicGas(t *testing.T) {
253262
addr2, _ := newTestAddrKey()
254263

255264
acc := input.accKeeper.NewAccountWithAddress(input.ctx, addr1)
265+
// nolint:errcheck
256266
acc.SetCoins(newTestCoins())
257267
input.accKeeper.SetAccount(input.ctx, acc)
258268

@@ -276,6 +286,7 @@ func TestEthInvalidMempoolFees(t *testing.T) {
276286
addr2, _ := newTestAddrKey()
277287

278288
acc := input.accKeeper.NewAccountWithAddress(input.ctx, addr1)
289+
// nolint:errcheck
279290
acc.SetCoins(newTestCoins())
280291
input.accKeeper.SetAccount(input.ctx, acc)
281292

@@ -297,6 +308,7 @@ func TestEthInvalidChainID(t *testing.T) {
297308
addr2, _ := newTestAddrKey()
298309

299310
acc := input.accKeeper.NewAccountWithAddress(input.ctx, addr1)
311+
// nolint:errcheck
300312
acc.SetCoins(newTestCoins())
301313
input.accKeeper.SetAccount(input.ctx, acc)
302314

app/ethermint.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"github.com/cosmos/cosmos-sdk/codec"
66
sdk "github.com/cosmos/cosmos-sdk/types"
77
"github.com/cosmos/cosmos-sdk/x/auth"
8-
"github.com/cosmos/cosmos-sdk/x/bank"
98
"github.com/cosmos/cosmos-sdk/x/gov"
109
"github.com/cosmos/cosmos-sdk/x/params"
1110
"github.com/cosmos/cosmos-sdk/x/slashing"
@@ -56,9 +55,9 @@ type (
5655
paramsKey *sdk.KVStoreKey
5756
tParamsKey *sdk.TransientStoreKey
5857

59-
accountKeeper auth.AccountKeeper
60-
feeCollKeeper auth.FeeCollectionKeeper
61-
coinKeeper bank.Keeper
58+
accountKeeper auth.AccountKeeper
59+
feeCollKeeper auth.FeeCollectionKeeper
60+
// coinKeeper bank.Keeper
6261
stakeKeeper stake.Keeper
6362
slashingKeeper slashing.Keeper
6463
govKeeper gov.Keeper

app/test_utils.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ func newTestSetup() testSetup {
4242
ms.MountStoreWithDB(feeCapKey, sdk.StoreTypeIAVL, db)
4343
ms.MountStoreWithDB(keyParams, sdk.StoreTypeIAVL, db)
4444
ms.MountStoreWithDB(tkeyParams, sdk.StoreTypeIAVL, db)
45+
// nolint:errcheck
4546
ms.LoadLatestVersion()
4647

4748
cdc := CreateCodec()

core/chain.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ type ChainContext struct {
2626
headersByNumber map[uint64]*ethtypes.Header
2727
}
2828

29+
// NewChainContext generates new ChainContext based on Ethereum's core.ChainContext and
30+
// consensus.Engine interfaces in order to process Ethereum transactions.
2931
func NewChainContext() *ChainContext {
3032
return &ChainContext{
3133
headersByNumber: make(map[uint64]*ethtypes.Header),

go.mod

Lines changed: 70 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -3,67 +3,81 @@ module github.com/cosmos/ethermint
33
go 1.12
44

55
require (
6-
github.com/allegro/bigcache v1.2.1 // indirect
7-
github.com/aristanetworks/goarista v0.0.0-20181101003910-5bb443fba8e0
8-
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973
9-
github.com/btcsuite/btcd v0.0.0-20181013004428-67e573d211ac
10-
github.com/btcsuite/btcutil v0.0.0-20180524032703-d4cc87b86016
6+
github.com/VividCortex/gohistogram v1.0.0 // indirect
7+
github.com/aristanetworks/goarista v0.0.0-20181101003910-5bb443fba8e0 // indirect
8+
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973 // indirect
9+
github.com/btcsuite/btcd v0.0.0-20181013004428-67e573d211ac // indirect
10+
github.com/btcsuite/btcutil v0.0.0-20180524032703-d4cc87b86016 // indirect
11+
github.com/cespare/cp v1.1.1 // indirect
12+
github.com/client9/misspell v0.3.4 // indirect
1113
github.com/cosmos/cosmos-sdk v0.0.0-20181218000439-ec9c4ea543b5
12-
github.com/davecgh/go-spew v1.1.1
13-
github.com/deckarep/golang-set v1.7.1
14-
github.com/edsrzf/mmap-go v0.0.0-20170320065105-0bce6a688712
14+
github.com/deckarep/golang-set v1.7.1 // indirect
15+
github.com/edsrzf/mmap-go v0.0.0-20170320065105-0bce6a688712 // indirect
16+
github.com/elastic/gosigar v0.10.3 // indirect
1517
github.com/ethereum/go-ethereum v1.8.27
16-
github.com/fsnotify/fsnotify v1.4.7
17-
github.com/go-kit/kit v0.6.0
18-
github.com/go-logfmt/logfmt v0.3.0
19-
github.com/go-stack/stack v1.8.0
20-
github.com/gogo/protobuf v1.1.1
21-
github.com/golang/protobuf v1.1.0
22-
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db
23-
github.com/google/uuid v1.0.0
24-
github.com/gorilla/websocket v1.2.0
25-
github.com/hashicorp/golang-lru v0.5.0
26-
github.com/hashicorp/hcl v1.0.0
27-
github.com/huin/goupnp v1.0.0
28-
github.com/inconshreveable/mousetrap v1.0.0
29-
github.com/jackpal/go-nat-pmp v1.0.1
30-
github.com/jmhodges/levigo v0.0.0-20161115193449-c42d9e0ca023
31-
github.com/karalabe/hid v0.0.0-20180420081245-2b4488a37358
32-
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515
33-
github.com/magiconair/properties v1.8.0
34-
github.com/matttproud/golang_protobuf_extensions v1.0.1
35-
github.com/mitchellh/mapstructure v1.1.2
36-
github.com/pborman/uuid v0.0.0-20180906182336-adf5a7427709
37-
github.com/pelletier/go-toml v1.2.0
18+
github.com/fjl/memsize v0.0.0-20180929194037-2a09253e352a // indirect
19+
github.com/fortytw2/leaktest v1.3.0 // indirect
20+
github.com/go-kit/kit v0.6.0 // indirect
21+
github.com/go-logfmt/logfmt v0.3.0 // indirect
22+
github.com/go-stack/stack v1.8.0 // indirect
23+
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b // indirect
24+
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db // indirect
25+
github.com/golangci/golangci-lint v1.17.1 // indirect
26+
github.com/google/gofuzz v1.0.0 // indirect
27+
github.com/google/uuid v1.0.0 // indirect
28+
github.com/gordonklaus/ineffassign v0.0.0-20190601041439-ed7b1b5ee0f8 // indirect
29+
github.com/gorilla/websocket v1.2.0 // indirect
30+
github.com/hashicorp/golang-lru v0.5.0 // indirect
31+
github.com/hashicorp/hcl v1.0.0 // indirect
32+
github.com/huin/goupnp v1.0.0 // indirect
33+
github.com/influxdata/influxdb v1.7.7 // indirect
34+
github.com/jackpal/go-nat-pmp v1.0.1 // indirect
35+
github.com/jmhodges/levigo v0.0.0-20161115193449-c42d9e0ca023 // indirect
36+
github.com/karalabe/hid v0.0.0-20180420081245-2b4488a37358 // indirect
37+
github.com/kisielk/errcheck v1.2.0 // indirect
38+
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515 // indirect
39+
github.com/kr/pty v1.1.8 // indirect
40+
github.com/magiconair/properties v1.8.0 // indirect
41+
github.com/mattn/go-colorable v0.1.2 // indirect
42+
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
43+
github.com/mdempsky/unconvert v0.0.0-20190325185700-2f5dc3378ed3 // indirect
44+
github.com/mitchellh/mapstructure v1.1.2 // indirect
45+
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
46+
github.com/onsi/ginkgo v1.8.0 // indirect
47+
github.com/onsi/gomega v1.5.0 // indirect
48+
github.com/pborman/uuid v0.0.0-20180906182336-adf5a7427709 // indirect
49+
github.com/pelletier/go-toml v1.2.0 // indirect
3850
github.com/pkg/errors v0.8.0
39-
github.com/pmezard/go-difflib v1.0.0
40-
github.com/prometheus/client_golang v0.9.1
41-
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910
42-
github.com/prometheus/common v0.0.0-20181109100915-0b1957f9d949
43-
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d
44-
github.com/rcrowley/go-metrics v0.0.0-20180503174638-e2704e165165
45-
github.com/rjeczalik/notify v0.9.2
46-
github.com/rs/cors v1.6.0
47-
github.com/spf13/afero v1.1.2
48-
github.com/spf13/cast v1.3.0
49-
github.com/spf13/cobra v0.0.1
50-
github.com/spf13/jwalterweatherman v1.0.0
51-
github.com/spf13/pflag v1.0.3
52-
github.com/spf13/viper v1.0.0
51+
github.com/prometheus/client_golang v0.9.1 // indirect
52+
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910 // indirect
53+
github.com/prometheus/common v0.0.0-20181109100915-0b1957f9d949 // indirect
54+
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d // indirect
55+
github.com/rcrowley/go-metrics v0.0.0-20180503174638-e2704e165165 // indirect
56+
github.com/rjeczalik/notify v0.9.2 // indirect
57+
github.com/rogpeppe/go-internal v1.3.0 // indirect
58+
github.com/rs/cors v1.6.0 // indirect
59+
github.com/spf13/afero v1.1.2 // indirect
60+
github.com/spf13/cast v1.3.0 // indirect
61+
github.com/spf13/jwalterweatherman v1.0.0 // indirect
62+
github.com/spf13/pflag v1.0.3 // indirect
5363
github.com/stretchr/testify v1.2.2
54-
github.com/syndtr/goleveldb v0.0.0-20181105012736-f9080354173f
55-
github.com/tendermint/btcd v0.1.0
56-
github.com/tendermint/go-amino v0.14.1
57-
github.com/tendermint/iavl v0.12.0
64+
github.com/syndtr/goleveldb v0.0.0-20181105012736-f9080354173f // indirect
65+
github.com/tendermint/btcd v0.1.0 // indirect
66+
github.com/tendermint/go-amino v0.14.1 // indirect
67+
github.com/tendermint/iavl v0.12.0 // indirect
68+
github.com/tendermint/lint v0.0.1 // indirect
5869
github.com/tendermint/tendermint v0.27.0
59-
golang.org/x/crypto v0.0.0-20190618222545-ea8f1a30c443 // indirect
60-
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3
61-
golang.org/x/sys v0.0.0-20190412213103-97732733099d
62-
golang.org/x/text v0.3.0
63-
google.golang.org/genproto v0.0.0-20181107211654-5fc9ac540362
64-
google.golang.org/grpc v1.13.0
65-
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce
66-
gopkg.in/yaml.v2 v2.2.1
70+
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4 // indirect
71+
golang.org/x/net v0.0.0-20190628185345-da137c7871d7 // indirect
72+
golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb // indirect
73+
golang.org/x/text v0.3.2 // indirect
74+
golang.org/x/tools v0.0.0-20190702152245-7e72c71c505f // indirect
75+
google.golang.org/genproto v0.0.0-20181107211654-5fc9ac540362 // indirect
76+
google.golang.org/grpc v1.13.0 // indirect
77+
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
78+
gopkg.in/olebedev/go-duktape.v3 v3.0.0-20190213234257-ec84240a7772 // indirect
79+
gopkg.in/urfave/cli.v1 v1.20.0 // indirect
80+
mvdan.cc/unparam v0.0.0-20190310220240-1b9ccfa71afe // indirect
6781
)
6882

6983
replace github.com/ethereum/go-ethereum v1.8.27 => github.com/alexanderbez/go-ethereum v1.8.17-0.20181024144731-0a57b29f0c8e

0 commit comments

Comments
 (0)