Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: prepare migration to forge #32

Open
wants to merge 30 commits into
base: forge-dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
f1bccaa
chore(lean-imt): migrate to forge
sripwoud Jul 10, 2024
0c0c689
chore(lazy-imt): migrate to forge
sripwoud Jul 10, 2024
a40e737
chore(lazytower): migrate to forge
sripwoud Jul 10, 2024
1d0b788
chore(imt): migrate to forge
sripwoud Jul 10, 2024
f4f4084
chore(excubiae): migrate to forge
sripwoud Jul 10, 2024
c0e9be5
chore(excubiae): fix package.json homepage
sripwoud Jul 10, 2024
cc21c7d
chore(excubiae): update package.json keywords
sripwoud Jul 10, 2024
51dcad0
fix: update imports in sol test files
sripwoud Jul 10, 2024
a4bd9d3
chore: remove ts related deps/files
sripwoud Jul 10, 2024
81d050b
refactor: update main workflow
sripwoud Jul 10, 2024
4ab5bf8
chore: define publish.sh
sripwoud Jul 10, 2024
4bb2590
fix: use `yarn` to run `prettier` when lintstaging
sripwoud Jul 10, 2024
101e809
ci: trigger publish to branch on pr to forge-dev
sripwoud Jul 10, 2024
19bf5a2
ci: fix publish script
sripwoud Jul 10, 2024
ab59076
ci: fix release workflow syntax
sripwoud Jul 10, 2024
747b3b0
fix: fix regex in publish script
sripwoud Jul 10, 2024
8f02fd9
chore: exclude release script from release workflow
sripwoud Jul 10, 2024
971caaf
fix: do not use brace expansion
sripwoud Jul 10, 2024
45dbcc1
fix: update find rm command
sripwoud Jul 10, 2024
1b86fac
ci: setup git user and email to github actions user
sripwoud Jul 10, 2024
bbf0303
ci: update publish script
sripwoud Jul 10, 2024
4ee33b3
ci: debug
sripwoud Jul 10, 2024
0a1aefb
ci: refactor publish workflow
sripwoud Jul 10, 2024
beb8204
refactor: use sh scripts to bump/remove stable version
sripwoud Jul 10, 2024
a5eeff4
feat: handle usage error
sripwoud Jul 10, 2024
cf7251a
refactor: update publish for forge script
sripwoud Jul 10, 2024
c0f8408
chore: comment
sripwoud Jul 10, 2024
9ffc7e4
ci: update release workflow
sripwoud Jul 10, 2024
947522e
ci: update publish-for-forge.sh
sripwoud Jul 11, 2024
137db20
docs: update README
sripwoud Jul 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/[email protected]
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
19 changes: 12 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,10 @@ permissions:

on:
push:
tags:
- "*"

tags: ["*"]
jobs:
release:
npm:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
Expand All @@ -34,10 +31,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/[email protected]
- 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.
Loading
Loading