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

ci: generate zetacored CLI docs in a single file #2650

Closed
wants to merge 3 commits into from
Closed
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
GOOS: linux
GOARCH: ${{ env.CPU_ARCH }}
run: |
make install-testnet
make install
cp "$HOME"/go/bin/* ./
chmod a+x ./zetacored
./zetacored version
Expand Down
98 changes: 9 additions & 89 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ env:
- CC_linux_amd64=x86_64-linux-gnu-gcc
- CXX_linux_amd64=x86_64-linux-gnu-g++
- CC_windows_amd64=x86_64-w64-mingw32-gcc
- CXX_windows_amd64=x86_64-w64-mingw32-g++
- CXX_windows_amd64=x86_64-w64-mingw32-g++
- VERSION={{ .Version }}
- COMMIT={{ .Commit }}
- BUILDTIME={{ .Date }}
Expand All @@ -32,9 +32,9 @@ before:
- go mod tidy

builds:
- id: "zetacored_testnet"
- id: "zetacored"
main: ./cmd/zetacored
binary: "zetacored_testnet-{{ .Os }}-{{ .Arch }}"
binary: "zetacored-{{ .Os }}-{{ .Arch }}"
env:
- 'CC={{ index .Env (print "CC_" .Os "_" .Arch) }}'
- 'CXX={{ index .Env (print "CXX_" .Os "_" .Arch) }}'
Expand All @@ -48,9 +48,8 @@ builds:
ignore:
- goos: windows
goarch: arm64
flags: &default_testnet_flags
- -tags=TESTNET,pebbledb,ledger,cgo,netgo
- -installsuffix=static
flags: &default_flags
- -tags=pebbledb,ledger
ldflags: &default_ldflags
- -X github.com/cosmos/cosmos-sdk/version.Name=zetacore
- -X github.com/cosmos/cosmos-sdk/version.ServerName=zetacored
Expand All @@ -61,11 +60,11 @@ builds:
- -X github.com/zeta-chain/zetacore/common.Version={{ .Version }}
- -X github.com/zeta-chain/zetacore/common.CommitHash={{ .Env.COMMIT }}
- -X github.com/zeta-chain/zetacore/common.BuildTime=={{ .Env.BUILDTIME }}
- -X github.com/cosmos/cosmos-sdk/types.DBBackend=pebbledb
- -X github.com/cosmos/cosmos-sdk/types.DBBackend=pebbledb

- id: "zetaclientd_testnet"
- id: "zetaclientd"
main: ./cmd/zetaclientd
binary: "zetaclientd_testnet-{{ .Os }}-{{ .Arch }}"
binary: "zetaclientd-{{ .Os }}-{{ .Arch }}"
env:
- 'CC={{ index .Env (print "CC_" .Os "_" .Arch) }}'
- 'CXX={{ index .Env (print "CXX_" .Os "_" .Arch) }}'
Expand All @@ -79,88 +78,9 @@ builds:
ignore:
- goos: windows
goarch: arm64
flags: *default_testnet_flags
flags: *default_flags
ldflags: *default_ldflags

- id: "zetacored_mock_mainnet"
main: ./cmd/zetacored
binary: "zetacored_mock_mainnet-{{ .Os }}-{{ .Arch }}"
env:
- 'CC={{ index .Env (print "CC_" .Os "_" .Arch) }}'
- 'CXX={{ index .Env (print "CXX_" .Os "_" .Arch) }}'
goos:
- linux
- darwin
- windows
goarch:
- arm64
- amd64
ignore:
- goos: windows
goarch: arm64
flags: &default_mock_mainnet_flags
- -tags=MOCK_MAINNET,pebbledb,ledger,cgo
ldflags: *default_ldflags

- id: "zetaclientd_mock_mainnet"
main: ./cmd/zetaclientd
binary: "zetaclientd_mock_mainnet-{{ .Os }}-{{ .Arch }}"
env:
- 'CC={{ index .Env (print "CC_" .Os "_" .Arch) }}'
- 'CXX={{ index .Env (print "CXX_" .Os "_" .Arch) }}'
goos:
- linux
# - darwin
# - windows
goarch:
- arm64
- amd64
ignore:
- goos: windows
goarch: arm64
flags: *default_mock_mainnet_flags
ldflags: *default_ldflags

- id: "zetacored_mainnet"
main: ./cmd/zetacored
binary: "zetacored_mainnet-{{ .Os }}-{{ .Arch }}"
env:
- 'CC={{ index .Env (print "CC_" .Os "_" .Arch) }}'
- 'CXX={{ index .Env (print "CXX_" .Os "_" .Arch) }}'
goos:
- linux
- darwin
- windows
goarch:
- arm64
- amd64
ignore:
- goos: windows
goarch: arm64
flags: &default_mainnet_flags
- -tags=pebbledb,ledger,cgo
ldflags: *default_ldflags

- id: "zetaclientd_mainnet"
main: ./cmd/zetaclientd
binary: "zetaclientd_mainnet-{{ .Os }}-{{ .Arch }}"
env:
- 'CC={{ index .Env (print "CC_" .Os "_" .Arch) }}'
- 'CXX={{ index .Env (print "CXX_" .Os "_" .Arch) }}'
goos:
- linux
# - darwin
# - windows
goarch:
- arm64
- amd64
ignore:
- goos: windows
goarch: arm64
flags: *default_mainnet_flags
ldflags: *default_ldflags


archives:
- format: binary
name_template: "{{ .Binary }}"
Expand Down
72 changes: 72 additions & 0 deletions Dockerfile-versioned-source
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
FROM golang:1.19-alpine

ENV GOPATH /go
ENV GOOS=linux
ENV CGO_ENABLED=1

ARG old_version

RUN apk --no-cache add git make build-base jq openssh libusb-dev linux-headers bash curl tmux
RUN ssh-keygen -b 2048 -t rsa -f /root/.ssh/localtest.pem -q -N ""

WORKDIR /go/delivery/zeta-node

RUN mkdir -p $GOPATH/bin/old
RUN mkdir -p $GOPATH/bin/new

ENV NEW_VERSION=v42.0.0

# Build new release from the current source
COPY go.mod /go/delivery/zeta-node/
COPY go.sum /go/delivery/zeta-node/
RUN cd /go/delivery/zeta-node/ && go mod download
COPY . /go/delivery/zeta-node/
RUN cd /go/delivery/zeta-node/ && make install
RUN cd /go/delivery/zeta-node/ && make install-smoketest
RUN cp $GOPATH/bin/zetacored $GOPATH/bin/new/
RUN cp $GOPATH/bin/zetaclientd $GOPATH/bin/new/
RUN cp $GOPATH/bin/smoketest $GOPATH/bin/new/

# Checkout and build old binary
RUN git clone https://github.com/zeta-chain/node.git
RUN cd node && git fetch

RUN cd node && git checkout ${old_version}
RUN cd node && make install
RUN cd node && make install-smoketest
RUN cp $GOPATH/bin/zetacored $GOPATH/bin/old/
RUN cp $GOPATH/bin/zetaclientd $GOPATH/bin/old/
RUN cp $GOPATH/bin/smoketest $GOPATH/bin/old/

RUN git clone https://github.com/zeta-chain/cosmos-sdk.git
RUN cd cosmos-sdk && git checkout zetavisor-v0.1.5
RUN cd cosmos-sdk/cosmovisor && make zetavisor
#
#FROM golang:1.19-alpine

#RUN apk --no-cache add openssh jq tmux vim curl bash
RUN ssh-keygen -A
WORKDIR /root

RUN cp /root/.ssh/localtest.pem.pub /root/.ssh/authorized_keys

RUN cp /go/bin/zetaclientd /usr/local/bin
RUN cp /go/bin/zetacored /usr/local/bin
RUN cp /go/bin/smoketest /usr/local/bin
RUN cp /go/bin/zetavisor /usr/local/bin

COPY contrib/localnet/scripts /root
COPY contrib/localnet/preparams /root/preparams
COPY contrib/localnet/ssh_config /root/.ssh/config
COPY contrib/localnet/zetacored /root/zetacored
COPY contrib/localnet/tss /root/tss

RUN chmod 755 /root/*.sh
RUN chmod 700 /root/.ssh
RUN chmod 600 /root/.ssh/*

WORKDIR /usr/local/bin
ENV SHELL /bin/sh
EXPOSE 22

ENTRYPOINT ["/usr/sbin/sshd", "-D"]
102 changes: 49 additions & 53 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,11 @@ ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=zetacore \
-X github.com/zeta-chain/zetacore/common.BuildTime=$(BUILDTIME) \
-X github.com/cosmos/cosmos-sdk/types.DBBackend=pebbledb

BUILD_FLAGS := -ldflags '$(ldflags)' -tags PRIVNET,pebbledb,ledger
TESTNET_BUILD_FLAGS := -ldflags '$(ldflags)' -tags TESTNET,pebbledb,ledger
MOCK_MAINNET_BUILD_FLAGS := -ldflags '$(ldflags)' -tags MOCK_MAINNET,pebbledb,ledger
MAINNET_BUILD_FLAGS := -ldflags '$(ldflags)' -tags pebbledb,ledger
BUILD_FLAGS := -ldflags '$(ldflags)' -tags pebbledb,ledger

TEST_DIR?="./..."
TEST_BUILD_FLAGS := -tags TESTNET,pebbledb,ledger
PRIV_BUILD_FLAGS := -tags PRIVNET,pebbledb,ledger
TEST_BUILD_FLAGS := -tags pebbledb,ledger
HSM_BUILD_FLAGS := -tags pebbledb,ledger,hsm_test

clean: clean-binaries clean-dir clean-test-dir clean-coverage

Expand All @@ -39,6 +36,22 @@ clean-dir:

all: install

go.sum: go.mod
@echo "--> Ensure dependencies have not been modified"
GO111MODULE=on go mod verify

###############################################################################
### Test commands ###
###############################################################################

run-test:
@go test ${TEST_BUILD_FLAGS} ${TEST_DIR}

test :clean-test-dir run-test

test-hsm:
@go test ${HSM_BUILD_FLAGS} ${TEST_DIR}

test-coverage-exclude-core:
@go test ${TEST_BUILD_FLAGS} -v -coverprofile coverage.out $(go list ./... | grep -v /x/zetacore/)

Expand All @@ -57,21 +70,9 @@ clean-test-dir:
@rm -rf x/crosschain/client/querytests/.zetacored
@rm -rf x/observer/client/querytests/.zetacored

run-test:
@go test ${TEST_BUILD_FLAGS} ${TEST_DIR}

test :clean-test-dir run-test

test-priv:
@go test ${PRIV_BUILD_FLAGS} ${TEST_DIR}

gosec:
gosec -exclude-dir=localnet ./...

install-testnet: go.sum
@echo "--> Installing zetacored & zetaclientd"
@go install -mod=readonly $(TESTNET_BUILD_FLAGS) ./cmd/zetacored
@go install -mod=readonly $(TESTNET_BUILD_FLAGS) ./cmd/zetaclientd
###############################################################################
### Install commands ###
###############################################################################

build-testnet-ubuntu: go.sum
docker build -t zetacore-ubuntu --platform linux/amd64 -f ./Dockerfile-athens3-ubuntu .
Expand All @@ -85,44 +86,26 @@ install: go.sum
@go install -race -mod=readonly $(BUILD_FLAGS) ./cmd/zetacored
@go install -race -mod=readonly $(BUILD_FLAGS) ./cmd/zetaclientd

install-mainnet: go.sum
@echo "--> Installing zetacored & zetaclientd"
@go install -mod=readonly $(MAINNET_BUILD_FLAGS) ./cmd/zetacored
@go install -mod=readonly $(MAINNET_BUILD_FLAGS) ./cmd/zetaclientd

install-mock-mainnet: go.sum
@echo "--> Installing zetacored & zetaclientd"
@go install -mod=readonly $(MOCK_MAINNET_BUILD_FLAGS) ./cmd/zetacored
@go install -mod=readonly $(MOCK_MAINNET_BUILD_FLAGS) ./cmd/zetaclientd


install-zetaclient: go.sum
@echo "--> Installing zetaclientd"
@go install -mod=readonly $(BUILD_FLAGS) ./cmd/zetaclientd

# running with race detector on will be slow
install-zetaclient-race-test-only-build: go.sum
@echo "--> Installing zetaclientd"
@go install -race -mod=readonly $(BUILD_FLAGS) ./cmd/zetaclientd

install-zetacore: go.sum
@echo "--> Installing zetacored"
@go install -mod=readonly $(BUILD_FLAGS) ./cmd/zetacored

install-zetacore-testnet: go.sum
@echo "--> Installing zetacored"
@go install -mod=readonly $(TESTNET_BUILD_FLAGS) ./cmd/zetacored
# running with race detector on will be slow
install-zetaclient-race-test-only-build: go.sum
@echo "--> Installing zetaclientd"
@go install -race -mod=readonly $(BUILD_FLAGS) ./cmd/zetaclientd

install-smoketest: go.sum
@echo "--> Installing orchestrator"
@go install -mod=readonly $(BUILD_FLAGS) ./contrib/localnet/orchestrator/smoketest

go.sum: go.mod
@echo "--> Ensure dependencies have not been modified"
GO111MODULE=on go mod verify

test-cctx:
./standalone-network/cctx-creator.sh
###############################################################################
### Local network ###
###############################################################################

init:
./standalone-network/init.sh
Expand All @@ -136,12 +119,12 @@ chain-stop:
@killall zetacored
@killall tail

test-cctx:
./standalone-network/cctx-creator.sh

chain-init-testnet: clean install-zetacore-testnet init
chain-run-testnet: clean install-zetacore-testnet init run

chain-init-mock-mainnet: clean install-mock-mainnet init
chain-run-mock-mainnet: clean install-mock-mainnet init run
###############################################################################
### Linting ###
###############################################################################

lint-pre:
@test -z $(gofmt -l .)
Expand All @@ -153,6 +136,13 @@ lint: lint-pre
lint-cosmos-gosec:
@bash ./scripts/cosmos-gosec.sh

gosec:
gosec -exclude-dir=localnet ./...

###############################################################################
### Generation commands ###
###############################################################################

proto:
@echo "--> Removing old Go types "
@find . -name '*.pb.go' -type f -delete
Expand Down Expand Up @@ -193,7 +183,7 @@ generate: proto openapi specs typescript docs-zetacored
.PHONY: generate

###############################################################################
### Docker Images ###
### Smoke tests ###
###############################################################################

zetanode:
Expand Down Expand Up @@ -237,13 +227,19 @@ stateful-upgrade:
$(DOCKER) build -t orchestrator -f contrib/localnet/orchestrator/Dockerfile-upgrade.fastbuild .
cd contrib/localnet/ && $(DOCKER) compose -f docker-compose-stateful.yml up -d

stateful-upgrade-source:
@echo "--> Starting stateful smoketest"
$(DOCKER) build --build-arg old_version=v10.1.7 -t zetanode -f ./Dockerfile-versioned-source .
$(DOCKER) build -t orchestrator -f contrib/localnet/orchestrator/Dockerfile-upgrade.fastbuild .
cd contrib/localnet/ && $(DOCKER) compose -f docker-compose-stateful.yml up -d

stop-stateful-upgrade:
cd contrib/localnet/ && $(DOCKER) compose -f docker-compose-stateful.yml down --remove-orphans


###############################################################################
### GoReleaser ###
###############################################################################

PACKAGE_NAME := github.com/zeta-chain/node
GOLANG_CROSS_VERSION ?= v1.20
GOPATH ?= '$(HOME)/go'
Expand Down
Loading
Loading