-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: foundry and devcontainer (#111)
## Description This PR: 1. Adds [foundry](https://getfoundry.sh/) configuration for the contracts. 2. Configures the solidity compiler for foundry to replicate that currently used within the contracts. 3. Adds a devcontainer containing foundry and node (for still running hardhat during the migration phase). 4. Configures a VS Code environment for solidity development. ## Test Plan 1. Observe CI/CD continues to pass. ## Related Issues Closes #99 Closes #98 --------- Co-authored-by: Federico Giacon <[email protected]>
- Loading branch information
Showing
10 changed files
with
171 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "Foundry + Node", | ||
"image": "mcr.microsoft.com/devcontainers/base:0", | ||
"features": { | ||
"ghcr.io/nlordell/features/foundry": {}, | ||
"ghcr.io/devcontainers/features/node:1": {} | ||
}, | ||
"customizations": { | ||
"vscode" : { | ||
"extensions": [ | ||
"JuanBlanco.solidity" | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
TestNoOp:test_noOp() (gas: 122) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
name: Gas | ||
|
||
on: | ||
pull_request: | ||
paths: | ||
- '**.sol' | ||
- '**.yml' | ||
- '**.toml' | ||
- 'lib/**' | ||
- '.gitmodules' | ||
- '.gas-snapshot' | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- '**.sol' | ||
- '**.yml' | ||
- '**.toml' | ||
- 'lib/**' | ||
- '.gitmodules' | ||
- '.gas-snapshot' | ||
|
||
env: | ||
FOUNDRY_PROFILE: ci | ||
|
||
jobs: | ||
gas: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive | ||
|
||
- uses: actions/setup-node@v4 | ||
- id: yarn-cache | ||
run: echo "dir=$(yarn cache dir)" >> "$GITHUB_OUTPUT" | ||
- uses: actions/cache@v4 | ||
with: | ||
path: ${{ steps.yarn-cache.outputs.dir }} | ||
key: yarn-${{ hashFiles('**/yarn.lock') }} | ||
restore-keys: | | ||
yarn- | ||
- run: yarn --frozen-lockfile | ||
|
||
- name: Install Foundry | ||
uses: foundry-rs/foundry-toolchain@v1 | ||
with: | ||
version: nightly | ||
|
||
- name: Check gas snapshots | ||
run: forge snapshot --check | ||
# TODO: remove failure allowance once foundry migration is complete | ||
continue-on-error: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
name: Test | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
paths: | ||
- '**.sol' | ||
- '**.yml' | ||
- '**.toml' | ||
- 'lib/**' | ||
- '.gitmodules' | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- '**.sol' | ||
- '**.yml' | ||
- '**.toml' | ||
- 'lib/**' | ||
- '.gitmodules' | ||
|
||
env: | ||
FOUNDRY_PROFILE: ci | ||
|
||
jobs: | ||
test: | ||
strategy: | ||
fail-fast: true | ||
|
||
name: Foundry project | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive | ||
|
||
- uses: actions/setup-node@v4 | ||
- id: yarn-cache | ||
run: echo "dir=$(yarn cache dir)" >> "$GITHUB_OUTPUT" | ||
- uses: actions/cache@v4 | ||
with: | ||
path: ${{ steps.yarn-cache.outputs.dir }} | ||
key: yarn-${{ hashFiles('**/yarn.lock') }} | ||
restore-keys: | | ||
yarn- | ||
- run: yarn --frozen-lockfile | ||
|
||
- name: Install Foundry | ||
uses: foundry-rs/foundry-toolchain@v1 | ||
with: | ||
version: nightly | ||
|
||
- name: Run Forge build | ||
run: | | ||
forge --version | ||
forge build --sizes | ||
id: build | ||
|
||
- name: Run Forge tests | ||
run: | | ||
forge test -vvv | ||
id: test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "lib/forge-std"] | ||
path = lib/forge-std | ||
url = https://github.com/foundry-rs/forge-std |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"solidity.packageDefaultDependenciesDirectory": ["node_modules", "lib"], | ||
"[solidity]": { | ||
"editor.defaultFormatter": "JuanBlanco.solidity" | ||
}, | ||
"solidity.compileUsingRemoteVersion": "v0.7.6+commit.7338295f", | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[profile.default] | ||
src = "src" | ||
out = "out" | ||
libs = ["node_modules", "lib"] | ||
|
||
# Compiler settings | ||
solc = "0.7.6" | ||
via_ir = false | ||
optimizer = true | ||
optimizer_runs = 1000000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
pragma solidity ^0.7.6; | ||
|
||
/// @dev No-op contract for start of forgifying contracts. Delete this! | ||
contract TestNoOp { | ||
function test_noOp() external pure {} | ||
} |