Skip to content

Commit 9e4e333

Browse files
authored
feat: add github workflow (#2)
1 parent 77712bb commit 9e4e333

File tree

7 files changed

+147
-7
lines changed

7 files changed

+147
-7
lines changed

.eslintignore

+3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
node_modules
22
artifacts
3+
artifacts-hardhat
34
cache
5+
cache-hardhat
46
coverage
7+
typechain

.github/workflows/contracts.yml

+135
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
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

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,6 @@ broadcast
1616

1717
# eslint
1818
.eslintcache
19+
20+
# Visual Studio Code
21+
.vscode

.prettierignore

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
node_modules
22
artifacts
3+
artifacts-hardhat
34
cache
5+
cache-hardhat
46
coverage*
57
gasReporterOutput.json
6-
src/libraries/verifier/ZkTrieVerifier.sol
7-
src/libraries/verifier/PatriciaMerkleTrieVerifier.sol
8-
src/L2/predeploys/L1BlockContainer.sol

hardhat-test/PoseidonHash.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ describe("PoseidonHash.spec", async () => {
7474
});
7575

7676
it("should succeed on random inputs", async () => {
77-
const lines = String(fs.readFileSync("./integration-test/testdata/poseidon_hash_with_domain.data")).split("\n");
77+
const lines = String(fs.readFileSync("./hardhat-test/testdata/poseidon_hash_with_domain.data")).split("\n");
7878
for (const line of lines) {
7979
const [domain, a, b, hash] = line.split(" ");
8080
expect(await poseidon["poseidon(uint256[2],uint256)"]([a, b], domain)).to.eq(toBigInt(hash));

hardhat-test/ZkEvmVerifierV1.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ describe("ZkEvmVerifierV1", async () => {
2525
});
2626

2727
it("should succeed", async () => {
28-
const proof = hexlify(fs.readFileSync("./integration-test/testdata/plonk_verifier_0.9.8_proof.data"));
29-
const instances = fs.readFileSync("./integration-test/testdata/plonk_verifier_0.9.8_pi.data");
28+
const proof = hexlify(fs.readFileSync("./hardhat-test/testdata/plonk_verifier_0.9.8_proof.data"));
29+
const instances = fs.readFileSync("./hardhat-test/testdata/plonk_verifier_0.9.8_pi.data");
3030

3131
const publicInputHash = new Uint8Array(32);
3232
for (let i = 0; i < 32; i++) {

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"test": "yarn test:hardhat && yarn test:forge",
1010
"solhint": "./node_modules/.bin/solhint -f table 'src/**/*.sol'",
1111
"lint:sol": "./node_modules/.bin/prettier --write 'src/**/*.sol'",
12-
"lint:ts": "./node_modules/.bin/prettier --write 'integration-test/**/*.ts' 'scripts/**/*.ts' *.ts",
12+
"lint:ts": "./node_modules/.bin/prettier --write 'hardhat-test/**/*.ts' 'scripts/**/*.ts' *.ts",
1313
"lint": "yarn lint:ts && yarn lint:sol",
1414
"coverage": "hardhat coverage",
1515
"coverage:forge": "forge coverage",

0 commit comments

Comments
 (0)