Skip to content

Commit

Permalink
tooling: swap out cargo-make for make (#359)
Browse files Browse the repository at this point in the history
* swap out cargo-make for make

* feat: add self documented Makefile targets

* refactor: use single default profile for both local and CI tests

* docs: make command fail if there are warnings

* ci: split test and lint workflows

* address review comments

* ci: try defining lint and test as reusable jobs

* ci: remove workflow dependency and run ci on merges on next and main

* ci: make targets consistent with miden-base

* docs: fixes to documentation

* make: add fix target for makefile

* ci: remove rust-toolchain from test and lint workflows

* lint: fix clippy issues

* make: reorder sections to be the same as miden base

* make: restrict separators to 100 chars width

* ci: remove rustup update on mkdocs job

* make: add targets to build and install
  • Loading branch information
mFragaBA authored Jun 6, 2024
1 parent 637a8d4 commit 058b217
Show file tree
Hide file tree
Showing 16 changed files with 245 additions and 261 deletions.
4 changes: 0 additions & 4 deletions .config/nextest.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
[profile.default]
retries = 0
slow-timeout = { period = "5m"}

[profile.ci-default]
retries = { backoff = "exponential", count = 2, delay = "1s", jitter = true, max-delay = "10s"}
status-level = "skip"
failure-output = "immediate-final"
Expand Down
104 changes: 0 additions & 104 deletions .github/workflows/ci.yml

This file was deleted.

58 changes: 58 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Lint
on:
push:
branches: [main, next]
pull_request:
types: [opened, repoened, synchronize]

jobs:
clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@main
- name: Install Rust with clippy
run: |
rustup update --no-self-update nightly
rustup +nightly component add clippy
- name: make - clippy
run: make clippy

rustfmt:
name: rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@main
- name: Install Rust with rustfmt
run: |
rustup update --no-self-update nightly
rustup +nightly component add rustfmt
- name: make - format-check
run: make format-check

mkdocs:
name: build mkdocs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@main
- uses: actions/setup-python@v5
with:
python-version: 3.x
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
- uses: actions/cache@v4
with:
key: mkdocs-material-${{ env.cache_id }}
path: .cache
restore-keys: |
mkdocs-material-
- run: make doc-build

rustdocs:
name: build rust documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@main
- name: Install Rust
run: rustup update --no-self-update
- name: make - doc
run: make doc
39 changes: 39 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Test
on:
push:
branches: [main, next]
pull_request:
types: [opened, repoened, synchronize]

jobs:
test:
name: Test Rust ${{matrix.toolchain}} on ${{matrix.os}}
runs-on: ${{matrix.os}}-latest
strategy:
fail-fast: false
matrix:
toolchain: [stable, nightly]
os: [ubuntu]
steps:
- uses: actions/checkout@main
- name: Install Rust with ${{matrix.toolchain}} toolchain
run: rustup update --no-self-update ${{ matrix.toolchain }}
- uses: taiki-e/install-action@nextest
- name: make - test
run: make test

integration_tests:
name: integration_tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@main
- name: Install Rust
run: rustup update --no-self-update
- uses: taiki-e/install-action@nextest
- run: make clean-node
- run: make node
- run: make start-node > /dev/null &
- run: make integration-test-full
- name: Kill miden-node
if: always()
run: make kill-node
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Changelog

* Changed `cargo-make` usage for `make` and `Makefile.toml` for a regular `Makefile` (#359).
* Added integration tests using the CLI (#353).
* Added a new check on account creation / import on the CLI to set the account as the default one if none is set (#372).
* Fixed bug when exporting a note into a file (#368).
* Simplified and separated the `notes --list` table (#356).
Expand Down
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ For example, a new change to the `miden-node-store` crate might have the followi
// ================================================================================
```
- [Rustfmt](https://github.com/rust-lang/rustfmt), [Clippy](https://github.com/rust-lang/rust-clippy) and [Rustdoc](https://doc.rust-lang.org/rustdoc/index.html) linting is included in CI pipeline. Anyways it's preferable to run linting locally before push. To simplify running these commands in a reproducible manner we use [cargo-make](https://github.com/sagiegurari/cargo-make), you can run:
- [Rustfmt](https://github.com/rust-lang/rustfmt), [Clippy](https://github.com/rust-lang/rust-clippy) and [Rustdoc](https://doc.rust-lang.org/rustdoc/index.html) linting is included in CI pipeline. Anyways it's preferable to run linting locally before push. To simplify running these commands in a reproducible manner we use `make`, you can run:
```
cargo make lint
make lint
```
You can find more information about the `cargo make` commands in the [Makefile](Makefile.toml)
You can find more information about other `make` commands in the [Makefile](Makefile)
### Versioning
We use [semver](https://semver.org/) naming convention.
Expand Down
99 changes: 99 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
.DEFAULT_GOAL := help

.PHONY: help
help: ## Show description of all commands
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

# --- Variables -----------------------------------------------------------------------------------

FEATURES_INTEGRATION_TESTING="integration"
FEATURES_CLI="testing,concurrent"
NODE_FEATURES_TESTING="testing"
WARNINGS=RUSTDOCFLAGS="-D warnings"

# --- Linting -------------------------------------------------------------------------------------

.PHONY: clippy
clippy: ## Runs clippy on all targets with config
cargo +nightly clippy --workspace --tests --all-targets --all-features -- -D clippy::all -D warnings

.PHONY: fix
fix: ## Runs Fix with configs
cargo +nightly fix --allow-staged --allow-dirty --all-targets --all-features

.PHONY: format
format: ## Runs format using nightly toolchain
cargo +nightly fmt --all

.PHONY: format-check
format-check: ## Runs format using nightly toolchain but only in check mode
cargo +nightly fmt --all --check

.PHONY: lint
lint: format fix clippy ## Runs all linting tasks at once (clippy, fixing, formatting)

# --- Documentation site --------------------------------------------------------------------------

.PHONY: doc-deps
doc-deps: ## Install dependencies to build and serve documentation site
pip3 install -r scripts/docs_requirements.txt

.PHONY: doc-build
doc-build: doc-deps ## Build documentation site
mkdocs build

.PHONY: doc-serve
doc-serve: doc-deps ## Serve documentation site
mkdocs serve

# --- Rust documentation --------------------------------------------------------------------------

.PHONY: doc
doc: ## Generates & checks rust documentation
$(WARNINGS) cargo doc --all-features --keep-going --release

# --- Testing -------------------------------------------------------------------------------------

.PHONY: test
test: ## Run tests
cargo nextest run --release --workspace

# --- Integration testing -------------------------------------------------------------------------

.PHONY: integration-test
integration-test: ## Run integration tests
cargo nextest run --release --test=integration --features $(FEATURES_INTEGRATION_TESTING)

.PHONY: integration-test-full
integration-test-full: ## Run the integration test binary with ignored tests included
cargo nextest run --release --test=integration --features $(FEATURES_INTEGRATION_TESTING)
cargo nextest run --release --test=integration --features $(FEATURES_INTEGRATION_TESTING) --run-ignored ignored-only -- test_import_genesis_accounts_can_be_used_for_transactions

.PHONY: kill-node
kill-node: ## Kill node process
pkill miden-node || echo 'process not running'

.PHONY: clean-node
clean-node: ## Clean node directory
rm -rf miden-node

.PHONY: node
node: ## Setup node
if [ -d miden-node ]; then cd miden-node ; else git clone https://github.com/0xPolygonMiden/miden-node.git && cd miden-node; fi
cd miden-node && git checkout main && git pull origin main && cargo update
cd miden-node && rm -rf miden-store.sqlite3*
cd miden-node && cargo run --bin miden-node --features $(NODE_FEATURES_TESTING) -- make-genesis --inputs-path ../tests/config/genesis.toml --force

.PHONY: start-node
start-node: ## Run node
cd miden-node && cargo run --bin miden-node --features $(NODE_FEATURES_TESTING) -- start --config ../tests/config/miden-node.toml node

# --- Installing ----------------------------------------------------------------------------------

install: ## Installs the CLI binary using the current dir
cargo install --features $(FEATURES_CLI) --path .

# --- Building ------------------------------------------------------------------------------------

build: ## Builds the CLI binary and client library in release mode
cargo build --release --features $(FEATURES_CLI)
Loading

0 comments on commit 058b217

Please sign in to comment.