Skip to content

Commit

Permalink
misc: add makefile (#1071)
Browse files Browse the repository at this point in the history
* chore: add makefile

* nit: types + use make check-features

* nit

* imp: add install-tools
  • Loading branch information
Farhad-Shabani authored Feb 21, 2024
1 parent e78c372 commit 49e66de
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/no-std.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
override: true
- run: |
cd ci/no-std-check
make check-panic-conflict
make check-no-std
check-substrate:
name: Check no_std substrate support
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
- name: Cache cargo dependencies
uses: Swatinem/rust-cache@v2
- name: Publish crates (dry run)
run: cargo release --workspace --no-push --no-tag --no-publish --exclude ibc-derive
run: make check-release
env:
CRATES_TOKEN: ${{ secrets.CRATES_TOKEN }}

Expand All @@ -48,7 +48,7 @@ jobs:
- name: Cache cargo dependencies
uses: Swatinem/rust-cache@v2
- name: Publish crates
run: yes | cargo release --workspace --no-push --no-tag --exclude ibc-derive --allow-branch HEAD --execute
run: yes | make release
env:
CRATES_TOKEN: ${{ secrets.CRATES_TOKEN }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
uses: taiki-e/install-action@cargo-hack
- uses: Swatinem/rust-cache@v2
- name: Run cargo hack
run: cargo hack check --workspace --feature-powerset --exclude-features default
run: make check-features

nightly_fmt:
runs-on: ubuntu-latest
Expand Down
6 changes: 3 additions & 3 deletions ci/no-std-check/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ NIGHTLY_VERSION=nightly

.DEFAULT_GOAL := help

.PHONY: all setup build-substrate check-panic-conflict check-cargo-build-std check-wasm check-substrate help
.PHONY: all setup build-substrate check-no-std check-cargo-build-std check-wasm check-substrate help

all: ## Run the setup and all checks
$(MAKE) build-substrate
$(MAKE) check-panic-conflict
$(MAKE) check-no-std
$(MAKE) check-cargo-build-std
$(MAKE) check-wasm
$(MAKE) check-substrate
Expand All @@ -21,7 +21,7 @@ build-substrate: ## Build with Substrate support
--no-default-features \
--features use-substrate,substrate-std

check-panic-conflict: ## Check for `no_std` compliance by installing a panic handler, and any other crate importing `std` will cause a conflict. Runs on default target.
check-no-std: ## Check for `no_std` compliance by installing a panic handler, and any other crate importing `std` will cause a conflict. Runs on default target.
cargo build \
--no-default-features \
--features panic-handler
Expand Down
40 changes: 40 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
.PHONY: help

help: ## Display help message.
@echo "Usage: make <target>"
@awk 'BEGIN {FS = ":.*?## "}/^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)

install-tools: ## Install development tools including nightly rustfmt, cargo-hack and cargo-release.
rustup component add rustfmt --toolchain nightly
cargo install cargo-hack
cargo install cargo-release

lint: ## Lint the code using rustfmt, clippy and whitespace lints.
cargo +nightly fmt --all --check
cargo clippy --all-targets --all-features
cargo clippy --all-targets --no-default-features
bash ./ci/code-quality/whitespace-lints.sh

check-features: ## Check that project compiles with all combinations of features.
cargo hack check --workspace --feature-powerset --exclude-features default

check-docs: ## Build documentation with all features and without default features.
cargo doc --all --all-features --release
cargo doc --all --no-default-features --release

check-no-std: ## Check that libraries compile with `no_std` feature.
$(MAKE) -C ./ci/no-std-check $@

check-cw: ## Check that the CosmWasm smart contract compiles.
cd ./ci/cw-check \
&& cargo build --target wasm32-unknown-unknown --no-default-features --release

test: ## Run tests with all features and without default features.
cargo test --all-targets --all-features
cargo test --all-targets --no-default-features

check-release: ## Check that the release build compiles.
cargo release --workspace --no-push --no-tag --no-publish --exclude ibc-derive

release: ## Perform an actual release and publishes to crates.io.
cargo release --workspace --no-push --no-tag --exclude ibc-derive --allow-branch HEAD --execute

0 comments on commit 49e66de

Please sign in to comment.