Skip to content

Commit b932938

Browse files
authored
Merge pull request #819 from axone-protocol/build/summaraize-tests
Build/summarise tests
2 parents 8627473 + 76e0213 commit b932938

File tree

3 files changed

+37
-7
lines changed

3 files changed

+37
-7
lines changed

.github/workflows/test.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ jobs:
4545
with:
4646
go-version: "1.23"
4747

48+
- name: Restore Cache for Tools
49+
uses: actions/cache@v3
50+
with:
51+
path: ./target/tools
52+
key: tools-cache-${{ runner.os }}-${{ hashFiles('Makefile') }}
53+
4854
- name: Test go project
4955
run: |
5056
make test-go

Makefile

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ BINARY_NAME = axoned
55
TARGET_FOLDER = target
66
DIST_FOLDER = $(TARGET_FOLDER)/dist
77
RELEASE_FOLDER = $(TARGET_FOLDER)/release
8+
TOOLS_FOLDER = $(TARGET_FOLDER)/tools
89
CMD_ROOT :=./cmd/${BINARY_NAME}
910
LEDGER_ENABLED ?= true
1011

@@ -19,6 +20,12 @@ DOCKER_BUILDX_BUILDER = axone-builder
1920
DOCKER_IMAGE_MARKDOWNLINT = thegeeklab/markdownlint-cli:0.32.2
2021
DOCKER_IMAGE_GOTEMPLATE = hairyhenderson/gomplate:v3.11.3-alpine
2122

23+
# Tools
24+
TOOL_TPARSE_NAME := tparse
25+
TOOL_TPARSE_VERSION := v0.16.0
26+
TOOL_TPARSE_PKG := github.com/mfridman/$(TOOL_TPARSE_NAME)@$(TOOL_TPARSE_VERSION)
27+
TOOL_TPARSE_BIN := ${TOOLS_FOLDER}/$(TOOL_TPARSE_NAME)/$(TOOL_TPARSE_VERSION)/$(TOOL_TPARSE_NAME)
28+
2229
# Some colors
2330
COLOR_GREEN = $(shell tput -Txterm setaf 2)
2431
COLOR_YELLOW = $(shell tput -Txterm setaf 3)
@@ -111,7 +118,6 @@ endif
111118
.PHONY: all
112119
all: help
113120

114-
## Lint:
115121
.PHONY: lint
116122
lint: lint-go lint-proto ## Lint all available linters
117123

@@ -190,9 +196,9 @@ install: ## Install node executable
190196
test: test-go ## Pass all the tests
191197

192198
.PHONY: test-go
193-
test-go: build ## Pass the test for the go source code
199+
test-go: $(TOOL_TPARSE_BIN) build ## Pass the test for the go source code
194200
@echo "${COLOR_CYAN} 🧪 Passing go tests${COLOR_RESET}"
195-
@go test -v -coverprofile ./target/coverage.txt ./...
201+
@go test -v -coverprofile ./target/coverage.txt ./... -json | $(TOOL_TPARSE_BIN)
196202

197203
## Chain:
198204
chain-init: build ## Initialize the blockchain with default settings.
@@ -409,6 +415,18 @@ ensure-buildx-builder:
409415
@docker buildx ls | sed '1 d' | cut -f 1 -d ' ' | grep -q ${DOCKER_BUILDX_BUILDER} || \
410416
docker buildx create --name ${DOCKER_BUILDX_BUILDER}
411417

418+
## Dependencies:
419+
.PHONY: deps
420+
deps: deps-$(TOOL_TPARSE_NAME) ## Install all the dependencies (tools, etc.)
421+
422+
.PHONY: deps-$(TOOL_TPARSE_NAME)
423+
deps-tparse: $(TOOL_TPARSE_BIN) ## Install $TOOL_TPARSE_NAME $TOOL_TPARSE_VERSION ($TOOL_TPARSE_PKG)
424+
425+
$(TOOL_TPARSE_BIN):
426+
@echo "${COLOR_CYAN} 📦 Installing ${COLOR_GREEN}$(TOOL_TPARSE_NAME)@$(TOOL_TPARSE_VERSION)${COLOR_CYAN}...${COLOR_RESET}"
427+
@mkdir -p $(dir $(TOOL_TPARSE_BIN))
428+
@GOBIN=$(dir $(abspath $(TOOL_TPARSE_BIN))) go install $(TOOL_TPARSE_PKG)
429+
412430
## Help:
413431
.PHONY: help
414432
help: ## Show this help.
@@ -417,10 +435,14 @@ help: ## Show this help.
417435
@echo ' ${COLOR_YELLOW}make${COLOR_RESET} ${COLOR_GREEN}<target>${COLOR_RESET}'
418436
@echo ''
419437
@echo 'Targets:'
420-
@awk 'BEGIN {FS = ":.*?## "} { \
438+
@$(foreach V,$(sort $(.VARIABLES)), \
439+
$(if $(filter-out environment% default automatic,$(origin $V)), \
440+
$(if $(filter TOOL_%,$V), \
441+
export $V="$($V)";))) \
442+
awk 'BEGIN {FS = ":.*?## "} { \
421443
if (/^[a-zA-Z_-]+:.*?##.*$$/) {printf " ${COLOR_YELLOW}%-20s${COLOR_GREEN}%s${COLOR_RESET}\n", $$1, $$2} \
422444
else if (/^## .*$$/) {printf " ${COLOR_CYAN}%s${COLOR_RESET}\n", substr($$1,4)} \
423-
}' $(MAKEFILE_LIST)
445+
}' $(MAKEFILE_LIST) | envsubst
424446
@echo ''
425447
@echo 'This Makefile depends on ${COLOR_CYAN}docker${COLOR_RESET}. To install it, please follow the instructions:'
426448
@echo '- for ${COLOR_YELLOW}macOS${COLOR_RESET}: https://docs.docker.com/docker-for-mac/install/'

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ The project comes with a convenient `Makefile` that helps you to build, install,
9999
$ make <target>
100100
101101
Targets:
102-
Lint:
103102
lint Lint all available linters
104103
lint-go Lint go source code
105104
lint-proto Lint proto files
@@ -120,7 +119,7 @@ Targets:
120119
chain-init Initialize the blockchain with default settings.
121120
chain-start Start the blockchain with existing configuration (see chain-init)
122121
chain-stop Stop the blockchain
123-
chain-upgrade Test the chain upgrade from the given FROM_VERSION to the given TO_VERSION. You can pass also the proposal json file on PROPOSAL var
122+
chain-upgrade Test the chain upgrade from the given FROM_VERSION to the given TO_VERSION.
124123
Clean:
125124
clean Remove all the files from the target folder
126125
Proto:
@@ -135,6 +134,9 @@ Targets:
135134
mock Generate all the mocks (for tests)
136135
Release:
137136
release-assets Generate release assets
137+
Dependencies:
138+
deps Install all the dependencies (tools, etc.)
139+
deps-tparse Install tparse v0.16.0 (github.com/mfridman/tparse@v0.16.0)
138140
Help:
139141
help Show this help.
140142

0 commit comments

Comments
 (0)