Skip to content

Commit

Permalink
Merge pull request #240 from morpho-labs/feat/improve-ci
Browse files Browse the repository at this point in the history
feat: improve continuous integration setup
  • Loading branch information
julien-devatom authored Aug 9, 2023
2 parents 757adb5 + aee8f1e commit f2b70d7
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 12 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/formatting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Formatting

on:
push:
branches:
- main
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
cancel-in-progress: true

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- name: Install node
uses: actions/setup-node@v3
with:
node-version: 18
cache: yarn

- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1

- name: Run Linter
run: yarn lint
27 changes: 22 additions & 5 deletions .github/workflows/foundry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,27 @@ on:
pull_request:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
cancel-in-progress: true

jobs:
forge-test:
strategy:
fail-fast: true
matrix:
type: ["slow", "fast"]
include:
- type: "slow"
fuzz-runs: 100000
max-test-rejects: 500000
invariant-runs: 1000
invariant-depth: 100
- type: "fast"
fuzz-runs: 256
max-test-rejects: 65536
invariant-runs: 256
invariant-depth: 15

runs-on: ubuntu-latest
steps:
Expand All @@ -21,10 +38,10 @@ jobs:
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1

- name: Run Forge tests
- name: Run Forge tests in ${{ matrix.type }} mode
run: forge test -vvv
env:
FOUNDRY_FUZZ_RUNS: 100000
FOUNDRY_FUZZ_MAX_TEST_REJECTS: 500000
FOUNDRY_INVARIANT_RUNS: 1000
FOUNDRY_INVARIANT_DEPTH: 100
FOUNDRY_FUZZ_RUNS: ${{ matrix.fuzz-runs }}
FOUNDRY_FUZZ_MAX_TEST_REJECTS: ${{ matrix.max-test-rejects }}
FOUNDRY_INVARIANT_RUNS: ${{ matrix.invariant-runs }}
FOUNDRY_INVARIANT_DEPTH: ${{ matrix.invariant-depth }}
7 changes: 4 additions & 3 deletions .github/workflows/hardhat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ on:
pull_request:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
cancel-in-progress: true

jobs:
yarn-test:
strategy:
fail-fast: true

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down
3 changes: 2 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"printWidth": 120
"printWidth": 120,
"plugins": ["@trivago/prettier-plugin-sort-imports"]
}
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
"scripts": {
"postinstall": "husky install",
"compile": "npx hardhat compile --force",
"test": "npx hardhat test"
"test": "npx hardhat test",
"lint": "prettier --check test/hardhat && forge fmt --check",
"lint:fix": "prettier --write test/hardhat && forge fmt"
},
"dependencies": {
"@ethersproject/abi": "^5.7.0",
Expand Down
18 changes: 16 additions & 2 deletions test/hardhat/Blue.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,14 @@ describe("Blue", () => {
const totalSupplyShares = await blue.totalSupplyShares(id);
Promise.all([
blue.connect(user).supply(market, amount, user.address, []),
blue.connect(user).withdraw(market, amount.mul(totalSupplyShares.add(BigNumber.WAD)).div(totalSupply.add(1)).div(2), user.address, user.address),
blue
.connect(user)
.withdraw(
market,
amount.mul(totalSupplyShares.add(BigNumber.WAD)).div(totalSupply.add(1)).div(2),
user.address,
user.address,
),
]);
} else {
const totalSupply = await blue.totalSupply(id);
Expand All @@ -150,7 +157,14 @@ describe("Blue", () => {
Promise.all([
blue.connect(user).supplyCollateral(market, amount, user.address, []),
blue.connect(user).borrow(market, amount.div(2), user.address, user.address),
blue.connect(user).repay(market, amount.mul(totalBorrowShares.add(BigNumber.WAD)).div(totalBorrow.add(1)).div(4), user.address, []),
blue
.connect(user)
.repay(
market,
amount.mul(totalBorrowShares.add(BigNumber.WAD)).div(totalBorrow.add(1)).div(4),
user.address,
[],
),
blue.connect(user).withdrawCollateral(market, amount.div(8), user.address, user.address),
]);
}
Expand Down

0 comments on commit f2b70d7

Please sign in to comment.