From 8f5857fa303da435a6cda3e41f81928ba30dc27b Mon Sep 17 00:00:00 2001 From: Mario Karagiorgas Date: Wed, 11 Aug 2021 16:10:34 +0300 Subject: [PATCH] Remove upg branch dependency Makefile: separate testupg binary from build-linux Update README.md --- Makefile | 11 ++++------- networks/docker/Makefile | 2 +- networks/docker/test-upg/Dockerfile | 7 ++++++- networks/upg/README.md | 3 ++- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 71392560..82b382fd 100644 --- a/Makefile +++ b/Makefile @@ -49,10 +49,6 @@ BUILD_FLAGS := -tags "$(build_tags)" -ldflags '$(ldflags)' build: go build -mod=readonly $(BUILD_FLAGS) -o build/emd$(BIN_PREFIX) ./cmd/emd -emdupg: - docker run --rm --entrypoint cat emoney/test-upg /go/src/em-ledger/build/emd > "build/emdupg" - chmod +x "build/emdupg" - cosmovisor: go install github.com/cosmos/cosmos-sdk/cosmovisor/cmd/cosmovisor@latest @@ -73,16 +69,17 @@ install: build-test-upg: docker run --rm --entrypoint cat emoney/cosmovisor /go/bin/cosmovisor > build/cosmovisor chmod +x build/cosmovisor + docker run --rm --entrypoint cat emoney/test-upg /go/src/em-ledger/build/emd > "build/emdupg" + chmod +x "build/emdupg" docker run --rm --entrypoint cat emoney/test-upg /go/src/em-ledger/build/emd-linux > "build/emdupg-linux" chmod +x "build/emdupg-linux" - sed -i -e '/bep3.NewKeeper/r networks/upg/upgfunc.txt' app.go build-linux: # Linux images for docker-compose # CGO_ENABLED=0 added to solve this issue: https://stackoverflow.com/a/36308464 BIN_PREFIX=-linux LEDGER_ENABLED=false GOOS=linux GOARCH=amd64 $(MAKE) build -build-all: build-linux emdupg +build-all: build-linux build-test-upg $(MAKE) build build-docker: @@ -118,7 +115,7 @@ license: GO111MODULE=off go get github.com/google/addlicense/ addlicense -f LICENSE . -.PHONY: build build-linux emdupg cosmovisor clean test bdd-test build-docker license +.PHONY: build build-linux build-test-upg cosmovisor clean test bdd-test build-docker license ############################################################################### ### Protobuf ### diff --git a/networks/docker/Makefile b/networks/docker/Makefile index c6493f13..459c7d14 100644 --- a/networks/docker/Makefile +++ b/networks/docker/Makefile @@ -9,7 +9,7 @@ cosmovisor: docker build cosmovisor --tag emoney/cosmovisor test-upg: - docker build test-upg --tag emoney/test-upg + docker build test-upg --build-arg branch=$$(git rev-parse --abbrev-ref HEAD) --build-arg version=test-upg-0.2.0 --tag emoney/test-upg # todo (reviewer): please note the rest-server is not a command anymore. Please enable `api` section in `app.toml` instead diff --git a/networks/docker/test-upg/Dockerfile b/networks/docker/test-upg/Dockerfile index d70b47c0..d8cb6108 100644 --- a/networks/docker/test-upg/Dockerfile +++ b/networks/docker/test-upg/Dockerfile @@ -1,10 +1,15 @@ FROM golang:1.16-buster +ARG branch +ARG version + # checkout and build linux binary RUN cd /go/src && \ git clone https://github.com/e-money/em-ledger.git && \ cd em-ledger && \ - git checkout test-upg-0.2.0 && \ + git checkout $branch && \ + sed -i -e '/bep3.NewKeeper/r networks/upg/upgfunc.txt' app.go && \ + git tag $version && \ BIN_PREFIX=-linux LEDGER_ENABLED=false GOOS=linux GOARCH=amd64 make build # build MacOS binary diff --git a/networks/upg/README.md b/networks/upg/README.md index 519941dd..58a04c70 100644 --- a/networks/upg/README.md +++ b/networks/upg/README.md @@ -7,7 +7,7 @@ Please note if you'd rather test the upgrade module within the **e-money local-t ```shell cd em-ledger make build-docker -make build-linux +make build-all go test -v --tags="bdd" bdd_test.go upgrade_test.go ``` @@ -22,6 +22,7 @@ Note these scripts at **em-ledger/networks/upg**: * `startcv` (starts a single e-money node with cosmovisor) * `upg-sched` schedule an upgrade by passing the upgrade block height * `upg-sched-srv` optional documentation setup and schedule command for upgrading with server downloaded binary +* `upgfunc.txt` Go snippet to be inserted as the upgrade module handler in the *upgrade* binary. ### Components installation Build the revamped Docker, Linux artifacts