1+ name : Contracts
2+
3+ on :
4+ push :
5+ branches :
6+ - main
7+ paths :
8+ - ' **'
9+ - ' .github/workflows/contracts.yaml'
10+ pull_request :
11+ types :
12+ - opened
13+ - reopened
14+ - synchronize
15+ - ready_for_review
16+ paths :
17+ - ' **'
18+ - ' .github/workflows/contracts.yaml'
19+
20+ defaults :
21+ run :
22+ working-directory : ' .'
23+
24+ jobs :
25+ foundry :
26+ if : github.event.pull_request.draft == false
27+ runs-on : ubuntu-latest
28+
29+ steps :
30+ - name : Checkout sources
31+ uses : actions/checkout@v4
32+ with :
33+ submodules : recursive
34+
35+ - name : Install Foundry
36+ uses : foundry-rs/foundry-toolchain@v1
37+ with :
38+ version : nightly
39+
40+ - name : Setup LCOV
41+ uses : hrishikesh-kadam/setup-lcov@v1
42+
43+ - name : Install Node.js 18
44+ uses : actions/setup-node@v2
45+ with :
46+ node-version : ' 18'
47+
48+ - name : Get yarn cache directory path
49+ id : yarn-cache-dir-path
50+ run : echo "::set-output name=dir::$(yarn cache dir)"
51+
52+ - name : Cache yarn dependencies
53+ uses : actions/cache@v2
54+ id : yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
55+ with :
56+ path : ${{ steps.yarn-cache-dir-path.outputs.dir }}
57+ key : ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
58+ restore-keys : |
59+ ${{ runner.os }}-yarn-
60+
61+ - name : Cache node_modules
62+ id : npm_cache
63+ uses : actions/cache@v2
64+ with :
65+ path : node_modules
66+ key : node_modules-${{ hashFiles('yarn.lock') }}
67+
68+ - name : yarn install
69+ # if: steps.npm_cache.outputs.cache-hit != 'true'
70+ run : yarn install
71+
72+ - name : Compile with foundry
73+ run : forge build --evm-version cancun
74+
75+ - name : Run foundry tests
76+ run : forge test --evm-version cancun -vvv
77+
78+ - name : Run foundry coverage
79+ run : forge coverage --evm-version cancun --report lcov
80+
81+ - name : Prune coverage
82+ run : lcov --rc branch_coverage=1 --remove ./lcov.info -o ./lcov.info.pruned 'src/mocks/*' 'src/test/*' 'scripts/*' 'node_modules/*' 'lib/*'
83+
84+ - name : Upload coverage reports to Codecov
85+ uses : codecov/codecov-action@v3
86+ env :
87+ CODECOV_TOKEN : ${{ secrets.CODECOV_TOKEN }}
88+ with :
89+ files : lcov.info.pruned
90+ flags : contracts
91+
92+ hardhat :
93+ if : github.event.pull_request.draft == false
94+ runs-on : ubuntu-latest
95+
96+ steps :
97+ - name : Checkout sources
98+ uses : actions/checkout@v4
99+ with :
100+ submodules : recursive
101+
102+ - name : Install Node.js 18
103+ uses : actions/setup-node@v2
104+ with :
105+ node-version : ' 18'
106+
107+ - name : Get yarn cache directory path
108+ id : yarn-cache-dir-path
109+ run : echo "::set-output name=dir::$(yarn cache dir)"
110+
111+ - name : Cache yarn dependencies
112+ uses : actions/cache@v2
113+ id : yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
114+ with :
115+ path : ${{ steps.yarn-cache-dir-path.outputs.dir }}
116+ key : ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
117+ restore-keys : |
118+ ${{ runner.os }}-yarn-
119+
120+ - name : Cache node_modules
121+ id : npm_cache
122+ uses : actions/cache@v2
123+ with :
124+ path : node_modules
125+ key : node_modules-${{ hashFiles('yarn.lock') }}
126+
127+ - name : yarn install
128+ # if: steps.npm_cache.outputs.cache-hit != 'true'
129+ run : yarn install
130+
131+ - name : Compile with hardhat
132+ run : npx hardhat compile
133+
134+ - name : Run hardhat tests
135+ run : npx hardhat test
0 commit comments