-
Notifications
You must be signed in to change notification settings - Fork 1
chore: add Makefile and MakefileEc2.mk, update README #78
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
Open
panos-xyz
wants to merge
3
commits into
main
Choose a base branch
from
chore/add-makefile
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,4 +4,6 @@ | |
|
|
||
| CLAUDE.md | ||
|
|
||
| .worktrees/ | ||
| .worktrees/ | ||
| .claude/ | ||
| .omc/ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,131 @@ | ||
| # Heavily inspired by Lighthouse: https://github.com/sigp/lighthouse/blob/stable/Makefile | ||
| .DEFAULT_GOAL := help | ||
|
|
||
| GIT_SHA ?= $(shell git rev-parse HEAD) | ||
| GIT_TAG ?= $(shell git describe --tags --abbrev=0 2>/dev/null || git rev-parse --short HEAD) | ||
| BIN_DIR = "dist/bin" | ||
|
|
||
| CARGO_TARGET_DIR ?= target | ||
|
|
||
| # Cargo profile for builds. Default is release; CI can override. | ||
| PROFILE ?= release | ||
|
|
||
| # Extra flags for Cargo | ||
| CARGO_INSTALL_EXTRA_FLAGS ?= | ||
|
|
||
| # The docker image name | ||
| DOCKER_IMAGE_NAME ?= ghcr.io/morph-l2/morph-reth | ||
|
|
||
| ##@ 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%-30s\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 morph-reth binary into the `target` directory. | ||
| cargo build --bin morph-reth --profile "$(PROFILE)" | ||
|
|
||
| .PHONY: build-debug | ||
| build-debug: ## Build the morph-reth binary into `target/debug`. | ||
| cargo build --bin morph-reth | ||
|
|
||
| .PHONY: install | ||
| install: ## Build and install the morph-reth binary under `$(CARGO_HOME)/bin`. | ||
| cargo install --path bin/morph-reth --bin morph-reth --force --locked \ | ||
| --profile "$(PROFILE)" \ | ||
| $(CARGO_INSTALL_EXTRA_FLAGS) | ||
|
|
||
| # Create a `.tar.gz` containing the morph-reth binary for a specific target. | ||
| define tarball_release_binary | ||
| cp $(CARGO_TARGET_DIR)/$(PROFILE)/morph-reth $(BIN_DIR)/morph-reth | ||
| cd $(BIN_DIR) && \ | ||
| tar -czf morph-reth-$(GIT_TAG).tar.gz morph-reth && \ | ||
| rm morph-reth | ||
| endef | ||
|
|
||
| .PHONY: build-release-tarballs | ||
| build-release-tarballs: ## Build and package morph-reth into a `.tar.gz` in the `dist/bin` directory. | ||
| [ -d $(BIN_DIR) ] || mkdir -p $(BIN_DIR) | ||
| $(MAKE) build | ||
| $(call tarball_release_binary) | ||
|
|
||
| ##@ Test | ||
|
|
||
| .PHONY: test | ||
| test: ## Run all tests (unit only, fast). | ||
| cargo test --all | ||
|
|
||
| .PHONY: test-unit | ||
| test-unit: ## Run unit tests with cargo-nextest (install with: cargo install cargo-nextest). | ||
| cargo nextest run --locked --workspace -E 'kind(lib)' -E 'kind(bin)' -E 'kind(proc-macro)' | ||
|
|
||
| .PHONY: test-e2e | ||
| test-e2e: ## Run e2e integration tests (spawns full nodes, slower). | ||
| cargo nextest run --locked -p morph-node --features test-utils -E 'binary(it)' | ||
|
|
||
| .PHONY: test-all | ||
| test-all: test test-e2e ## Run all tests including e2e. | ||
|
|
||
| ##@ Lint | ||
|
|
||
| .PHONY: fmt | ||
| fmt: ## Check code formatting. | ||
| cargo fmt --all -- --check | ||
|
|
||
| .PHONY: fmt-fix | ||
| fmt-fix: ## Auto-fix code formatting. | ||
| cargo fmt --all | ||
|
|
||
| .PHONY: clippy | ||
| clippy: ## Run clippy lints. | ||
| cargo clippy --all --all-targets -- -D warnings | ||
|
|
||
| .PHONY: clippy-e2e | ||
| clippy-e2e: ## Run clippy on morph-node with e2e test-utils feature. | ||
| cargo clippy -p morph-node --all-targets --features test-utils -- -D warnings | ||
|
|
||
| .PHONY: clippy-fix | ||
| clippy-fix: ## Run clippy and auto-fix warnings. | ||
| cargo clippy --all --all-targets --fix --allow-staged --allow-dirty -- -D warnings | ||
|
|
||
| .PHONY: lint | ||
| lint: fmt clippy ## Run all lints (fmt + clippy). | ||
|
|
||
| .PHONY: fix-lint | ||
| fix-lint: clippy-fix fmt-fix ## Auto-fix all lint issues. | ||
|
|
||
| ##@ Docker | ||
|
|
||
| # Note: Requires Docker with buildx support. | ||
| # Setup example: | ||
| # docker buildx create --use --driver docker-container --name cross-builder | ||
| .PHONY: docker-build-push | ||
| docker-build-push: ## Build and push a Docker image tagged with the latest git tag. | ||
| $(call docker_build_push,$(GIT_TAG),$(GIT_TAG)) | ||
|
|
||
| .PHONY: docker-build-push-latest | ||
| docker-build-push-latest: ## Build and push a Docker image tagged with the latest git tag and `latest`. | ||
| $(call docker_build_push,$(GIT_TAG),latest) | ||
|
|
||
| .PHONY: docker-build-push-git-sha | ||
| docker-build-push-git-sha: ## Build and push a Docker image tagged with the latest git sha. | ||
| $(call docker_build_push,$(GIT_SHA),$(GIT_SHA)) | ||
|
|
||
| define docker_build_push | ||
| docker buildx build --file ./Dockerfile . \ | ||
| --platform linux/amd64 \ | ||
| --tag $(DOCKER_IMAGE_NAME):$(1) \ | ||
| --tag $(DOCKER_IMAGE_NAME):$(2) \ | ||
| --provenance=false \ | ||
| --push | ||
| endef | ||
|
|
||
| ##@ Other | ||
|
|
||
| .PHONY: clean | ||
| clean: ## Clean build artifacts and the dist directory. | ||
| cargo clean | ||
| rm -rf $(BIN_DIR) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| # Internal Makefile for building and deploying morph-reth binaries to AWS S3. | ||
| # Mirrors the target naming convention from go-ethereum/MakefileEc2.mk. | ||
|
|
||
| DIST_DIR = dist | ||
| BINARY = morph-reth | ||
| TARBALL = morph-reth.tar.gz | ||
| CARGO_TARGET_DIR ?= target | ||
| PROFILE ?= release | ||
|
|
||
| define cargo_build_and_upload | ||
| if [ ! -d $(DIST_DIR) ]; then mkdir -p $(DIST_DIR); fi | ||
| cargo build --bin $(BINARY) --profile "$(PROFILE)" --target-dir "$(CARGO_TARGET_DIR)" | ||
| cp "$(CARGO_TARGET_DIR)/$(PROFILE)/$(BINARY)" "$(DIST_DIR)/" | ||
| tar -czvf $(TARBALL) $(DIST_DIR) | ||
| aws s3 cp $(TARBALL) $(1) | ||
| endef | ||
|
|
||
| # ─── Mainnet ───────────────────────────────────────────────────────────────── | ||
|
|
||
| build-bk-prod-morph-prod-mainnet-to-morph-reth: | ||
| $(call cargo_build_and_upload,s3://morph-0582-morph-technical-department-mainnet-data/morph-setup/morph-reth.tar.gz) | ||
|
|
||
| # ─── Testnet (Hoodi) ──────────────────────────────────────────────────────── | ||
|
|
||
| build-bk-prod-morph-prod-testnet-to-morph-reth-hoodi: | ||
| $(call cargo_build_and_upload,s3://morph-0582-morph-technical-department-testnet-data/testnet/hoodi/morph-setup/morph-reth.tar.gz) | ||
|
|
||
| # ─── QA Net ────────────────────────────────────────────────────────────────── | ||
|
|
||
| build-bk-test-morph-test-qanet-to-morph-reth-qanet: | ||
| $(call cargo_build_and_upload,s3://morph-7637-morph-technical-department-qanet-data/morph-setup/morph-reth.tar.gz) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.