Skip to content

Commit

Permalink
Merge 13c23df into 1aef325
Browse files Browse the repository at this point in the history
  • Loading branch information
sripwoud authored Jul 11, 2024
2 parents 1aef325 + 13c23df commit e92fe6c
Show file tree
Hide file tree
Showing 108 changed files with 1,420 additions and 7,052 deletions.
84 changes: 33 additions & 51 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,37 +37,39 @@ jobs:
changed-files:
runs-on: ubuntu-latest
outputs:
any_changed: ${{ steps.changed-files.outputs.any_changed }}
modified_files: ${{ steps.changed-files.outputs.modified_files }}
any_sol_changed: ${{ steps.changed-files.outputs.any_changed }}
changed_files: ${{ steps.changed-files.outputs.all_changed_and_modified_files }}
steps:
- uses: actions/checkout@v4
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v44
with:
files: packages/**/*.{sol,json,ts}
files: packages/**/*.sol

compile:
if: needs.changed-files.outputs.any_changed == 'true'
if: needs.changed-files.outputs.any_sol_changed == 'true'
needs: [changed-files, deps]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
# forge needs some deps coming from node_modules, so we need to restore it
- uses: actions/cache/restore@v4
with:
path: node_modules
key: ${{ needs.deps.outputs.cache-key }}

- run: yarn compile

- uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- run: forge compile
- name: Upload compilation results
uses: actions/upload-artifact@v4
with:
name: all-artifacts
path: packages/**/artifacts/**
name: out
path: out/**

style:
needs: deps
Expand All @@ -77,50 +79,45 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: 20
- uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- uses: actions/cache/restore@v4
with:
path: node_modules
key: ${{ needs.deps.outputs.cache-key }}

- run: yarn format
tests:
if: needs.changed-files.outputs.any_changed == 'true'
needs: [changed-files, set-matrix, deps, compile]
if: needs.changed-files.outputs.any_sol_changed == 'true'
needs: [changed-files, deps, compile]
runs-on: ubuntu-latest
strategy:
matrix:
dir: ${{ fromJson(needs.set-matrix.outputs.matrix) }}

steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- uses: actions/download-artifact@v4
with:
node-version: 20
name: out
path: out/
# forge needs some deps coming from node_modules, so we need to restore it
- uses: actions/cache/restore@v4
with:
path: node_modules
key: ${{ needs.deps.outputs.cache-key }}
- uses: actions/download-artifact@v4
- uses: foundry-rs/foundry-toolchain@v1
with:
name: all-artifacts
path: packages/
version: nightly

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

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

set-matrix:
if: needs.changed-files.outputs.any_changed == 'true'
if: needs.changed-files.outputs.any_sol_changed == 'true'
needs: changed-files
runs-on: ubuntu-latest
outputs:
Expand All @@ -134,8 +131,8 @@ jobs:
echo "matrix=$matrix" >> $GITHUB_OUTPUT
slither:
if: needs.changed-files.outputs.any_changed == 'true'
needs: [changed-files, set-matrix, deps]
if: needs.changed-files.outputs.any_sol_changed == 'true'
needs: [changed-files, compile, set-matrix]
runs-on: ubuntu-latest
permissions:
contents: read
Expand All @@ -145,27 +142,12 @@ jobs:
dir: ${{ fromJson(needs.set-matrix.outputs.matrix) }}
steps:
- uses: actions/checkout@v4

# FIXME this does not work as a way to restore compilation results for slither job but it does for the compile job ??
#- uses: actions/download-artifact@v4
# with:
# name: all-artifacts
# path: packages/

- uses: actions/setup-node@v4
with:
node-version: 20
- uses: actions/cache/restore@v4
- uses: actions/download-artifact@v4
with:
path: node_modules
key: ${{ needs.deps.outputs.cache-key }}
- if: contains(needs.changed-files.outputs.modified_files, matrix.dir)
name: Compile contracts
run: |
workspace=$(jq -r '.name' packages/${{ matrix.dir }}/package.json)
yarn workspace "$workspace" run compile
name: out
path: out/

- if: contains(needs.changed-files.outputs.modified_files, matrix.dir)
- if: contains(needs.changed-files.outputs.changed_files, matrix.dir)
name: Run slither
uses: crytic/slither-action@v0.4.0
id: slither
Expand All @@ -177,7 +159,7 @@ jobs:
slither-args: --filter-paths "test" --exclude-dependencies --markdown-root ${{ github.server_url }}/${{ github.repository }}/blob/${{ github.sha }}/
target: packages/${{ matrix.dir }}

- if: contains(needs.changed-files.outputs.modified_files, matrix.dir)
- if: contains(needs.changed-files.outputs.changed_files, matrix.dir)
name: Upload SARIF files
uses: github/codeql-action/upload-sarif@v3
with:
Expand Down
20 changes: 16 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@ on:
tags:
- "*"

pull_request:
# test purposes
# TODO: remove
branches: [forge-dev]

jobs:
release:
npm:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
Expand All @@ -34,10 +38,18 @@ jobs:
run: yarn

- name: Publish packages
run: yarn version:publish
run: yarn workspaces foreach -A --no-private npm publish --tolerate-republish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- run: yarn version:release
- run: yarn changelogithub
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

forge:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: fregante/setup-git-user@v2.0.1
- name: Push contracts to forge branch
run: scripts/publish-for-forge.sh
40 changes: 3 additions & 37 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,28 +1,14 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# IDE
.vscode
.idea

# Cargo
target

# Testing
coverage
coverage.json
Expand All @@ -31,27 +17,9 @@ coverage.json
# Dependency directories
node_modules/

# Parcel cache
.parcel-cache

# TypeScript cache
*.tsbuildinfo

# Output of 'npm pack'
*.tgz

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Yarn Integrity file
.yarn-integrity

# Generate output
dist
build
# Forge
out
lcov.info

# Hardhat
artifacts
Expand All @@ -65,8 +33,6 @@ typechain-types
.env.production.local
.env.local

# Optional npm cache directory
.npm
.DS_Store

# yarn v3
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "lib/forge-std"]
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std
3 changes: 2 additions & 1 deletion .lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"**/*.{js,ts,md,json,sol,yml,yaml}": "prettier --write"
"**/*.{js,ts,md,json,yml,yaml}": "yarn prettier --write",
"**/*.sol": "forge fmt"
}
15 changes: 3 additions & 12 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
# dependencies
node_modules
package-lock.json
yarn.lock
.yarn

# testing
coverage
coverage.json

# hardhat
cache
typechain-types

# production
dist
build
# forge
out
lib

# github
.github/ISSUE_TEMPLATE
Expand All @@ -24,9 +19,5 @@ build
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# others
target
File renamed without changes.
6 changes: 6 additions & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[profile.default]
src = 'packages'
test = 'packages'

# TODO: update, temporarily ignoring all except lean-imt
no_match_coverage = "^packages/(excubiae|imt|lazy-imt|lazytower)"
1 change: 1 addition & 0 deletions lib/forge-std
Submodule forge-std added at 07263d
18 changes: 5 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,10 @@
"bugs": "https://github.com/privacy-scaling-explorations/zk-kit.solidity/issues",
"private": true,
"scripts": {
"compile": "yarn workspaces foreach -Ap run compile",
"test": "yarn workspaces foreach -Ap run test:coverage",
"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}",
"version:publish": "yarn workspaces foreach -A --no-private npm publish --tolerate-republish --access public",
"version:release": "changelogithub",
"format": "prettier -c .",
"format:write": "prettier -w .",
"remove:stable-version-field": "ts-node scripts/remove-stable-version-field.ts ${0} && yarn format:write",
"test": "forge test",
"version:bump": "scripts/version-bump.sh",
"format": "prettier -c . && forge fmt --check",
"format:write": "prettier -w . && forge fmt",
"postinstall": "husky && git config --local core.editor cat"
},
"keywords": [
Expand All @@ -31,14 +27,10 @@
"devDependencies": {
"@commitlint/cli": "^18.6.1",
"@commitlint/config-conventional": "^18.6.2",
"@types/glob": "^7.2.0",
"@types/node": "^20",
"changelogithub": "patch:changelogithub@npm%3A0.13.3#~/.yarn/patches/changelogithub-npm-0.13.3-1783949906.patch",
"czg": "^1.9.1",
"husky": "^9.0.11",
"lint-staged": "^15.2.2",
"prettier": "^3.2.5",
"ts-node": "^10.9.2",
"typescript": "^5.3.3"
"prettier": "^3.2.5"
}
}
6 changes: 0 additions & 6 deletions packages/excubiae/.prettierrc.json

This file was deleted.

2 changes: 1 addition & 1 deletion packages/excubiae/LICENSE
1 change: 0 additions & 1 deletion packages/excubiae/README.md

This file was deleted.

Loading

0 comments on commit e92fe6c

Please sign in to comment.