-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Expand file tree
/
Copy pathMakefile
More file actions
165 lines (134 loc) · 4.31 KB
/
Makefile
File metadata and controls
165 lines (134 loc) · 4.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# Heavily inspired by:
# - Lighthouse: https://github.com/sigp/lighthouse/blob/693886b94176faa4cb450f024696cb69cda2fe58/Makefile
# - Reth: https://github.com/paradigmxyz/reth/blob/1f642353ca083b374851ab355b5d80207b36445c/Makefile
.DEFAULT_GOAL := help
# Cargo profile for builds.
PROFILE ?= dev
# The docker image name
DOCKER_IMAGE_NAME ?= ghcr.io/foundry-rs/foundry:latest
BIN_DIR = dist/bin
CARGO_TARGET_DIR ?= target
# List of features to use when building. Can be overridden via the environment.
# No jemalloc on Windows
ifeq ($(OS),Windows_NT)
FEATURES ?= aws-kms gcp-kms turnkey cli asm-keccak
else
FEATURES ?= jemalloc aws-kms gcp-kms turnkey cli asm-keccak
endif
##@ Help
.PHONY: help
help: ## Display this help.
@awk 'BEGIN {FS = ":.*##"; printf "Usage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-20s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
##@ Build
.PHONY: build
build: ## Build the project.
cargo build --locked --features "$(FEATURES)" --profile "$(PROFILE)"
.PHONY: build-docker
build-docker: ## Build the docker image.
docker build . -t "$(DOCKER_IMAGE_NAME)" \
--build-arg "RUST_PROFILE=$(PROFILE)" \
--build-arg "RUST_FEATURES=$(FEATURES)" \
--build-arg "TAG_NAME=dev" \
--build-arg "VERGEN_GIT_SHA=$(shell git rev-parse HEAD)"
##@ Test
## Run unit/doc tests and generate html coverage report in `target/llvm-cov/html` folder.
## Notice that `llvm-cov` supports doc tests only in nightly builds because the `--doc` flag
## is unstable (https://github.com/taiki-e/cargo-llvm-cov/issues/2).
.PHONY: test-coverage
test-coverage:
cargo +nightly llvm-cov --no-report nextest --locked -E 'kind(test) & !test(/\b(issue|ext_integration|flaky_)/)' && \
cargo +nightly llvm-cov --no-report --doc --locked && \
cargo +nightly llvm-cov report --doctests --open
.PHONY: test-unit
test-unit: ## Run unit tests.
cargo nextest run --workspace --locked -E 'kind(test) & !test(/\b(issue|ext_integration|flaky_)/)'
.PHONY: test-doc
test-doc: ## Run doc tests.
cargo test --doc --workspace --locked
.PHONY: test
test: ## Run all tests.
$(MAKE) test-unit && \
$(MAKE) test-doc
##@ Linting
.PHONY: fmt
fmt: ## Run all formatters.
cargo +nightly fmt
./.github/scripts/format.sh --check
.PHONY: lint-clippy
lint-clippy: ## Run clippy on the codebase.
cargo +nightly clippy \
--workspace \
--all-targets \
--all-features \
--locked \
-- -D warnings
.PHONY: lint-clippy-fix
lint-clippy-fix: ## Run clippy on the codebase and fix warnings.
cargo +nightly clippy \
--workspace \
--all-targets \
--all-features \
--locked \
--fix \
--allow-dirty \
--allow-staged \
-- -D warnings
.PHONY: lint-typos
lint-typos: ## Run typos on the codebase.
@command -v typos >/dev/null || { \
echo "typos not found. Please install it by running the command `cargo install typos-cli` or refer to the following link for more information: https://github.com/crate-ci/typos"; \
exit 1; \
}
typos
.PHONY: lint
lint: ## Run all linters.
$(MAKE) fmt && \
$(MAKE) lint-clippy && \
$(MAKE) lint-typos
##@ Documentation
.PHONY: doc
doc: ## Build the documentation.
RUSTDOCFLAGS="--cfg docsrs -D warnings -Zunstable-options --show-type-layout --generate-link-to-definition" \
cargo +nightly doc \
--workspace \
--all-features \
--document-private-items \
--no-deps \
--locked
##@ Other
.PHONY: lock
lock: ## Update the Cargo.lock file with the current dependencies.
cargo fetch
.PHONY: clean
clean: ## Clean the project.
cargo clean
.PHONY: deny
deny: ## Perform a `cargo` deny check.
cargo deny --locked --all-features check all
.PHONY: check
check: ## Run a feature check on all crates and binaries.
cargo hack check --locked --feature-powerset --depth 1
.PHONY: shear
shear: ## Run `cargo shear` to check for unused dependencies.
cargo shear --locked
.PHONY: pr
pr: ## Run all checks and tests.
$(MAKE) deny && \
$(MAKE) lint && \
$(MAKE) test && \
$(MAKE) doc
# dprint formatting commands
.PHONY: dprint-fmt
dprint-fmt: ## Format code with dprint
@if ! command -v dprint > /dev/null; then \
echo "Installing dprint..."; \
cargo install dprint; \
fi
dprint fmt
.PHONY: dprint-check
dprint-check: ## Check formatting with dprint
@if ! command -v dprint > /dev/null; then \
echo "Installing dprint..."; \
cargo install dprint; \
fi
dprint check