From 7e9940c188be457c544af17290c7dba1831c20a6 Mon Sep 17 00:00:00 2001 From: julien Date: Tue, 8 Aug 2023 17:08:20 +0200 Subject: [PATCH 1/7] feat(CI): add concurrency groups --- .github/workflows/foundry.yml | 4 ++++ .github/workflows/hardhat.yml | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/.github/workflows/foundry.yml b/.github/workflows/foundry.yml index a8c5d4916..778493a01 100644 --- a/.github/workflows/foundry.yml +++ b/.github/workflows/foundry.yml @@ -7,6 +7,10 @@ on: pull_request: workflow_dispatch: +concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }} + cancel-in-progress: true + jobs: forge-test: strategy: diff --git a/.github/workflows/hardhat.yml b/.github/workflows/hardhat.yml index f541eafd9..31e2c5b71 100644 --- a/.github/workflows/hardhat.yml +++ b/.github/workflows/hardhat.yml @@ -7,6 +7,10 @@ on: pull_request: workflow_dispatch: +concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }} + cancel-in-progress: true + jobs: yarn-test: strategy: From 60a46c86076df2bbcd7bcab9795d14ae5be98510 Mon Sep 17 00:00:00 2001 From: julien Date: Tue, 8 Aug 2023 17:09:08 +0200 Subject: [PATCH 2/7] fix(CI): rm unused strategy --- .github/workflows/foundry.yml | 3 --- .github/workflows/hardhat.yml | 3 --- 2 files changed, 6 deletions(-) diff --git a/.github/workflows/foundry.yml b/.github/workflows/foundry.yml index 778493a01..ffcfca365 100644 --- a/.github/workflows/foundry.yml +++ b/.github/workflows/foundry.yml @@ -13,9 +13,6 @@ concurrency: jobs: forge-test: - strategy: - fail-fast: true - runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/hardhat.yml b/.github/workflows/hardhat.yml index 31e2c5b71..3f036848d 100644 --- a/.github/workflows/hardhat.yml +++ b/.github/workflows/hardhat.yml @@ -13,9 +13,6 @@ concurrency: jobs: yarn-test: - strategy: - fail-fast: true - runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 From 025dcc92d37f721c122e5f90c0ffc33efcd36a53 Mon Sep 17 00:00:00 2001 From: julien Date: Tue, 8 Aug 2023 17:37:38 +0200 Subject: [PATCH 3/7] feat: add linter to the CI --- .github/workflows/ci.yml | 31 +++++++++++++++++++++++++++++++ .github/workflows/hardhat.yml | 4 ++-- .prettierrc | 3 ++- package.json | 4 +++- 4 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..16fd59c30 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,31 @@ +name: CI + +on: + push: + +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 diff --git a/.github/workflows/hardhat.yml b/.github/workflows/hardhat.yml index 3f036848d..4152c103c 100644 --- a/.github/workflows/hardhat.yml +++ b/.github/workflows/hardhat.yml @@ -8,8 +8,8 @@ on: workflow_dispatch: concurrency: - group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }} - cancel-in-progress: true + group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }} + cancel-in-progress: true jobs: yarn-test: diff --git a/.prettierrc b/.prettierrc index 9fcfde7a6..b5fc75e60 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,3 +1,4 @@ { - "printWidth": 120 + "printWidth": 120, + "plugins": ["@trivago/prettier-plugin-sort-imports"] } diff --git a/package.json b/package.json index 02ee1d077..eb844c8ec 100644 --- a/package.json +++ b/package.json @@ -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", From 359393a6a57503eb95afbbbea8adfd6b7b3a05da Mon Sep 17 00:00:00 2001 From: julien Date: Tue, 8 Aug 2023 17:37:52 +0200 Subject: [PATCH 4/7] chore: run `yarn lint` --- test/hardhat/Blue.spec.ts | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/test/hardhat/Blue.spec.ts b/test/hardhat/Blue.spec.ts index 981baea6e..edc1535a8 100644 --- a/test/hardhat/Blue.spec.ts +++ b/test/hardhat/Blue.spec.ts @@ -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); @@ -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), ]); } From deb3199a03c6a64bb333ebc0e179f1a589beaa8e Mon Sep 17 00:00:00 2001 From: julien Date: Tue, 8 Aug 2023 21:20:56 +0200 Subject: [PATCH 5/7] refactor: change workflow name to `formatting` --- .github/workflows/{ci.yml => formatting.yml} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename .github/workflows/{ci.yml => formatting.yml} (97%) diff --git a/.github/workflows/ci.yml b/.github/workflows/formatting.yml similarity index 97% rename from .github/workflows/ci.yml rename to .github/workflows/formatting.yml index 16fd59c30..691ebdae7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/formatting.yml @@ -1,4 +1,4 @@ -name: CI +name: Formatting on: push: From 304bf918a86931031afd00a3720666e117f24f14 Mon Sep 17 00:00:00 2001 From: julien Date: Tue, 8 Aug 2023 21:42:51 +0200 Subject: [PATCH 6/7] refactor: change triggers for Formatting CI --- .github/workflows/formatting.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/formatting.yml b/.github/workflows/formatting.yml index 691ebdae7..b0939c50a 100644 --- a/.github/workflows/formatting.yml +++ b/.github/workflows/formatting.yml @@ -2,6 +2,9 @@ name: Formatting on: push: + branches: + - main + pull_request: concurrency: group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }} From aee8f1e38deea99a579c3411d2b8f3e9f489aa93 Mon Sep 17 00:00:00 2001 From: julien Date: Tue, 8 Aug 2023 22:11:15 +0200 Subject: [PATCH 7/7] feat: add slow and fast foundry run to stop the CI early in case of an error --- .github/workflows/foundry.yml | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/.github/workflows/foundry.yml b/.github/workflows/foundry.yml index ffcfca365..5ff855439 100644 --- a/.github/workflows/foundry.yml +++ b/.github/workflows/foundry.yml @@ -13,6 +13,22 @@ concurrency: 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: - uses: actions/checkout@v3 @@ -22,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 }}