-
Notifications
You must be signed in to change notification settings - Fork 193
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
build: consistent build/clean scripts #633
Conversation
309f8e0
to
413c3f5
Compare
we don't use these abi files anywhere downstream
@@ -8,16 +8,21 @@ | |||
"directory": "packages/std-client" | |||
}, | |||
"license": "MIT", | |||
"type": "module", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed this so I could move codegen.mts
to codegen.ts
and align this with the rest of our packages. I ran templates/minimal
with this and it seemed to work just fine.
"dev": "vite build --watch", | ||
"generate-test-tables": "tsx ./scripts/generate-test-tables.ts", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looked more like a one-off script so I moved it out of the build path (doesn't need to be regenerated each time and is expected to be run locally and changes committed).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, though it's easy to forget to run this (and this one changes often, as it's meant to test any changes to tablegen), which is why it was part of test
, even though it doesn't really fit there too well.
If not part of test
, it would be nice to have it somewhere else in CI at least
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added back into test
script for now, will refactor in a follow up as part of #637
"build:typechain": "typechain --target ethers-v5 'abi/**/*.sol/!(*.abi).json'", | ||
"clean": "pnpm run clean:abi && pnpm run clean:typechain && pnpm run clean:js", | ||
"clean:abi": "rimraf abi", | ||
"clean:js": "rimraf dist", | ||
"clean:typechain": "rimraf types", | ||
"docs": "rimraf API && hardhat docgen", | ||
"gas-report": "../cli/dist/mud.js gas-report --path test/* --path test/**/* --save gas-report.json", | ||
"generate-tightcoder": "tsx ./scripts/generate-tightcoder.ts && prettier --write '**/tightcoder/*.sol'", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looked more like a one-off script so I moved it out of the build path (doesn't need to be regenerated each time and is expected to be run locally and changes committed).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this doesn't really change/matter, but if we have some localgen script for generate-test-tables
, tightcoder could also use it
"test": "pnpm run test:solidity && pnpm run test:typescript", | ||
"test:solidity": "forge test", | ||
"test:typescript": "tsc --noEmit" | ||
"test": "tsc --noEmit && forge test" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm planning to come back to this in #637
@@ -1,3 +1,2 @@ | |||
packages: | |||
- packages/* | |||
- docs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved this out for now to avoid running build
on docs when it doesn't depend on anything in the workspace.
Instead, we may want to treat this as a separate app and adjust our docs
scripts throughout to generate files into this docs/
.
"build:js": "vite build", | ||
"build:tightcoder": "tsx ./ts/scripts/codegenTightcoder.ts && prettier --write '**/*.sol'", | ||
"build:mud": "tsx ./ts/scripts/tablegen.ts", | ||
"build:typechain": "typechain --target ethers-v5 'abi/**/*.sol/!(*.abi).json'", | ||
"clean": "pnpm run clean:abi && pnpm run clean:typechain && pnpm run clean:js", | ||
"clean:abi": "rimraf abi", | ||
"clean:js": "rimraf dist", | ||
"clean:typechain": "rimraf types", | ||
"docs": "rimraf API && hardhat docgen", | ||
"gas-report": "../cli/dist/mud.js gas-report --path test/* --path test/**/* --save gas-report.json", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😭 Still need CLI here, but at least this isn't in the build path. I tried to add CLI as a dep, but that creates circular deps again. I also tried to add CLI as a dep in the root package, but there are no bins to link when it attempts to install from the workspace.
We could use whatever npm version is published, but that seems not ideal if we ever want to test changes to the gas report and want to use the local/workspace version.
We could also move the gas report out to common?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the tablegen treatment for gas-report would make sense imo, except yeah it'd go to common rather than store/world. And cli just gets a wrapper over the imported script
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added an issue to track this here: #667
Ready for review! I left a few non-blocking TODOs undone, so we can talk about em and decide if we should create follow up issues/PRs. In terms of the build scripts defined above (and in this PR), is it worth adding a little CI script to validate that no new types of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, though I would prefer to not put off automating generate-test-tables
in some way as it changes too often and cli's tests rely on it (making it part of the build/test pipeline again temporarily would be easiest I guess)
I’m good with moving the test tables codegen step back to test for now. Planning to follow up this PR with some refactoring for test/lint scripts. Will pick this back up next week!
|
Fixes #615
This will help us create a dependency graph of scripts, better caching, etc. (See #620)
The format I took with these build steps is to keep them focused on their output (e.g.
build:js
is for TS -> JS). These are also in execution order.build:go
runs golang build stepsbuild:protobuf
runs codegen for protobufbuild:mud
runs mud-specific codegenmud codegen
but for now istablegen && worldgen && tsgen
(see Movetablegen
toStore
andworldgen
toWorld
to resolve circular dependencies #616)build:abi
runsforge build --extra-output-files abi --out abi --skip test script
for abi files to be used by typechainforge build
in that it 1) also generates abi files, for better imports 2) outputs to a separate directory (for easier typechain targeting) and 3) skips generating files for tests/scripts to avoid cluttering typechainbuild:typechain
runstypechain
to generate typed ethers contracts/interfacesbuild:wasm
runsasc
(just for noise package)build:js
runstsup
orrollup
(see Consolidate JS build tooling #612)Each
build:*
script also has a correspondingclean:*
script, where applicable. Each package also has a correspondingbuild
andclean
that is a combo of any of the above (depending on what the package is doing). I expectbuild
will only be run locally, and nx will use the steps themselves (to resolve dependent steps and run in parallel) (see #620)Some other things to note:
clean:abi
usesrimraf abi
instead offorge clean
because the output directory is separate from the one configured byfoundry.toml
(used by tests, scripts)TODO:
tablegen
toStore
andworldgen
toWorld
to resolve circular dependencies #616) to fix build../cli/dist/mud.js
tomud
with proper depchmod +x
stepbuild:forge
for general building of solidity (i.e. tests, scripts) or let it get handled by e.g.forge test
? do we need aclean:forge
forout
dir?./typechain
instead of default./types/ethers-contracts
?dist
task)?build:codegen
andbuild:mudcodegen
steps? I mostly separated because 1) some mud codegen depended on local cli to be build (thus diff dep tree) and 2) to separate from other types of codegen (e.g. typechain), maybe we move it all into abuild:mud
step?.test-d.ts
in the same dir, consider relocating?build:abi
step from schema-type? not currently in useabi
output vs regularout