Skip to content

Commit e3a32a6

Browse files
crodriguezvegachatton
andauthoredOct 26, 2022
chore: makefile cleanup/fixes (cosmos#2549)
* cleaning up makefile * chore: removing goimports (cosmos#2548) * more cleanup * missing files * empty new line at the end * fix dockerfile * rename import Co-authored-by: Carlos Rodriguez <[email protected]> Co-authored-by: Cian Hatton <[email protected]>
1 parent 35b6084 commit e3a32a6

File tree

8 files changed

+99
-543
lines changed

8 files changed

+99
-543
lines changed
 

‎.github/scripts/go-imports.sh

-20
This file was deleted.

‎.github/workflows/goimports.yaml

-9
This file was deleted.

‎Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ ADD testing testing
1212
ADD modules modules
1313
ADD LICENSE LICENSE
1414

15+
COPY contrib/devtools/Makefile contrib/devtools/Makefile
1516
COPY Makefile .
1617

1718
RUN make build

‎Makefile

+6-116
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ endif
9696
all: build lint test
9797

9898
# The below include contains the tools and runsim targets.
99-
#include contrib/devtools/Makefile
99+
include contrib/devtools/Makefile
100100

101101
###############################################################################
102102
### Build ###
@@ -114,47 +114,7 @@ $(BUILD_TARGETS): go.sum $(BUILDDIR)/
114114
$(BUILDDIR)/:
115115
mkdir -p $(BUILDDIR)/
116116

117-
build-simd-all: go.sum
118-
$(DOCKER) rm latest-build || true
119-
$(DOCKER) run --volume=$(CURDIR):/sources:ro \
120-
--env TARGET_PLATFORMS='linux/amd64 darwin/amd64 linux/arm64 windows/amd64' \
121-
--env APP=simd \
122-
--env VERSION=$(VERSION) \
123-
--env COMMIT=$(COMMIT) \
124-
--env LEDGER_ENABLED=$(LEDGER_ENABLED) \
125-
--name latest-build cosmossdk/rbuilder:latest
126-
$(DOCKER) cp -a latest-build:/home/builder/artifacts/ $(CURDIR)/
127-
128-
build-simd-linux: go.sum $(BUILDDIR)/
129-
$(DOCKER) rm latest-build || true
130-
$(DOCKER) run --volume=$(CURDIR):/sources:ro \
131-
--env TARGET_PLATFORMS='linux/amd64' \
132-
--env APP=simd \
133-
--env VERSION=$(VERSION) \
134-
--env COMMIT=$(COMMIT) \
135-
--env LEDGER_ENABLED=false \
136-
--name latest-build cosmossdk/rbuilder:latest
137-
$(DOCKER) cp -a latest-build:/home/builder/artifacts/ $(CURDIR)/
138-
cp artifacts/simd-*-linux-amd64 $(BUILDDIR)/simd
139-
140-
cosmovisor:
141-
$(MAKE) -C cosmovisor cosmovisor
142-
143-
.PHONY: build build-linux build-simd-all build-simd-linux cosmovisor
144-
145-
mocks: $(MOCKS_DIR)
146-
mockgen -source=client/account_retriever.go -package mocks -destination tests/mocks/account_retriever.go
147-
mockgen -package mocks -destination tests/mocks/tendermint_tm_db_DB.go github.com/tendermint/tm-db DB
148-
mockgen -source=types/module/module.go -package mocks -destination tests/mocks/types_module_module.go
149-
mockgen -source=types/invariant.go -package mocks -destination tests/mocks/types_invariant.go
150-
mockgen -source=types/router.go -package mocks -destination tests/mocks/types_router.go
151-
mockgen -source=types/handler.go -package mocks -destination tests/mocks/types_handler.go
152-
mockgen -package mocks -destination tests/mocks/grpc_server.go github.com/gogo/protobuf/grpc Server
153-
mockgen -package mocks -destination tests/mocks/tendermint_tendermint_libs_log_DB.go github.com/tendermint/tendermint/libs/log Logger
154-
.PHONY: mocks
155-
156-
$(MOCKS_DIR):
157-
mkdir -p $(MOCKS_DIR)
117+
.PHONY: build build-linux
158118

159119
distclean: clean
160120
clean:
@@ -179,7 +139,7 @@ go.sum: go.mod
179139
###############################################################################
180140

181141
update-swagger-docs: statik
182-
$(BINDIR)/statik -src=client/docs/swagger-ui -dest=client/docs -f -m
142+
$(BINDIR)/statik -src=docs/client/swagger-ui -dest=docs/client -f -m
183143
@if [ -n "$(git status --porcelain)" ]; then \
184144
echo "\033[91mSwagger docs are out of sync!!!\033[0m";\
185145
exit 1;\
@@ -318,11 +278,6 @@ test-cover:
318278
@export VERSION=$(VERSION); bash -x contrib/test_cover.sh
319279
.PHONY: test-cover
320280

321-
test-rosetta:
322-
docker build -t rosetta-ci:latest -f contrib/rosetta/node/Dockerfile .
323-
docker-compose -f contrib/rosetta/docker-compose.yaml up --abort-on-container-exit --exit-code-from test_rosetta --build
324-
.PHONY: test-rosetta
325-
326281
benchmark:
327282
@go test -mod=readonly -bench=. $(PACKAGES_NOSIMULATION)
328283
.PHONY: benchmark
@@ -338,43 +293,11 @@ lint-fix:
338293
golangci-lint run --fix --out-format=tab --issues-exit-code=0
339294
.PHONY: lint lint-fix
340295

341-
format: goimports
342-
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/docs/statik/statik.go" -not -path "./tests/mocks/*" -not -name '*.pb.go' -not -name '*.pb.gw.go' | xargs gofumpt -w
343-
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/docs/statik/statik.go" -not -path "./tests/mocks/*" -not -name '*.pb.go' -not -name '*.pb.gw.go' | xargs misspell -w
296+
format:
297+
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./docs/client/statik/statik.go" -not -path "./tests/mocks/*" -not -name '*.pb.go' -not -name '*.pb.gw.go' | xargs gofumpt -w
298+
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./docs/client/statik/statik.go" -not -path "./tests/mocks/*" -not -name '*.pb.go' -not -name '*.pb.gw.go' | xargs misspell -w
344299
.PHONY: format
345300

346-
goimports:
347-
$(DOCKER) run -v $(CURDIR):/ibc-go --rm -w "/ibc-go" cytopia/goimports -w -local 'github.com/cosmos/ibc-go' "$(CHANGED_GO_FILES)" &> /dev/null || echo "No changed go files to format"
348-
349-
goimports-all:
350-
$(DOCKER) run -v $(CURDIR):/ibc-go --rm -w "/ibc-go" cytopia/goimports -w -local 'github.com/cosmos/ibc-go' "$(ALL_GO_FILES)"
351-
352-
###############################################################################
353-
### Devdoc ###
354-
###############################################################################
355-
356-
DEVDOC_SAVE = docker commit `docker ps -a -n 1 -q` devdoc:local
357-
358-
devdoc-init:
359-
$(DOCKER) run -it -v "$(CURDIR):/go/src/github.com/cosmos/cosmos-sdk" -w "/go/src/github.com/cosmos/cosmos-sdk" tendermint/devdoc echo
360-
# TODO make this safer
361-
$(call DEVDOC_SAVE)
362-
363-
devdoc:
364-
$(DOCKER) run -it -v "$(CURDIR):/go/src/github.com/cosmos/cosmos-sdk" -w "/go/src/github.com/cosmos/cosmos-sdk" devdoc:local bash
365-
366-
devdoc-save:
367-
# TODO make this safer
368-
$(call DEVDOC_SAVE)
369-
370-
devdoc-clean:
371-
docker rmi -f $$(docker images -f "dangling=true" -q)
372-
373-
devdoc-update:
374-
docker pull tendermint/devdoc
375-
376-
.PHONY: devdoc devdoc-clean devdoc-init devdoc-save devdoc-update
377-
378301
###############################################################################
379302
### Protobuf ###
380303
###############################################################################
@@ -466,36 +389,3 @@ proto-update-deps:
466389
@perl -lp -i -e 'print q(option go_package = "github.com/confio/ics23/go";) if $$. == 4' $(CONFIO_TYPES)/proofs.proto
467390

468391
.PHONY: proto-all proto-gen proto-gen-any proto-swagger-gen proto-format proto-lint proto-check-breaking proto-update-deps
469-
470-
###############################################################################
471-
### Localnet ###
472-
###############################################################################
473-
474-
# Run a 4-node testnet locally
475-
localnet-start: build-linux localnet-stop
476-
$(if $(shell $(DOCKER) inspect -f '{{ .Id }}' cosmossdk/simd-env 2>/dev/null),$(info found image cosmossdk/simd-env),$(MAKE) -C contrib/images simd-env)
477-
if ! [ -f build/node0/simd/config/genesis.json ]; then $(DOCKER) run --rm \
478-
--user $(shell id -u):$(shell id -g) \
479-
-v $(BUILDDIR):/simd:Z \
480-
-v /etc/group:/etc/group:ro \
481-
-v /etc/passwd:/etc/passwd:ro \
482-
-v /etc/shadow:/etc/shadow:ro \
483-
cosmossdk/simd-env testnet --v 4 -o . --starting-ip-address 192.168.10.2 --keyring-backend=test ; fi
484-
docker-compose up -d
485-
486-
localnet-stop:
487-
docker-compose down
488-
489-
.PHONY: localnet-start localnet-stop
490-
491-
###############################################################################
492-
### rosetta ###
493-
###############################################################################
494-
# builds rosetta test data dir
495-
rosetta-data:
496-
-docker container rm data_dir_build
497-
docker build -t rosetta-ci:latest -f contrib/rosetta/node/Dockerfile .
498-
docker run --name data_dir_build -t rosetta-ci:latest sh /rosetta/data.sh
499-
docker cp data_dir_build:/tmp/data.tar.gz "$(CURDIR)/contrib/rosetta/node/data.tar.gz"
500-
docker container rm data_dir_build
501-
.PHONY: rosetta-data

‎contrib/devtools/Makefile

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
###
2+
# Find OS and Go environment
3+
# GO contains the Go binary
4+
# FS contains the OS file separator
5+
###
6+
ifeq ($(OS),Windows_NT)
7+
GO := $(shell where go.exe 2> NUL)
8+
FS := "\\"
9+
else
10+
GO := $(shell command -v go 2> /dev/null)
11+
FS := "/"
12+
endif
13+
14+
ifeq ($(GO),)
15+
$(error could not find go. Is it in PATH? $(GO))
16+
endif
17+
18+
###############################################################################
19+
### Functions ###
20+
###############################################################################
21+
22+
go_get = $(if $(findstring Windows_NT,$(OS)),\
23+
IF NOT EXIST $(GITHUBDIR)$(FS)$(1)$(FS) ( mkdir $(GITHUBDIR)$(FS)$(1) ) else (cd .) &\
24+
IF NOT EXIST $(GITHUBDIR)$(FS)$(1)$(FS)$(2)$(FS) ( cd $(GITHUBDIR)$(FS)$(1) && git clone https://github.com/$(1)/$(2) ) else (cd .) &\
25+
,\
26+
mkdir -p $(GITHUBDIR)$(FS)$(1) &&\
27+
(test ! -d $(GITHUBDIR)$(FS)$(1)$(FS)$(2) && cd $(GITHUBDIR)$(FS)$(1) && git clone https://github.com/$(1)/$(2)) || true &&\
28+
)\
29+
cd $(GITHUBDIR)$(FS)$(1)$(FS)$(2) && git fetch origin && git checkout -q $(3)
30+
31+
mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
32+
mkfile_dir := $(shell cd $(shell dirname $(mkfile_path)); pwd)
33+
34+
35+
###############################################################################
36+
### Tools ###
37+
###############################################################################
38+
39+
PREFIX ?= /usr/local
40+
BIN ?= $(PREFIX)/bin
41+
UNAME_S ?= $(shell uname -s)
42+
UNAME_M ?= $(shell uname -m)
43+
44+
GOPATH ?= $(shell $(GO) env GOPATH)
45+
GITHUBDIR := $(GOPATH)$(FS)src$(FS)github.com
46+
47+
BUF_VERSION ?= 0.11.0
48+
49+
TOOLS_DESTDIR ?= $(GOPATH)/bin
50+
STATIK = $(TOOLS_DESTDIR)/statik
51+
RUNSIM = $(TOOLS_DESTDIR)/runsim
52+
53+
tools: tools-stamp
54+
tools-stamp: statik runsim
55+
# Create dummy file to satisfy dependency and avoid
56+
# rebuilding when this Makefile target is hit twice
57+
# in a row.
58+
touch $@
59+
60+
# Install the runsim binary
61+
statik: $(STATIK)
62+
$(STATIK):
63+
@echo "Installing statik..."
64+
@go install github.com/rakyll/statik@v0.1.6
65+
66+
# Install the runsim binary
67+
runsim: $(RUNSIM)
68+
$(RUNSIM):
69+
@echo "Installing runsim..."
70+
@go install github.com/cosmos/tools/cmd/runsim@v1.0.0
71+
72+
tools-clean:
73+
rm -f $(STATIK) $(GOLANGCI_LINT) $(RUNSIM)
74+
rm -f tools-stamp
75+
76+
.PHONY: tools-clean statik runsim

‎contrib/test_cover.sh

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
PKGS=$(go list ./... | grep -v '/simapp')
5+
6+
set -e
7+
echo "mode: atomic" > coverage.txt
8+
for pkg in ${PKGS[@]}; do
9+
go test -v -timeout 30m -race -coverprofile=profile.out -covermode=atomic -tags='ledger test_ledger_mock' "$pkg"
10+
if [ -f profile.out ]; then
11+
tail -n +2 profile.out >> coverage.txt;
12+
rm profile.out
13+
fi
14+
done

‎testing/simapp/simd/cmd/root.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"github.com/cosmos/cosmos-sdk/server"
1717
serverconfig "github.com/cosmos/cosmos-sdk/server/config"
1818
servertypes "github.com/cosmos/cosmos-sdk/server/types"
19+
sdkcmd "github.com/cosmos/cosmos-sdk/simapp/simd/cmd"
1920
"github.com/cosmos/cosmos-sdk/snapshots"
2021
snapshottypes "github.com/cosmos/cosmos-sdk/snapshots/types"
2122
"github.com/cosmos/cosmos-sdk/store"
@@ -164,7 +165,7 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig) {
164165
genutilcli.ValidateGenesisCmd(simapp.ModuleBasics),
165166
AddGenesisAccountCmd(simapp.DefaultNodeHome),
166167
tmcli.NewCompletionCmd(rootCmd, true),
167-
testnetCmd(simapp.ModuleBasics, banktypes.GenesisBalancesIterator{}),
168+
sdkcmd.NewTestnetCmd(simapp.ModuleBasics, banktypes.GenesisBalancesIterator{}),
168169
debug.Cmd(),
169170
config.Cmd(),
170171
)

‎testing/simapp/simd/cmd/testnet.go

-397
This file was deleted.

0 commit comments

Comments
 (0)
Please sign in to comment.