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

chore: add help target to Makefile to display the usage of all targets #11221

Merged
merged 2 commits into from
Jul 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 42 additions & 39 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,36 @@ OP_STACK_GO_BUILDER?=us-docker.pkg.dev/oplabs-tools-artifacts/images/op-stack-go
# Requires at least Python v3.9; specify a minor version below if needed
PYTHON?=python3

build: build-go build-ts
help: ## Prints this help message
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

build: build-go build-ts ## Builds both Go and TypeScript components
.PHONY: build

build-go: submodules op-node op-proposer op-batcher
build-go: submodules op-node op-proposer op-batcher ## Builds op-node, op-proposer and op-batcher
.PHONY: build-go

lint-go:
lint-go: ## Lints Go code with specific linters
golangci-lint run -E goimports,sqlclosecheck,bodyclose,asciicheck,misspell,errorlint --timeout 5m -e "errors.As" -e "errors.Is" ./...
.PHONY: lint-go

lint-go-fix:
lint-go-fix: ## Lints Go code with specific linters and fixes reported issues
golangci-lint run -E goimports,sqlclosecheck,bodyclose,asciicheck,misspell,errorlint --timeout 5m -e "errors.As" -e "errors.Is" ./... --fix
.PHONY: lint-go-fix

build-ts: submodules
build-ts: submodules ## Builds TypeScript components
if [ -f "$$NVM_DIR/nvm.sh" ]; then \
. $$NVM_DIR/nvm.sh && nvm use; \
fi
pnpm install:ci
pnpm build
.PHONY: build-ts

ci-builder:
ci-builder: ## Builds the CI builder Docker image
docker build -t ci-builder -f ops/docker/ci-builder/Dockerfile .
.PHONY: ci-builder

golang-docker:
golang-docker: ## Builds Docker images for Go components using buildx
# We don't use a buildx builder here, and just load directly into regular docker, for convenience.
GIT_COMMIT=$$(git rev-parse HEAD) \
GIT_DATE=$$(git show -s --format='%ct') \
Expand All @@ -44,17 +47,17 @@ golang-docker:
op-node op-batcher op-proposer op-challenger op-dispute-mon op-supervisor
.PHONY: golang-docker

docker-builder-clean:
docker-builder-clean: ## Removes the Docker buildx builder
docker buildx rm buildx-build
.PHONY: docker-builder-clean

docker-builder:
docker-builder: ## Creates a Docker buildx builder
docker buildx create \
--driver=docker-container --name=buildx-build --bootstrap --use
.PHONY: docker-builder

# add --print to dry-run
cross-op-node:
cross-op-node: ## Builds cross-platform Docker image for op-node
# We don't use a buildx builder here, and just load directly into regular docker, for convenience.
GIT_COMMIT=$$(git rev-parse HEAD) \
GIT_DATE=$$(git show -s --format='%ct') \
Expand All @@ -80,7 +83,7 @@ cross-op-node:
op-node
.PHONY: golang-docker

contracts-bedrock-docker:
contracts-bedrock-docker: ## Builds Docker image for Bedrock contracts
IMAGE_TAGS=$$(git rev-parse HEAD),latest \
docker buildx bake \
--progress plain \
Expand All @@ -89,58 +92,58 @@ contracts-bedrock-docker:
contracts-bedrock
.PHONY: contracts-bedrock-docker

submodules:
submodules: ## Updates git submodules
git submodule update --init --recursive
.PHONY: submodules


op-node:
op-node: ## Builds op-node binary
make -C ./op-node op-node
.PHONY: op-node

generate-mocks-op-node:
generate-mocks-op-node: ## Generates mocks for op-node
make -C ./op-node generate-mocks
.PHONY: generate-mocks-op-node

generate-mocks-op-service:
generate-mocks-op-service: ## Generates mocks for op-service
make -C ./op-service generate-mocks
.PHONY: generate-mocks-op-service

op-batcher:
op-batcher: ## Builds op-batcher binary
make -C ./op-batcher op-batcher
.PHONY: op-batcher

op-proposer:
op-proposer: ## Builds op-proposer binary
make -C ./op-proposer op-proposer
.PHONY: op-proposer

op-challenger:
op-challenger: ## Builds op-challenger binary
make -C ./op-challenger op-challenger
.PHONY: op-challenger

op-dispute-mon:
op-dispute-mon: ## Builds op-dispute-mon binary
make -C ./op-dispute-mon op-dispute-mon
.PHONY: op-dispute-mon

op-program:
op-program: ## Builds op-program binary
make -C ./op-program op-program
.PHONY: op-program

cannon:
cannon: ## Builds cannon binary
make -C ./cannon cannon
.PHONY: cannon

reproducible-prestate:
reproducible-prestate: ## Builds reproducible-prestate binary
make -C ./op-program reproducible-prestate
.PHONY: reproducible-prestate

cannon-prestate: op-program cannon
cannon-prestate: op-program cannon ## Generates prestate using cannon and op-program
./cannon/bin/cannon load-elf --path op-program/bin/op-program-client.elf --out op-program/bin/prestate.json --meta op-program/bin/meta.json
./cannon/bin/cannon run --proof-at '=0' --stop-at '=1' --input op-program/bin/prestate.json --meta op-program/bin/meta.json --proof-fmt 'op-program/bin/%d.json' --output ""
mv op-program/bin/0.json op-program/bin/prestate-proof.json
.PHONY: cannon-prestate

mod-tidy:
mod-tidy: ## Cleans up unused dependencies in Go modules
# Below GOPRIVATE line allows mod-tidy to be run immediately after
# releasing new versions. This bypasses the Go modules proxy, which
# can take a while to index new versions.
Expand All @@ -149,15 +152,15 @@ mod-tidy:
export GOPRIVATE="github.com/ethereum-optimism" && go mod tidy
.PHONY: mod-tidy

clean:
clean: ## Removes all generated files under bin/
rm -rf ./bin
.PHONY: clean

nuke: clean devnet-clean
nuke: clean devnet-clean ## Completely clean the project directory
git clean -Xdf
.PHONY: nuke

pre-devnet: submodules
pre-devnet: submodules ## Prepares for running a local devnet
@if ! [ -x "$(command -v geth)" ]; then \
make install-geth; \
fi
Expand All @@ -166,37 +169,37 @@ pre-devnet: submodules
fi
.PHONY: pre-devnet

devnet-up: pre-devnet
devnet-up: pre-devnet ## Starts the local devnet
./ops/scripts/newer-file.sh .devnet/allocs-l1.json ./packages/contracts-bedrock \
|| make devnet-allocs
PYTHONPATH=./bedrock-devnet $(PYTHON) ./bedrock-devnet/main.py --monorepo-dir=.
.PHONY: devnet-up

devnet-test: pre-devnet
devnet-test: pre-devnet ## Runs tests on the local devnet
PYTHONPATH=./bedrock-devnet $(PYTHON) ./bedrock-devnet/main.py --monorepo-dir=. --test
.PHONY: devnet-test

devnet-down:
devnet-down: ## Stops the local devnet
@(cd ./ops-bedrock && GENESIS_TIMESTAMP=$(shell date +%s) docker compose stop)
.PHONY: devnet-down

devnet-clean:
devnet-clean: ## Cleans up local devnet environment
rm -rf ./packages/contracts-bedrock/deployments/devnetL1
rm -rf ./.devnet
cd ./ops-bedrock && docker compose down
docker image ls 'ops-bedrock*' --format='{{.Repository}}' | xargs -r docker rmi
docker volume ls --filter name=ops-bedrock --format='{{.Name}}' | xargs -r docker volume rm
.PHONY: devnet-clean

devnet-allocs: pre-devnet
devnet-allocs: pre-devnet ## Generates allocations for the local devnet
PYTHONPATH=./bedrock-devnet $(PYTHON) ./bedrock-devnet/main.py --monorepo-dir=. --allocs
.PHONY: devnet-allocs

devnet-logs:
devnet-logs: ## Displays logs for the local devnet
@(cd ./ops-bedrock && docker compose logs -f)
.PHONY: devnet-logs

test-unit:
test-unit: ## Runs unit tests for all components
make -C ./op-node test
make -C ./op-proposer test
make -C ./op-batcher test
Expand All @@ -205,25 +208,25 @@ test-unit:
.PHONY: test-unit

# Remove the baseline-commit to generate a base reading & show all issues
semgrep:
semgrep: ## Runs Semgrep checks
$(eval DEV_REF := $(shell git rev-parse develop))
SEMGREP_REPO_NAME=ethereum-optimism/optimism semgrep ci --baseline-commit=$(DEV_REF)
.PHONY: semgrep

clean-node-modules:
clean-node-modules: ## Cleans up node_modules directories
rm -rf node_modules
rm -rf packages/**/node_modules
.PHONY: clean-node-modules

tag-bedrock-go-modules:
tag-bedrock-go-modules: ## Tags Go modules for Bedrock
./ops/scripts/tag-bedrock-go-modules.sh $(BEDROCK_TAGS_REMOTE) $(VERSION)
.PHONY: tag-bedrock-go-modules

update-op-geth:
update-op-geth: ## Updates the Geth version used in the project
./ops/scripts/update-op-geth.py
.PHONY: update-op-geth

install-geth:
install-geth: ## Installs or updates Geth if versions do not match
./ops/scripts/geth-version-checker.sh && \
(echo "Geth versions match, not installing geth..."; true) || \
(echo "Versions do not match, installing geth!"; \
Expand Down