Skip to content

Commit 81d050b

Browse files
committed
refactor: update main workflow
ci: restore deps in compile job ci: restore node_modules in tests job chore: format ci: debug ci: fix output name in if check ci: debug ci: debug ci: fix coveralls step chore: remove debug test: exclude some packages from coverage ci: debug ci: have slither job wait for compile ci: debug ci: debug
1 parent a4bd9d3 commit 81d050b

File tree

4 files changed

+39
-53
lines changed

4 files changed

+39
-53
lines changed

.github/workflows/main.yml

Lines changed: 33 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -37,37 +37,39 @@ jobs:
3737
changed-files:
3838
runs-on: ubuntu-latest
3939
outputs:
40-
any_changed: ${{ steps.changed-files.outputs.any_changed }}
41-
modified_files: ${{ steps.changed-files.outputs.modified_files }}
40+
any_sol_changed: ${{ steps.changed-files.outputs.any_changed }}
41+
changed_files: ${{ steps.changed-files.outputs.all_changed_and_modified_files }}
4242
steps:
4343
- uses: actions/checkout@v4
4444
- name: Get changed files
4545
id: changed-files
4646
uses: tj-actions/changed-files@v44
4747
with:
48-
files: packages/**/*.{sol,json,ts}
48+
files: packages/**/*.sol
4949

5050
compile:
51-
if: needs.changed-files.outputs.any_changed == 'true'
51+
if: needs.changed-files.outputs.any_sol_changed == 'true'
5252
needs: [changed-files, deps]
5353
runs-on: ubuntu-latest
5454
steps:
5555
- uses: actions/checkout@v4
5656
- uses: actions/setup-node@v4
5757
with:
5858
node-version: 20
59+
# forge needs some deps coming from node_modules, so we need to restore it
5960
- uses: actions/cache/restore@v4
6061
with:
6162
path: node_modules
6263
key: ${{ needs.deps.outputs.cache-key }}
63-
64-
- run: yarn compile
65-
64+
- uses: foundry-rs/foundry-toolchain@v1
65+
with:
66+
version: nightly
67+
- run: forge compile
6668
- name: Upload compilation results
6769
uses: actions/upload-artifact@v4
6870
with:
69-
name: all-artifacts
70-
path: packages/**/artifacts/**
71+
name: out
72+
path: out/**
7173

7274
style:
7375
needs: deps
@@ -77,50 +79,45 @@ jobs:
7779
- uses: actions/setup-node@v4
7880
with:
7981
node-version: 20
82+
- uses: foundry-rs/foundry-toolchain@v1
83+
with:
84+
version: nightly
8085
- uses: actions/cache/restore@v4
8186
with:
8287
path: node_modules
8388
key: ${{ needs.deps.outputs.cache-key }}
8489

8590
- run: yarn format
8691
tests:
87-
if: needs.changed-files.outputs.any_changed == 'true'
88-
needs: [changed-files, set-matrix, deps, compile]
92+
if: needs.changed-files.outputs.any_sol_changed == 'true'
93+
needs: [changed-files, deps, compile]
8994
runs-on: ubuntu-latest
90-
strategy:
91-
matrix:
92-
dir: ${{ fromJson(needs.set-matrix.outputs.matrix) }}
93-
9495
steps:
9596
- uses: actions/checkout@v4
96-
- uses: actions/setup-node@v4
97+
- uses: actions/download-artifact@v4
9798
with:
98-
node-version: 20
99+
name: out
100+
path: out/
101+
# forge needs some deps coming from node_modules, so we need to restore it
99102
- uses: actions/cache/restore@v4
100103
with:
101104
path: node_modules
102105
key: ${{ needs.deps.outputs.cache-key }}
103-
- uses: actions/download-artifact@v4
106+
- uses: foundry-rs/foundry-toolchain@v1
104107
with:
105-
name: all-artifacts
106-
path: packages/
108+
version: nightly
107109

108-
- if: contains(needs.changed-files.outputs.modified_files, matrix.dir)
109-
name: Test
110-
run: |
111-
workspace=$(jq -r '.name' packages/${{ matrix.dir }}/package.json)
112-
yarn workspace "$workspace" run test:coverage
110+
- run: forge coverage --report lcov
113111

114-
- if: contains(needs.changed-files.outputs.modified_files, matrix.dir) && github.event_name == 'push' && github.ref == 'refs/heads/main'
112+
- if: github.event_name == 'pull_request' && github.ref == 'refs/pull/32/merge' # TODO: switch back to push & refs/heads/main checks
115113
name: Coveralls
116114
uses: coverallsapp/github-action@v2
117115
with:
118116
github-token: ${{ secrets.GITHUB_TOKEN }}
119-
parallel: true
120-
flag-name: run ${{ join(matrix.*, '-') }}
117+
file: lcov.info
121118

122119
set-matrix:
123-
if: needs.changed-files.outputs.any_changed == 'true'
120+
if: needs.changed-files.outputs.any_sol_changed == 'true'
124121
needs: changed-files
125122
runs-on: ubuntu-latest
126123
outputs:
@@ -134,8 +131,8 @@ jobs:
134131
echo "matrix=$matrix" >> $GITHUB_OUTPUT
135132
136133
slither:
137-
if: needs.changed-files.outputs.any_changed == 'true'
138-
needs: [changed-files, set-matrix, deps]
134+
if: needs.changed-files.outputs.any_sol_changed == 'true'
135+
needs: [changed-files, compile, set-matrix]
139136
runs-on: ubuntu-latest
140137
permissions:
141138
contents: read
@@ -145,27 +142,12 @@ jobs:
145142
dir: ${{ fromJson(needs.set-matrix.outputs.matrix) }}
146143
steps:
147144
- uses: actions/checkout@v4
148-
149-
# FIXME this does not work as a way to restore compilation results for slither job but it does for the compile job ??
150-
#- uses: actions/download-artifact@v4
151-
# with:
152-
# name: all-artifacts
153-
# path: packages/
154-
155-
- uses: actions/setup-node@v4
156-
with:
157-
node-version: 20
158-
- uses: actions/cache/restore@v4
145+
- uses: actions/download-artifact@v4
159146
with:
160-
path: node_modules
161-
key: ${{ needs.deps.outputs.cache-key }}
162-
- if: contains(needs.changed-files.outputs.modified_files, matrix.dir)
163-
name: Compile contracts
164-
run: |
165-
workspace=$(jq -r '.name' packages/${{ matrix.dir }}/package.json)
166-
yarn workspace "$workspace" run compile
147+
name: out
148+
path: out/
167149

168-
- if: contains(needs.changed-files.outputs.modified_files, matrix.dir)
150+
- if: contains(needs.changed-files.outputs.changed_files, matrix.dir)
169151
name: Run slither
170152
uses: crytic/[email protected]
171153
id: slither
@@ -177,7 +159,7 @@ jobs:
177159
slither-args: --filter-paths "test" --exclude-dependencies --markdown-root ${{ github.server_url }}/${{ github.repository }}/blob/${{ github.sha }}/
178160
target: packages/${{ matrix.dir }}
179161

180-
- if: contains(needs.changed-files.outputs.modified_files, matrix.dir)
162+
- if: contains(needs.changed-files.outputs.changed_files, matrix.dir)
181163
name: Upload SARIF files
182164
uses: github/codeql-action/upload-sarif@v3
183165
with:

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ coverage.json
1717
# Dependency directories
1818
node_modules/
1919

20-
# Forge build output
20+
# Forge
2121
out
22+
lcov.info
2223

2324
# Hardhat
2425
artifacts

foundry.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
[profile.default]
22
src = 'packages'
33
test = 'packages'
4+
5+
# TODO: update, temporarily ignoring all except lean-imt
6+
no_match_coverage = "^packages/(excubiae|imt|lazy-imt|lazytower)"

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"bugs": "https://github.com/privacy-scaling-explorations/zk-kit.solidity/issues",
88
"private": true,
99
"scripts": {
10-
"test": "yarn workspaces foreach -Ap run test:coverage",
10+
"test": "forge test",
1111
"version:bump": "yarn workspace @zk-kit/${0}.sol version ${1} && yarn remove:stable-version-field ${0} && NO_HOOK=1 git commit -am \"chore(${0}): v${1}\" && git tag ${0}.sol-v${1}",
1212
"version:publish": "yarn workspaces foreach -A --no-private npm publish --tolerate-republish --access public",
1313
"version:release": "changelogithub",

0 commit comments

Comments
 (0)