Skip to content
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
6 changes: 5 additions & 1 deletion .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
# yaml-language-server: $schema=https://json.schemastore.org/github-action.json
name: Setup
description: Install just and local development dependencies.
description: Install Foundry, just, and local development dependencies.

runs:
using: composite
steps:
- uses: foundry-rs/foundry-toolchain@c7450ba673e133f5ee30098b3b54f444d3a2ca2d # action v1.8.0, installs Foundry v1.7.1
with:
version: v1.7.1

- uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # action v4, installs just 1.50.0
with:
just-version: 1.50.0
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,6 @@ jobs:
submodules: recursive
- uses: ./.github/actions/setup
- name: Test
run: just test
run: forge test -vvv --show-progress --gas-snapshot-check true
- name: Coverage
run: just coverage-check
39 changes: 9 additions & 30 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@ set quiet # Doesn't print the command that is being run

COVERAGE_MIN := env_var_or_default("COVERAGE_MIN", "100")
SOLHINT := "dev/node_modules/.bin/solhint" # Binary path for local Solhint installation
FORGE := "dev/node_modules/.bin/forge" # Binary path for local Forge installation
ANVIL := "dev/node_modules/.bin/anvil" # Binary path for local Anvil installation
CAST := "dev/node_modules/.bin/cast" # Binary path for local Cast installation
CHISEL := "dev/node_modules/.bin/chisel" # Binary path for local Chisel installation
NPM_BIN := "dev/node_modules/.bin" # Directory containing the local NPM binaries
JUST := just_executable()

# Runs `just help`
Expand All @@ -21,54 +16,38 @@ register-hooks:
help:
{{JUST}} --list

# Run the local Forge binary
forge *args:
{{FORGE}} {{args}}

# Run the local Anvil binary
anvil *args:
{{ANVIL}} {{args}}

# Run the local Cast binary
cast *args:
{{CAST}} {{args}}

# Run the local Chisel binary
chisel *args:
{{CHISEL}} {{args}}

# Compile contracts
build:
{{FORGE}} build
forge build

# Compile all contracts
build-all:
{{FORGE}} build --force
forge build --force

# Format Solidity sources
fmt:
{{FORGE}} fmt
forge fmt

# Check formatting and run `solhint` on `src`/`script`/`test`
lint:
{{FORGE}} fmt --check
forge fmt --check
{{SOLHINT}} --max-warnings 0 '**/*.sol'

# Run Slither static analysis on `src`
slither:
PATH="$PWD/{{NPM_BIN}}:$PATH" uv run --project dev slither src --config-file slither.config.json
uv run --project dev slither src --config-file slither.config.json

# Run tests
test:
{{FORGE}} test -vvv --show-progress --gas-snapshot-check true
forge test -vvv --show-progress --gas-snapshot-check true

# Print coverage summary
coverage-summary:
{{FORGE}} coverage --no-match-coverage "^(test|script)/" --report summary
forge coverage --no-match-coverage "^(test|script)/" --report summary

# Generate lcov coverage report
coverage-lcov:
{{FORGE}} coverage --no-match-coverage "^(test|script)/" --report lcov
forge coverage --no-match-coverage "^(test|script)/" --report lcov

# Fail if the minimum of all four coverage metrics (lines/statements/branches/funcs) on the `Total` row is below `COVERAGE_MIN` (default `100`)
coverage-check:
Expand All @@ -94,7 +73,7 @@ coverage-check:

# Generate gas snapshots
snapshot:
{{FORGE}} snapshot --desc --show-progress
forge snapshot --desc --show-progress

# Run build, lint, slither, coverage-check, snapshot
all: build lint slither coverage-check snapshot
33 changes: 19 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,23 @@ just fmt

### Local tooling

Foundry should be installed locally and pinned to `v1.7.1`.
CI uses the same Foundry version.

Install Foundry with:

```shell
foundryup --install v1.7.1
```

Check that the expected version is active with:

```shell
forge --version
```

The output should end in `v1.7.1`.

Solhint and Slither are pinned as local development dependencies under `dev/`.

The pnpm and uv setups wait 7 days before installing newly released packages, matching CoW repos and giving more review time than a 2-day delay.
Expand All @@ -54,18 +71,6 @@ just lint
just slither
```

Foundry commands can be run through `just`, so they use the pinned local executables:

```shell
just forge --version
just anvil --version
just cast --version
just chisel --version
```

Compare the printed versions with `dev/package.json` and `dev/pnpm-lock.yaml`.
For example, if `@foundry-rs/forge` resolves to `1.7.0`, `just forge --version` should print a version ending in `v1.7.0`.

### Pre-commit hooks

Install the hooks with:
Expand All @@ -89,7 +94,7 @@ just snapshot
### Deploy

```shell
just forge script script/Counter.s.sol:CounterScript --rpc-url <your_rpc_url> --private-key <your_private_key>
forge script script/Counter.s.sol:CounterScript --rpc-url <your_rpc_url> --private-key <your_private_key>
```

## New project creation checklist
Expand Down Expand Up @@ -117,7 +122,7 @@ The following operations need to be performed after this repository has been cre
- Select "Pull request title and description" in "Default commit message" option
- Unckeck "Allow merge commits" option
- Check "Allow auto-merge" option
- [ ] Run `just forge install` to install the dependencies. This will create a new `foundry.lock` file which you should commit to the project
- [ ] Run `forge install` to install the dependencies. This will create a new `foundry.lock` file which you should commit to the project
- [ ] Set up [Local tooling](#local-tooling) so Solhint and Slither use the pinned project versions
- [ ] Update the project details in `dev/package.json`, including `name` and `description`
- [ ] Make sure you use the [latest version of Solidity](https://github.com/argotorg/solidity/releases) by updating the `solc` version in `foundry.toml`
Expand Down
4 changes: 0 additions & 4 deletions dev/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
"license": "(MIT OR Apache-2.0)",
"packageManager": "pnpm@10.33.2",
"devDependencies": {
"@foundry-rs/anvil": "^1.7.0",
"@foundry-rs/cast": "^1.7.0",
"@foundry-rs/chisel": "^1.7.0",
"@foundry-rs/forge": "^1.7.0",
"solhint": "6.2.1"
}
}
Loading
Loading