From 0d5eda483b9cbb2a8c5b5811e90009dc516eb3ba Mon Sep 17 00:00:00 2001 From: igorroncevic <57319163+igorroncevic@users.noreply.github.com> Date: Wed, 6 May 2026 16:31:13 +0200 Subject: [PATCH 1/2] chore: Justfile --- .gitignore | 9 ++++++ Justfile | 66 ++++++++++++++++++++++++++++++++++++++ README.md | 43 ++++++++++++++----------- snapshots/CounterTest.json | 3 ++ 4 files changed, 103 insertions(+), 18 deletions(-) create mode 100644 Justfile create mode 100644 snapshots/CounterTest.json diff --git a/.gitignore b/.gitignore index 85198aa..dd378b4 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,12 @@ docs/ # Dotenv file .env + +# Local development dependencies +dev/node_modules/ +dev/.venv/ + +# Local reports +coverage.txt +lcov.info +.gas-snapshot diff --git a/Justfile b/Justfile new file mode 100644 index 0000000..3688823 --- /dev/null +++ b/Justfile @@ -0,0 +1,66 @@ +set shell := ["bash", "-eu", "-o", "pipefail", "-c"] + +COVERAGE_MIN := env_var_or_default("COVERAGE_MIN", "100") + +# Runs `just help` +default: help + +# Show available recipes +help: + just --list + +# Compile contracts with `forge build` +build: + forge build + +# Compile all contracts with `forge build --force` +build-all: + forge build --force + +# Format Solidity sources with `forge fmt` +fmt: + forge fmt + +# Check formatting and run `solhint` on `src`/`script`/`test` +lint: + forge fmt --check + dev/node_modules/.bin/solhint --max-warnings 0 'src/**/*.sol' + dev/node_modules/.bin/solhint --max-warnings 0 'script/**/*.sol' + dev/node_modules/.bin/solhint --max-warnings 0 'test/**/*.t.sol' + +# Run Slither static analysis on `src` +slither: + dev/.venv/bin/slither src --config-file slither.config.json + +# Run tests with `forge test` +test: + forge test --force --isolate -vvv --show-progress --gas-snapshot-check true + +# Print coverage summary (excludes `test`/`script` files) +coverage-summary: + forge coverage --no-match-coverage "(test|script)" --report summary + +# Generate lcov coverage report (excludes `test`/`script` files) +coverage-lcov: + forge coverage --no-match-coverage "(test|script)" --report lcov + +# Fail if total coverage is below `COVERAGE_MIN` (default `100`) +coverage-check: + just coverage-summary > coverage.txt + @coverage="$(awk '/^\| Total/ {gsub(/%/, "", $4); print $4}' coverage.txt)"; \ + cat coverage.txt; \ + if [ -z "$coverage" ]; then echo "Failed to extract coverage percentage."; exit 1; fi; \ + awk "BEGIN {exit !($coverage >= {{COVERAGE_MIN}})}" || { echo "Coverage $coverage% is below {{COVERAGE_MIN}}%."; exit 1; }; \ + rm coverage.txt + +# Generate gas snapshots with `forge snapshot` +snapshot: + forge snapshot --force --isolate --desc --show-progress + +# Run build, lint, slither, test, coverage-check, snapshot +all: + just build + just lint + just slither + just coverage-check + just snapshot diff --git a/README.md b/README.md index 72ce9fd..bb2c28f 100644 --- a/README.md +++ b/README.md @@ -6,31 +6,38 @@ This project is meant to be used as a templated during the creation of new Githu It will contain some useful configuration files and scripts, that can be used also with existing projects (manually copied). - ## Usage +### Just commands + +Install `just` on your machine, then run `just --list` to see the available commands. + +The commands do not load `.env` files. +For local deploys, pass RPC URLs and private keys through your shell or secret manager. +Do not commit private keys. + ### Build ```shell -forge build +just build ``` ### Test ```shell -forge test +just test ``` ### Format ```shell -forge fmt +just fmt ``` ### Gas Snapshots ```shell -forge snapshot +just snapshot ``` ### Deploy @@ -44,18 +51,18 @@ forge script script/Counter.s.sol:CounterScript --rpc-url --priva The following operations need to be performed after this repository has been created. - [ ] In GitHub repo settings: - - [ ] Add a new ruleset called "Protected branches" and include the following changes: - - Enforcement status: active - - Target branches: Include default branch - - Require linear history - - Require a pull request before merging - - Required approvals: 1 - - Allowed merge methods: Squash - - Block force pushes - - [ ] In General → Features → Pull requests: - - Select "Pull request title and description" in "Default commit message" option - - Unckeck "Allow merge commits" option - - Check "Allow auto-merge" option + - [ ] Add a new ruleset called "Protected branches" and include the following changes: + - Enforcement status: active + - Target branches: Include default branch + - Require linear history + - Require a pull request before merging + - Required approvals: 1 + - Allowed merge methods: Squash + - Block force pushes + - [ ] In General → Features → Pull requests: + - Select "Pull request title and description" in "Default commit message" option + - Unckeck "Allow merge commits" option + - Check "Allow auto-merge" option - [ ] Run `forge install` to install the dependencies. This will create a new `foundry.lock` file which you should commit to the project - [ ] Make sure you use the [latest version of Solidity](https://github.com/argotorg/solidity/releases) by updating the `solc` version in `foundry.toml` -- [ ] Once all entries in this list are checked, delete this section from the readme \ No newline at end of file +- [ ] Once all entries in this list are checked, delete this section from the readme diff --git a/snapshots/CounterTest.json b/snapshots/CounterTest.json new file mode 100644 index 0000000..e96fdd2 --- /dev/null +++ b/snapshots/CounterTest.json @@ -0,0 +1,3 @@ +{ + "increment - success": "43476" +} \ No newline at end of file From 7e6c7eacd5de376b0e9617621d20e1985c5584a1 Mon Sep 17 00:00:00 2001 From: igorroncevic <57319163+igorroncevic@users.noreply.github.com> Date: Fri, 8 May 2026 13:57:26 +0200 Subject: [PATCH 2/2] pr feedback --- Justfile | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/Justfile b/Justfile index 3688823..f5542af 100644 --- a/Justfile +++ b/Justfile @@ -1,13 +1,15 @@ set shell := ["bash", "-eu", "-o", "pipefail", "-c"] +set quiet # Doesn't print the command that is being run COVERAGE_MIN := env_var_or_default("COVERAGE_MIN", "100") +JUST := just_executable() # Runs `just help` default: help # Show available recipes help: - just --list + {{JUST}} --list # Compile contracts with `forge build` build: @@ -24,9 +26,7 @@ fmt: # Check formatting and run `solhint` on `src`/`script`/`test` lint: forge fmt --check - dev/node_modules/.bin/solhint --max-warnings 0 'src/**/*.sol' - dev/node_modules/.bin/solhint --max-warnings 0 'script/**/*.sol' - dev/node_modules/.bin/solhint --max-warnings 0 'test/**/*.t.sol' + dev/node_modules/.bin/solhint --max-warnings 0 '**/*.sol' # Run Slither static analysis on `src` slither: @@ -38,16 +38,16 @@ test: # Print coverage summary (excludes `test`/`script` files) coverage-summary: - forge coverage --no-match-coverage "(test|script)" --report summary + forge coverage --no-match-coverage "^(test|script)/" --report summary # Generate lcov coverage report (excludes `test`/`script` files) coverage-lcov: - forge coverage --no-match-coverage "(test|script)" --report lcov + forge coverage --no-match-coverage "^(test|script)/" --report lcov # Fail if total coverage is below `COVERAGE_MIN` (default `100`) coverage-check: - just coverage-summary > coverage.txt - @coverage="$(awk '/^\| Total/ {gsub(/%/, "", $4); print $4}' coverage.txt)"; \ + {{JUST}} coverage-summary > coverage.txt + coverage="$(awk '/^\| Total/ {gsub(/%/, "", $4); print $4}' coverage.txt)"; \ cat coverage.txt; \ if [ -z "$coverage" ]; then echo "Failed to extract coverage percentage."; exit 1; fi; \ awk "BEGIN {exit !($coverage >= {{COVERAGE_MIN}})}" || { echo "Coverage $coverage% is below {{COVERAGE_MIN}}%."; exit 1; }; \ @@ -59,8 +59,8 @@ snapshot: # Run build, lint, slither, test, coverage-check, snapshot all: - just build - just lint - just slither - just coverage-check - just snapshot + {{JUST}} build + {{JUST}} lint + {{JUST}} slither + {{JUST}} coverage-check + {{JUST}} snapshot