From 1ee3f188f4660fd03c21a2794e044dd4bf61704c Mon Sep 17 00:00:00 2001 From: Michael Heuer Date: Thu, 18 Jun 2026 12:49:40 +0200 Subject: [PATCH] build: add justfile --- .github/workflows/ci.yml | 47 ++++++++++++++------------------ justfile | 59 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+), 26 deletions(-) create mode 100644 justfile diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a85509f..a84035a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,16 +20,32 @@ jobs: with: submodules: recursive + - name: Install just + uses: extractions/setup-just@v3 + - name: Install Foundry uses: foundry-rs/foundry-toolchain@v1 - name: Show Forge version run: forge --version + - name: Install Bun + uses: oven-sh/setup-bun@v1 + + - name: Show Bun version + run: bun --version + + - name: Install Test-Tooling + run: just tooling + - name: Run Forge fmt - run: forge fmt --check + run: just fmt-check id: fmt + - name: Run Solhint + run: just lint + id: solhint + - name: Install Slither run: pip install slither-analyzer @@ -37,38 +53,17 @@ jobs: run: slither --version - name: Run Slither - run: slither . + run: just static-analysis id: slither - - name: "Install Bun" - uses: "oven-sh/setup-bun@v1" - - - name: Show Bun version - run: bun --version - - - name: Install Test-Tooling - run: bun install - - - name: Run Solhint in `src` dir - run: bunx --bun solhint --config .solhint.json 'src/**/*.sol' - id: solhint-src - - - name: Run Solhint in `test` dir - run: bunx --bun solhint --config .solhint.other.json 'test/**/*.sol' - id: solhint-test - - - name: Run Solhint in `script` dir - run: bunx --bun solhint --config .solhint.other.json 'script/**/*.sol' - id: solhint-script - - name: Run Forge clean - run: forge clean + run: just clean id: clean - name: Run Forge build - run: forge build --sizes --ast + run: just build id: build - name: Run Forge tests - run: forge test -vvv --gas-report + run: just test id: test diff --git a/justfile b/justfile new file mode 100644 index 0000000..bae0e43 --- /dev/null +++ b/justfile @@ -0,0 +1,59 @@ +# Show commands before running (helps debug failures) +set shell := ["bash", "-euo", "pipefail", "-c"] + +# Default recipe +default: + @just --list + +# Install/update git submodule dependencies +deps: + git submodule update --init --recursive + +# Install test tooling (solhint, etc.) +tooling: + bun install + +# Clean build artifacts +clean: + forge clean + +# Build contracts +build *args: + forge build --sizes --ast {{ args }} + +# Format contracts +fmt *args: + forge fmt {{ args }} + +# Check contract formatting +fmt-check: + forge fmt --check + +# Lint contracts (solhint) +lint: + bunx --bun solhint --config .solhint.json 'src/**/*.sol' + bunx --bun solhint --config .solhint.other.json 'test/**/*.sol' + bunx --bun solhint --config .solhint.other.json 'script/**/*.sol' + +# Static analysis with slither +static-analysis: + slither . + +# Run contract tests +test *args: + forge test -vvv --gas-report {{ args }} + +# Prerequisites check (mirrors CI) +check: + @echo "==> Checking formatting..." + @just fmt-check + @echo "==> Linting..." + @just lint + @echo "==> Static analysis with slither..." + @just static-analysis + @echo "==> Cleaning..." + @just clean + @echo "==> Building..." + @just build + @echo "==> Testing..." + @just test