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

feat(code): Add Makefile to fix lints and test in local #751

Merged
merged 6 commits into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
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
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
Loading