-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathMakefile
182 lines (147 loc) · 5.27 KB
/
Makefile
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Inverter Network Makefile
#
# WARNING: This file is part of the git repo. DO NOT INCLUDE SENSITIVE DATA!
#
# The Inverter Network smart contracts project uses this Makefile to execute
# common tasks.
#
# The Makefile supports a help command, i.e. `make help`.
#
# Expected enviroment variables are defined in the `dev.env` file.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# This loads in the dev.env as the environment
ifneq (,$(wildcard ./dev.env))
include dev.env
export
endif
# -----------------------------------------------------------------------------
# Common
.PHONY: clean
clean: # Remove build artifacts
@forge clean
.PHONY: install
install: # Installs the required dependencies
@forge install
.PHONY: build
build: # Build project
@forge build
.PHONY: list-size
list-size: # Print the size of contracts
@{ \
trap 'mv .test/ test/; mv .script/ script/' EXIT; \
mv test/ .test/; \
mv script/ .script/; \
forge build --sizes; \
}
.PHONY: check-size
check-size: # Checks the size of contracts
@{ \
trap 'mv .test/ test/; mv .script/ script/' EXIT; \
mv test/ .test/; \
mv script/ .script/; \
forge build --sizes | awk '!/----/ && /-[0-9]+/ { print; FOUND=1} END { if (!FOUND) { print "All contracts within the limit."; exit 0 }; if (FOUND) { exit 1 } }'; \
}
.PHONY: update
update: # Update dependencies
@forge update
.PHONY: test
test: # Run whole test suite
@forge test -vvv
.PHONY: testFuzz
testFuzz: # Run whole test suite with a custom amount of fuzz runs
@if [ "$(filter-out $@,$(MAKECMDGOALS))" -ge 1 ] 2>/dev/null; then \
export FOUNDRY_FUZZ_RUNS=$(filter-out $@,$(MAKECMDGOALS)); \
else \
read -p "Fuzz runs (no input = defaults to 1024): " RUNS; \
export FOUNDRY_FUZZ_RUNS=$$(if [ "$$RUNS" -ge 1 ] 2>/dev/null; then echo $$RUNS; else echo 1024; fi); \
fi; \
if [ $$FOUNDRY_FUZZ_RUNS -gt 1024 ]; then \
export FOUNDRY_FUZZ_MAX_TEST_REJECTS=$$((FOUNDRY_FUZZ_RUNS * 50)); \
else \
export FOUNDRY_FUZZ_MAX_TEST_REJECTS=65536; \
fi; \
echo "Running tests with $${FOUNDRY_FUZZ_RUNS} fuzz runs and $${FOUNDRY_FUZZ_MAX_TEST_REJECTS} accepted test rejections..."; \
forge test -vvv
# -----------------------------------------------------------------------------
# Individual Component Tests
.PHONY: testOrchestrator
testOrchestrator: # Run orchestrator/ package tests
@make pre-test
@forge test -vvv --match-path "*/orchestrator/*"
.PHONY: testModules
testModules: # Run modules/ package tests
@make pre-test
@forge test -vvv --match-path "*/modules/*"
.PHONY: testFactories
testFactories: # Run factories/ package tests
@make pre-test
@forge test -vvv --match-path "*/factories/*"
.PHONY: testE2e
testE2e: # Run e2e test suite
@make pre-test
@forge test -vvv --match-path "*/e2e/*"
.PHONY: testScripts
testScripts: # Run e2e test suite
@echo "### Run scripts"
@echo "Run TestnetDeploymentScript"
@forge script script/deploymentScript/TestnetDeploymentScript.s.sol:TestnetDeploymentScript
# -----------------------------------------------------------------------------
# Static Analyzers
.PHONY: analyze-slither
analyze-slither: # Run slither analyzer against project (requires solc-select)
@forge build --extra-output abi --extra-output userdoc --extra-output devdoc --extra-output evm.methodIdentifiers
@solc-select use 0.8.23
@slither --ignore-compile src/common || \
slither --ignore-compile src/external || \
slither --ignore-compile src/factories || \
slither --ignore-compile src/modules || \
slither --ignore-compile src/orchestrator || \
slither --ignore-compile src/proxies
.PHONY: analyze-c4udit
analyze-c4udit: # Run c4udit analyzer against project
@c4udit src
# -----------------------------------------------------------------------------
# Reports
.PHONY: report-gas
report-gas: # Print gas report
@forge test --gas-report
.PHONY: report-cov
report-cov: # Print coverage report
@echo "### Running tests & generating the coverage report..."
@forge coverage --report lcov
@genhtml lcov.info --branch-coverage --output-dir coverage
@forge snapshot
# -----------------------------------------------------------------------------
# Formatting
.PHONY: fmt
fmt: # Format code
@forge fmt
.PHONY: fmt-check
fmt-check: # Check whether code formatted correctly
@forge fmt --check
# -----------------------------------------------------------------------------
# Git
pre-test: # format and export correct data
@echo "### Formatting..."
@forge fmt
@echo "### Env variables to make sure the local tests runs"
@echo "### equally long compared to the CI tests"
@export FOUNDRY_FUZZ_RUNS=1024
@export FOUNDRY_FUZZ_MAX_TEST_REJECTS=65536
.PHONY: pre-commit
pre-commit: # Git pre-commit hook
@echo "### Checking the contract size"
@make check-size
@echo "### Running the scripts"
@make testScripts
@echo "### Configure tests"
@make pre-test
@echo "### Running the tests"
@forge test
# -----------------------------------------------------------------------------
# Help Command
.PHONY: help
help: # Show help for each of the Makefile recipes
@grep -E '^[a-zA-Z0-9 -]+:.*#' Makefile | sort | while read -r l; do printf "\033[1;32m$$(echo $$l | cut -f 1 -d':')\033[00m:$$(echo $$l | cut -f 2- -d'#')\n"; done