Skip to content

Commit

Permalink
Merge pull request #853 from axone-protocol/build/heighliner
Browse files Browse the repository at this point in the history
Build/heighliner
  • Loading branch information
ccamel authored Dec 22, 2024
2 parents 55b88c3 + 2d77b6e commit 8fe4cfa
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:

- name: Build go project
run: |
make build
make build-go
build-docker:
runs-on: ubuntu-22.04
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ jobs:

- name: Install AXONE blockchain
run: |
make build && make install
make build-go && make install
- name: Initialize blockchain
run: |
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ RUN set -eux \

COPY . /src/

RUN BUILD_TAGS=muslc LINK_STATICALLY=true make build
RUN BUILD_TAGS=muslc LINK_STATICALLY=true make build-go

#--- Image stage
FROM alpine:3.20.3
Expand Down
47 changes: 37 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,15 @@ DOCKER_IMAGE_MARKDOWNLINT = thegeeklab/markdownlint-cli:0.32.2
DOCKER_IMAGE_GOTEMPLATE = hairyhenderson/gomplate:v3.11.3-alpine

# Tools
TOOL_TPARSE_NAME := tparse
TOOL_TPARSE_VERSION := v0.16.0
TOOL_TPARSE_PKG := github.com/mfridman/$(TOOL_TPARSE_NAME)@$(TOOL_TPARSE_VERSION)
TOOL_TPARSE_BIN := ${TOOLS_FOLDER}/$(TOOL_TPARSE_NAME)/$(TOOL_TPARSE_VERSION)/$(TOOL_TPARSE_NAME)
TOOL_TPARSE_NAME := tparse
TOOL_TPARSE_VERSION := v0.16.0
TOOL_TPARSE_PKG := github.com/mfridman/$(TOOL_TPARSE_NAME)@$(TOOL_TPARSE_VERSION)
TOOL_TPARSE_BIN := ${TOOLS_FOLDER}/$(TOOL_TPARSE_NAME)/$(TOOL_TPARSE_VERSION)/$(TOOL_TPARSE_NAME)

TOOL_HEIGHLINER_NAME := heighliner
TOOL_HEIGHLINER_VERSION := v1.7.1
TOOL_HEIGHLINER_PKG := github.com/strangelove-ventures/$(TOOL_HEIGHLINER_NAME)@$(TOOL_HEIGHLINER_VERSION)
TOOL_HEIGHLINER_BIN := ${TOOLS_FOLDER}/$(TOOL_HEIGHLINER_NAME)/$(TOOL_HEIGHLINER_VERSION)/$(TOOL_HEIGHLINER_NAME)

# Some colors (if supported)
define get_color
Expand Down Expand Up @@ -168,7 +173,7 @@ format-proto: ## Format proto files

## Build:
.PHONY: build
build: build-go ## Build all available artefacts (executable, docker image, etc.)
build: build-go build-docker ## Build all available artefacts (executable, docker image, etc.)

.PHONY: build-go
build-go: ## Build node executable for the current environment (default build)
Expand All @@ -177,6 +182,11 @@ build-go: ## Build node executable for the current environment (default build)

build-go-all: $(ENVIRONMENTS_TARGETS) ## Build node executables for all available environments

.PHONY: build-docker
build-docker: $(TOOL_HEIGHLINER_BIN) ## Build docker image
@echo "${COLOR_CYAN} 🐳 Building local ${COLOR_RESET}docker${COLOR_CYAN} image${COLOR_RESET}"
@$(TOOL_HEIGHLINER_BIN) build -c axone --local

$(ENVIRONMENTS_TARGETS):
@GOOS=$(word 3, $(subst -, ,$@)); \
GOARCH=$(word 4, $(subst -, ,$@)); \
Expand Down Expand Up @@ -213,7 +223,7 @@ test-go: $(TOOL_TPARSE_BIN) build ## Pass the test for the go source code
@go test -v -coverprofile ./target/coverage.txt ./... -json | $(TOOL_TPARSE_BIN)

## Chain:
chain-init: build ## Initialize the blockchain with default settings.
chain-init: build-go ## Initialize the blockchain with default settings.
@echo "${COLOR_CYAN} 🛠️ Initializing chain ${COLOR_RESET}${CHAIN}${COLOR_CYAN} under ${COLOR_YELLOW}${CHAIN_HOME}${COLOR_RESET}"

@rm -rf "${CHAIN_HOME}"; \
Expand Down Expand Up @@ -245,7 +255,7 @@ chain-init: build ## Initialize the blockchain with default settings.
${CHAIN_BINARY} genesis collect-gentxs \
--home "${CHAIN_HOME}"

chain-start: build ## Start the blockchain with existing configuration (see chain-init)
chain-start: build-go ## Start the blockchain with existing configuration (see chain-init)
@echo "${COLOR_CYAN} 🛠️ Starting chain ${COLOR_RESET}${CHAIN}${COLOR_CYAN} with configuration ${COLOR_YELLOW}${CHAIN_HOME}${COLOR_RESET}"; \
${CHAIN_BINARY} start --moniker ${CHAIN_MONIKER} \
--home ${CHAIN_HOME}
Expand All @@ -254,14 +264,14 @@ chain-stop: ## Stop the blockchain
@echo "${COLOR_CYAN} ✋️ Stopping chain ${COLOR_RESET}${CHAIN}${COLOR_CYAN} with configuration ${COLOR_YELLOW}${CHAIN_HOME}${COLOR_RESET}"
@killall axoned

chain-upgrade: build ## Test the chain upgrade from the given FROM_VERSION to the given TO_VERSION.
chain-upgrade: build-go ## Test the chain upgrade from the given FROM_VERSION to the given TO_VERSION.
@echo "${COLOR_CYAN} ⬆️ Upgrade the chain ${COLOR_RESET}${CHAIN}${COLOR_CYAN} from ${COLOR_YELLOW}${FROM_VERSION}${COLOR_RESET}${COLOR_CYAN} to ${COLOR_YELLOW}${TO_VERSION}${COLOR_RESET}"
@killall cosmovisor || \
rm -rf ${TARGET_FOLDER}/${FROM_VERSION}; \
git clone -b ${FROM_VERSION} https://github.com/axone-protocol/axoned.git ${TARGET_FOLDER}/${FROM_VERSION}; \
echo "${COLOR_CYAN} 🏗 Build the ${COLOR_YELLOW}${FROM_VERSION}${COLOR_RESET}${COLOR_CYAN} binary...${COLOR_RESET}"; \
cd ${TARGET_FOLDER}/${FROM_VERSION}; \
make build; \
make build-go; \
BINARY_OLD=${TARGET_FOLDER}/${FROM_VERSION}/${DIST_FOLDER}/${DAEMON_NAME}; \
cd ../../; \
echo $$BINARY_OLD; \
Expand Down Expand Up @@ -429,16 +439,33 @@ ensure-buildx-builder:

## Dependencies:
.PHONY: deps
deps: deps-$(TOOL_TPARSE_NAME) ## Install all the dependencies (tools, etc.)
deps: deps-$(TOOL_TPARSE_NAME) deps-$(TOOL_HEIGHLINER_NAME) ## Install all the dependencies (tools, etc.)

.PHONY: deps-$(TOOL_TPARSE_NAME)
deps-tparse: $(TOOL_TPARSE_BIN) ## Install $TOOL_TPARSE_NAME $TOOL_TPARSE_VERSION ($TOOL_TPARSE_PKG)

.PHONY: deps-$(TOOL_HEIGHLINER_NAME)
deps-heighliner: $(TOOL_HEIGHLINER_BIN) ## Install $TOOL_HEIGHLINER_NAME $TOOL_HEIGHLINER_VERSION ($TOOL_HEIGHLINER_PKG)

$(TOOL_TPARSE_BIN):
@echo "${COLOR_CYAN} 📦 Installing ${COLOR_GREEN}$(TOOL_TPARSE_NAME)@$(TOOL_TPARSE_VERSION)${COLOR_CYAN}...${COLOR_RESET}"
@mkdir -p $(dir $(TOOL_TPARSE_BIN))
@GOBIN=$(dir $(abspath $(TOOL_TPARSE_BIN))) go install $(TOOL_TPARSE_PKG)

$(TOOL_HEIGHLINER_BIN):
@echo "${COLOR_CYAN} 📦 Installing ${COLOR_GREEN}$(TOOL_HEIGHLINER_NAME)@$(TOOL_HEIGHLINER_VERSION)${COLOR_CYAN}...${COLOR_RESET}"
@mkdir -p $(dir $(TOOL_HEIGHLINER_BIN))
CUR_DIR=$(shell pwd) && \
TEMP_DIR=$(shell mktemp -d) && \
GIT_URL=https://$(firstword $(subst @, ,$(TOOL_HEIGHLINER_PKG))).git && \
GIT_TAG=$(word 2,$(subst @, ,$(TOOL_HEIGHLINER_PKG))) && \
git clone --branch $$GIT_TAG --depth 1 $$GIT_URL $$TEMP_DIR && \
cd $$TEMP_DIR && \
make build && \
cd $$CUR_DIR && \
mv $$TEMP_DIR/heighliner $(TOOL_HEIGHLINER_BIN) && \
rm -rf $$TEMP_DIR

## Help:
.PHONY: help
help: ## Show this help.
Expand Down
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ Targets:
build Build all available artefacts (executable, docker image, etc.)
build-go Build node executable for the current environment (default build)
build-go-all Build node executables for all available environments
build-docker Build docker image
Install:
install Install node executable
Test:
Expand Down Expand Up @@ -137,6 +138,7 @@ Targets:
Dependencies:
deps Install all the dependencies (tools, etc.)
deps-tparse Install tparse v0.16.0 (github.com/mfridman/[email protected])
deps-heighliner Install heighliner v1.7.1 (github.com/strangelove-ventures/[email protected])
Help:
help Show this help.
Expand All @@ -148,14 +150,23 @@ This Makefile depends on docker. To install it, please follow the instructions:

### Build

To build the `axoned` node, invoke the goal `build` of the `Makefile`:
To build the `axoned` node, invoke the goal `build-go` of the `Makefile`:

```sh
make build
make build-go
```

The binary will be generated under the folder `target/dist`.

### Build a docker image

This project leverages [heighliner](https://github.com/strangelove-ventures/heighliner) to simplify the management and
creation of production-grade container images. To build a Docker image, use the `build-docker` target in the `Makefile`:

```sh
make build-docker
```

### Run a local network

To initialize a local network configuration, invoke the goal `chain-init` of the `Makefile`:
Expand Down

0 comments on commit 8fe4cfa

Please sign in to comment.