Skip to content

Commit

Permalink
Add ScopeLift foundry default settings to repo (#14)
Browse files Browse the repository at this point in the history
* Configured foundry/hardhat compatibility

* Add empty placeholder governor and test contract to verify forge install is working

* Added foundry.toml defaults for testing and formatting (original contracts not formatted)

* Add forge install to test.yml

* Updated hardhat plugin to latest to resolve coverage issue

* Switched proposer address in fork tests to one with some voting power

* prettier fix .. need for this triggered by previous commit ts file change
  • Loading branch information
jferas authored and wildmolasses committed Nov 1, 2024
1 parent 15614c9 commit b7fbd77
Show file tree
Hide file tree
Showing 16 changed files with 11,848 additions and 5,947 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
- main

env:
FOUNDRY_PROFILE: ci
RPC_URL: ${{ secrets.RPC_URL }}

jobs:
Expand All @@ -23,6 +24,19 @@ jobs:
cache: 'npm'
- name: Install Dependencies
run: npm ci
- 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
- name: Run Tests
run: npm test
coverage:
Expand All @@ -36,6 +50,15 @@ jobs:
cache: 'npm'
- name: Install Dependencies
run: npm ci
- 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 Coverage
run: npm run coverage
- name: Coveralls GitHub Action
Expand All @@ -51,6 +74,15 @@ jobs:
cache: 'npm'
- name: Install Dependencies
run: npm ci
- 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: build source
run: npm run build
- name: Run Lint
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ artifacts
yarn-error.log
.DS_Store
yarn.lock
cache_forge
out
3 changes: 3 additions & 0 deletions .gitmodules
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
11 changes: 4 additions & 7 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ node_modules
artifacts
cache
coverage*
contracts/test*
contracts/SafeMath.sol
contracts/Timelock.sol
contracts/Comp.sol
contracts/GovernorBravoDelegator.sol
contracts/GovernorBravoInterfaces.sol
typechain-types
contracts*
typechain-types
out
lib
5 changes: 5 additions & 0 deletions contracts/CompoundGovernor.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.18;

// TODO: Implement new governance contract for Compound. This is just a placeholder to satisfy "forge fmt".
contract CompoundGovernor {}
11 changes: 11 additions & 0 deletions contracts/test/CompoundGovernor.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.18;

import {Test, console2} from "forge-std/Test.sol";

// TODO: implement actual CompoundGovernor tests. This is just a placeholder to satisfy "forge test".
contract CompoundGovernorTest is Test {
function test() public pure {
assertEq(true, true);
}
}
50 changes: 50 additions & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
[profile.default]
src = 'contracts'
out = 'out'
libs = ['node_modules', 'lib']
test = 'test'
cache_path = 'cache_forge'
evm_version = "shanghai"
optimizer = true
optimizer_runs = 10_000_000
solc_version = "0.8.18"
verbosity = 3

[profile.ci]
fuzz = { runs = 5000 }
invariant = { runs = 1000 }

[profile.lite]
fuzz = { runs = 50 }
invariant = { runs = 10 }
# Speed up compilation and tests during development.
optimizer = false

[invariant]
call_override = false
depth = 100
dictionary_weight = 80
fail_on_revert = false
include_push_bytes = true
include_storage = true
optimizer = false
runs = 25

[fmt]
bracket_spacing = false
int_types = "long"
line_length = 120
multiline_func_header = "attributes_first"
number_underscore = "thousands"
quote_style = "double"
single_line_statement_blocks = "multi"
tab_width = 4
wrap_comments = true
ignore = [
"contracts/Comp.sol",
"contracts/GovernorBravo*.sol",
"contracts/SafeMath.sol",
"contracts/Timelock.sol",
"contracts/test/GovernorAlpha.sol",
"contracts/test/Multicall.sol"
]
1 change: 1 addition & 0 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
require("@nomicfoundation/hardhat-foundry");
import { HardhatUserConfig } from "hardhat/config";
import "@nomicfoundation/hardhat-toolbox";
import "@compound-finance/hardhat-match";
Expand Down
1 change: 1 addition & 0 deletions lib/forge-std
Submodule forge-std added at 1714be
Loading

0 comments on commit b7fbd77

Please sign in to comment.