Conversation
Problem - version drift - both IDL files carry the interface crate version - `cargo release` bumps the manifest, so the committed files fall behind - the IDL job regenerates the files, then compares them against the tree - the job fails after every release, so someone bumps the files by hand Summary of Changes - replace the program version in both IDL files during a release, so the release commit carries them
joncinque
left a comment
There was a problem hiding this comment.
Looks great to me! This is a great way to solve the problem, and I tested that it works. Just some nits to make it more robust.
cc @lorisleiva since we've discussed some sort of action to do this in the past. This seems like a very neat and easy solution
|
|
||
| [package.metadata.release] | ||
| pre-release-replacements = [ | ||
| { file = "../idl.json", search = '("publicKey": "Stake11111111111111111111111111111111111111",\n "version": ")[^"]+', replace = "${1}{{version}}", exactly = 1 }, |
There was a problem hiding this comment.
nit: in case we end up changing the spacing, can we make this slightly more robust?
| { file = "../idl.json", search = '("publicKey": "Stake11111111111111111111111111111111111111",\n "version": ")[^"]+', replace = "${1}{{version}}", exactly = 1 }, | |
| { file = "../idl.json", search = '("publicKey":\s*"Stake11111111111111111111111111111111111111",\s*"version":\s*")[^"]+', replace = "${1}{{version}}", exactly = 1 }, |
| [package.metadata.release] | ||
| pre-release-replacements = [ | ||
| { file = "../idl.json", search = '("publicKey": "Stake11111111111111111111111111111111111111",\n "version": ")[^"]+', replace = "${1}{{version}}", exactly = 1 }, | ||
| { file = "../interface-idl.json", search = '("publicKey": "Stake11111111111111111111111111111111111111",\n "version": ")[^"]+', replace = "${1}{{version}}", exactly = 1 }, |
There was a problem hiding this comment.
nit: same here
| { file = "../interface-idl.json", search = '("publicKey": "Stake11111111111111111111111111111111111111",\n "version": ")[^"]+', replace = "${1}{{version}}", exactly = 1 }, | |
| { file = "../interface-idl.json", search = '("publicKey":\s*"Stake11111111111111111111111111111111111111",\s*"version":\s*")[^"]+', replace = "${1}{{version}}", exactly = 1 }, |
|
@joncinque If I understand correctly even though the Codama Macros already do use the |
No not quite, this bumps the IDL version to the new / correct version after the crate is released. Currently, every time we bump the interface crate version, we immediately get CI failures because the IDL version is out of sync. This will make it so we avoid that extra manual step every time. Unless the better option is to perform a post-bump step to re-run codama to pick up the newest version and commit it? |
Problem - the replacement pattern hardcodes the IDL's current spacing, so a reformat breaks the release Summary of Changes - match any whitespace around the `publicKey` and `version` fields
|
We could also run the full script as |
That would have been my go-to solution yeah but I'm not sure how feasible it is to add this post-bump step to the Rust pipeline. |
I don't disagree but I'm also not a fan of the fact that we end up with two places to check when it comes to IDL generation. But again I'm not sure how complex that plumbing is in Rust so happy with the current solution is the trade-off is not worth it. |
|
Seems like it will boil down to something like this and the cost will be that the release pipeline needs to install the necessary tools... I agree this is cleaner, so let me prepare this one. |
Problem
cargo releasebumps the manifest, so the committed files fall behindSummary of Changes
Testing
A. Semver-job form — mirrors “Set Version” in solana-program/actions publish-rust.yml, run from the repo root:
B. Publish-job form — mirrors this repo’s make publish-rust-interface, run inside interface/. The extra --no-publish --no-push --no-tag flags keep the test off crates.io and the remote:
Result. Both forms produce a chore: Release commit containing these hunks: