Skip to content

Commit

Permalink
feat(code): Add Makefile to fix lints and test in local (#751)
Browse files Browse the repository at this point in the history
* feat: add Makefile to easy fix-lint and test in local

* update makeFile

* update makeFile

* update

* Update Makefile

* Run tests sequentially

---------

Co-authored-by: Romain Ruetschi <[email protected]>
  • Loading branch information
hoank101 and romac authored Feb 12, 2025
1 parent 99124f5 commit 56c64fc
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 4 deletions.
48 changes: 48 additions & 0 deletions code/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
.PHONY: help install lint lint-fix integration-tests starknet-tests discovery-tests tests

help: ## Show this help.
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage: make \033[36m\033[0m\n"} /^[$$()% a-zA-Z_-]+:.*?##/ { printf " \033[36m%-20s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)

install: ## Install the required tools.
npm i @informalsystems/quint -g
cargo install --locked cargo-nextest

lint: ## Lint the workspace.
cargo fmt --all --check
cargo clippy --workspace --all-features --all-targets -- -D warnings

lint-fix: ## Fix the linting issues.
cargo clippy --fix --allow-dirty --allow-staged --workspace --all-features --all-targets -- -D warnings
cargo fmt --all

integration-tests: ## Run the integration tests.
cargo nextest run \
--workspace \
--all-features \
--no-fail-fast \
--failure-output final \
--test-threads 1 \
--exclude informalsystems-malachitebft-starknet-test \
--exclude informalsystems-malachitebft-discovery-test

starknet-tests: ## Run the Starknet integration tests
cargo nextest run \
--all-features \
--no-fail-fast \
--failure-output final \
--test-threads 1 \
--package informalsystems-malachitebft-starknet-test

discovery-tests: ## Run the discovery tests
cargo nextest run \
--all-features \
--no-fail-fast \
--failure-output final \
--test-threads 1 \
--package informalsystems-malachitebft-discovery-test

tests: ## Run all the tests.
$(MAKE) integration-tests
$(MAKE) starknet-tests
$(MAKE) discovery-tests

9 changes: 5 additions & 4 deletions code/crates/test/cli/src/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,11 @@ pub fn init(log_level: LogLevel, log_format: LogFormat) -> WorkerGuard {
guard
}

/// Check if both stdout and stderr are proper terminal (tty),
/// so that we know whether or not to enable colored output,
/// using ANSI escape codes. If either is not, eg. because
/// stdout is redirected to a file, we don't enable colored output.
/// Checks if output is going to a terminal.
///
/// Determines if both stdout and stderr are proper terminals (TTY).
/// This helps decide whether to enable colored output with ANSI escape codes.
/// Colors are disabled when output is redirected to a file.
pub fn enable_ansi() -> bool {
use std::io::IsTerminal;
std::io::stdout().is_terminal() && std::io::stderr().is_terminal()
Expand Down

0 comments on commit 56c64fc

Please sign in to comment.