Skip to content

Commit 87748f1

Browse files
authored
merge: PR #229 chore/ci-improvements -> main
Ci improvements
2 parents 6dd3d78 + f373c53 commit 87748f1

67 files changed

Lines changed: 719 additions & 833 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci-deep.yml

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
name: CI
2+
3+
on:
4+
schedule:
5+
- cron: "0 3 * * 0" # at 3:00am UTC every Sunday
6+
workflow_dispatch:
7+
inputs:
8+
fuzzRuns:
9+
default: "100000"
10+
description: "Unit: number of fuzz runs."
11+
required: false
12+
13+
jobs:
14+
lint:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v3
18+
19+
- uses: actions/setup-node@v3
20+
with:
21+
node-version: 18
22+
cache: "yarn"
23+
24+
- name: Install dependencies
25+
run: yarn install
26+
27+
- name: Run solhint
28+
run: yarn lint:check
29+
30+
- name: "Add lint summary"
31+
run: |
32+
echo "## Lint result" >> $GITHUB_STEP_SUMMARY
33+
echo "✅ Passed" >> $GITHUB_STEP_SUMMARY
34+
35+
build:
36+
runs-on: ubuntu-latest
37+
steps:
38+
- uses: actions/checkout@v3
39+
with:
40+
submodules: "recursive"
41+
42+
- uses: actions/setup-node@v3
43+
with:
44+
node-version: 18
45+
cache: "yarn"
46+
47+
- name: Install dependencies
48+
run: yarn install --frozen-lockfile
49+
50+
- name: Compile hardhat
51+
run: yarn hardhat:compile
52+
53+
- name: Install Foundry
54+
uses: foundry-rs/foundry-toolchain@v1
55+
with:
56+
version: nightly
57+
58+
- name: Compile foundry
59+
run: yarn foundry:compile --sizes
60+
61+
- name: "Cache the build so that it can be re-used by the other jobs"
62+
uses: "actions/cache/save@v3"
63+
with:
64+
key: "build-${{ github.sha }}"
65+
path: |
66+
cache-forge
67+
out
68+
cache-hh
69+
artifacts
70+
typechain
71+
node_modules
72+
73+
- name: "Add build summary"
74+
run: |
75+
echo "## Build result" >> $GITHUB_STEP_SUMMARY
76+
echo "✅ Passed" >> $GITHUB_STEP_SUMMARY
77+
78+
hardhat-tests:
79+
needs: ["build", "lint"]
80+
runs-on: ubuntu-latest
81+
steps:
82+
- uses: actions/checkout@v3
83+
84+
- uses: actions/setup-node@v3
85+
with:
86+
node-version: 18
87+
cache: "yarn"
88+
89+
- name: "Restore the cached build"
90+
uses: "actions/cache/restore@v3"
91+
with:
92+
fail-on-cache-miss: true
93+
key: "build-${{ github.sha }}"
94+
path: |
95+
cache-forge
96+
out
97+
cache-hh
98+
artifacts
99+
typechain
100+
node_modules
101+
102+
- run: export NODE_OPTIONS=--max_old_space_size=11264
103+
104+
- name: Run unit tests
105+
run: yarn hardhat:test
106+
env:
107+
ENABLE_GAS_REPORT: true
108+
CI: true
109+
ETH_NODE_URI_POLYGON: ${{ secrets.ETH_NODE_URI_POLYGON }}
110+
ETH_NODE_URI_FORK: ${{ secrets.ETH_NODE_URI_FORK }}
111+
ETH_NODE_URI_MAINNET: ${{ secrets.ETH_NODE_URI_MAINNET }}
112+
113+
- name: "Add test summary"
114+
run: |
115+
echo "## Hardhat Unit tests result" >> $GITHUB_STEP_SUMMARY
116+
echo "✅ Passed" >> $GITHUB_STEP_SUMMARY
117+
118+
foundry-tests:
119+
needs: ["build", "lint"]
120+
runs-on: ubuntu-latest
121+
steps:
122+
- uses: actions/checkout@v2
123+
with:
124+
submodules: "recursive"
125+
126+
- name: Install Foundry
127+
uses: foundry-rs/foundry-toolchain@v1
128+
with:
129+
version: nightly
130+
131+
- name: "Restore the cached build"
132+
uses: "actions/cache/restore@v3"
133+
with:
134+
fail-on-cache-miss: true
135+
key: "build-${{ github.sha }}"
136+
path: |
137+
cache-forge
138+
out
139+
cache-hh
140+
artifacts
141+
typechain
142+
node_modules
143+
144+
- name: Run Foundry tests
145+
run: yarn foundry:test
146+
env:
147+
ETH_NODE_URI_MAINNET: ${{ secrets.ETH_NODE_URI_MAINNET }}
148+
ETH_NODE_URI_POLYGON: ${{ secrets.ETH_NODE_URI_POLYGON }}
149+
ETH_NODE_URI_GOERLI: ${{ secrets.ETH_NODE_URI_GOERLI }}
150+
ETH_NODE_URI_FANTOM: ${{ secrets.ETH_NODE_URI_FANTOM }}
151+
FOUNDRY_FUZZ_RUNS: ${{ github.event.inputs.fuzzRuns }}
152+
153+
- name: "Add test summary"
154+
run: |
155+
echo "## Foundry Unit tests result" >> $GITHUB_STEP_SUMMARY
156+
echo "✅ Passed" >> $GITHUB_STEP_SUMMARY

.github/workflows/ci.yml

Lines changed: 132 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,100 @@
11
name: CI
22

33
on:
4-
push:
5-
branches:
6-
- main
74
workflow_dispatch:
8-
inputs:
9-
workflow_to_run:
10-
type: choice
11-
description: Which workflow to run?
12-
required: true
13-
options:
14-
- all
15-
- hardhat-tests
16-
- foundry-tests
175
pull_request:
18-
types:
19-
- ready_for_review
20-
- review_requested
21-
pull_request_review:
22-
types: [submitted]
23-
24-
defaults:
25-
run:
26-
shell: bash
6+
push:
7+
branches:
8+
- "main"
279

2810
jobs:
29-
run-linters:
30-
if: github.ref == 'refs/heads/main' || github.event.review.state == 'approved' || github.event.action == 'ready_for_review' || github.event.action == 'review_requested'
11+
lint:
3112
runs-on: ubuntu-latest
3213
steps:
33-
- uses: actions/checkout@v2
34-
- uses: actions/setup-node@v2
35-
with:
36-
node-version: 14
37-
- uses: actions/cache@v2
14+
- uses: actions/checkout@v3
15+
16+
- uses: actions/setup-node@v3
3817
with:
39-
path: node_modules
40-
key: yarn-${{ hashFiles('yarn.lock') }}
41-
restore-keys: yarn-
18+
node-version: 18
19+
cache: "yarn"
20+
4221
- name: Install dependencies
43-
run: |
44-
npm config set //registry.npmjs.org/
45-
yarn install --frozen-lockfile
22+
run: yarn install
23+
4624
- name: Run solhint
47-
run: yarn lint:sol
48-
- name: Run eslint
49-
run: yarn lint:js:fix
25+
run: yarn lint:check
5026

51-
hardhat-tests:
52-
if: github.ref == 'refs/heads/main' || github.event.inputs.workflow_to_run == 'all' || github.event.inputs.workflow_to_run == 'hardhat-tests' || github.event.review.state == 'approved' || github.event.action == 'ready_for_review' || github.event.action == 'review_requested'
27+
- name: "Add lint summary"
28+
run: |
29+
echo "## Lint result" >> $GITHUB_STEP_SUMMARY
30+
echo "✅ Passed" >> $GITHUB_STEP_SUMMARY
31+
build:
5332
runs-on: ubuntu-latest
5433
steps:
55-
- uses: actions/checkout@v2
56-
- uses: actions/setup-node@v2
34+
- uses: actions/checkout@v3
5735
with:
58-
node-version: 14
59-
- uses: actions/cache@v2
36+
submodules: "recursive"
37+
38+
- uses: actions/setup-node@v3
6039
with:
61-
path: node_modules
62-
key: yarn-${{ hashFiles('yarn.lock') }}
63-
restore-keys: yarn-
40+
node-version: 18
41+
cache: "yarn"
42+
6443
- name: Install dependencies
65-
run: |
66-
npm config set //registry.npmjs.org/
67-
yarn install --frozen-lockfile
68-
# This is required separately from yarn test because it generates the typechain definitions
69-
- name: Compile
44+
run: yarn install --frozen-lockfile
45+
46+
- name: Compile hardhat
7047
run: yarn hardhat:compile
48+
49+
- name: Install Foundry
50+
uses: foundry-rs/foundry-toolchain@v1
51+
with:
52+
version: nightly
53+
54+
- name: Compile foundry
55+
run: yarn foundry:compile --sizes
56+
57+
- name: "Cache the build so that it can be re-used by the other jobs"
58+
uses: "actions/cache/save@v3"
59+
with:
60+
key: "build-${{ github.sha }}"
61+
path: |
62+
cache-forge
63+
out
64+
cache-hh
65+
artifacts
66+
typechain
67+
node_modules
68+
- name: "Add build summary"
69+
run: |
70+
echo "## Build result" >> $GITHUB_STEP_SUMMARY
71+
echo "✅ Passed" >> $GITHUB_STEP_SUMMARY
72+
73+
hardhat-tests:
74+
needs: ["build", "lint"]
75+
runs-on: ubuntu-latest
76+
steps:
77+
- uses: actions/checkout@v3
78+
79+
- uses: actions/setup-node@v3
80+
with:
81+
node-version: 18
82+
cache: "yarn"
83+
84+
- name: "Restore the cached build"
85+
uses: "actions/cache/restore@v3"
86+
with:
87+
fail-on-cache-miss: true
88+
key: "build-${{ github.sha }}"
89+
path: |
90+
cache-forge
91+
out
92+
cache-hh
93+
artifacts
94+
typechain
95+
node_modules
7196
- run: export NODE_OPTIONS=--max_old_space_size=11264
97+
7298
- name: Run unit tests
7399
run: yarn hardhat:test
74100
env:
@@ -78,30 +104,75 @@ jobs:
78104
ETH_NODE_URI_FORK: ${{ secrets.ETH_NODE_URI_FORK }}
79105
ETH_NODE_URI_MAINNET: ${{ secrets.ETH_NODE_URI_MAINNET }}
80106

107+
- name: "Add test summary"
108+
run: |
109+
echo "## Hardhat Unit tests result" >> $GITHUB_STEP_SUMMARY
110+
echo "✅ Passed" >> $GITHUB_STEP_SUMMARY
111+
81112
foundry-tests:
82-
if: github.ref == 'refs/heads/main' || github.event.inputs.workflow_to_run == 'all' || github.event.inputs.workflow_to_run == 'foundry-tests' || github.event.review.state == 'approved' || github.event.action == 'ready_for_review' || github.event.action == 'review_requested'
113+
needs: ["build", "lint"]
83114
runs-on: ubuntu-latest
84115
steps:
85116
- uses: actions/checkout@v2
86-
87-
- uses: actions/setup-node@v2
88117
with:
89-
node-version: 14
90-
- uses: actions/cache@v2
91-
with:
92-
path: node_modules
93-
key: yarn-${{ hashFiles('yarn.lock') }}
94-
restore-keys: yarn-
95-
- run: yarn install --frozen-lockfile
118+
submodules: "recursive"
96119

97120
- name: Install Foundry
98121
uses: foundry-rs/foundry-toolchain@v1
99122
with:
100123
version: nightly
124+
125+
- name: "Restore the cached build"
126+
uses: "actions/cache/restore@v3"
127+
with:
128+
fail-on-cache-miss: true
129+
key: "build-${{ github.sha }}"
130+
path: |
131+
cache-forge
132+
out
133+
cache-hh
134+
artifacts
135+
typechain
136+
node_modules
101137
- name: Run Foundry tests
102138
run: yarn foundry:test
103139
env:
104140
ETH_NODE_URI_MAINNET: ${{ secrets.ETH_NODE_URI_MAINNET }}
105141
ETH_NODE_URI_POLYGON: ${{ secrets.ETH_NODE_URI_POLYGON }}
106142
ETH_NODE_URI_GOERLI: ${{ secrets.ETH_NODE_URI_GOERLI }}
107143
ETH_NODE_URI_FANTOM: ${{ secrets.ETH_NODE_URI_FANTOM }}
144+
FOUNDRY_FUZZ_RUNS: "5000"
145+
146+
- name: "Add test summary"
147+
run: |
148+
echo "## Foundry Unit tests result" >> $GITHUB_STEP_SUMMARY
149+
echo "✅ Passed" >> $GITHUB_STEP_SUMMARY
150+
151+
slither-analyze:
152+
needs: ["build", "lint"]
153+
permissions:
154+
actions: "read"
155+
contents: "read"
156+
security-events: "write"
157+
runs-on: "ubuntu-latest"
158+
steps:
159+
- name: "Check out the repo"
160+
uses: "actions/checkout@v3"
161+
162+
- name: "Run Slither analysis"
163+
uses: "crytic/slither-action@v0.3.0"
164+
id: "slither"
165+
with:
166+
fail-on: "none"
167+
sarif: "results.sarif"
168+
node-version: 18
169+
170+
- name: "Upload SARIF file to GitHub code scanning"
171+
uses: "github/codeql-action/upload-sarif@v2"
172+
with:
173+
sarif_file: ${{ steps.slither.outputs.sarif }}
174+
175+
- name: "Add Slither summary"
176+
run: |
177+
echo "## Slither result" >> $GITHUB_STEP_SUMMARY
178+
echo "✅ Uploaded to GitHub code scanning" >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)