-
Notifications
You must be signed in to change notification settings - Fork 16
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
feat: automate compatible CFE upgrades #4149
Conversation
Codecov Report
@@ Coverage Diff @@
## main #4149 +/- ##
======================================
Coverage 72% 72%
======================================
Files 378 378
Lines 60906 61335 +429
Branches 60906 61335 +429
======================================
+ Hits 43687 43997 +310
- Misses 14955 15061 +106
- Partials 2264 2277 +13 see 59 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
35f79b5
to
b108da9
Compare
export async function compileBinaries(type: 'runtime' | 'all', projectRoot: string) { | ||
if (type === 'all') { | ||
console.log('Building all the binaries...'); | ||
execSync(`cd ${projectRoot} cargo build --release`); |
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.
You can use pushd
instead of cd
and then popd
so that the current directory doesn't change for whoever runs the 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.
Nice, didn't know this.
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 tried using it, doesn't seem to work with execSync
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.
Ah, of course, it doesn't work because execSync
would spawn different shells each time, and so the same commands don't share the same "directory stack". Could probably do something similar in JS by remembering pwd
before cd
, but not super important.
bouncer/shared/upgrade_network.ts
Outdated
const fromTomlVersion = await readPackageTomlVersion(path.dirname(process.cwd())); | ||
console.log("Version we're upgrading from: " + fromTomlVersion); | ||
|
||
// abcd124 ensures there's no bracnh with the same name that will stop us from creating the workspace. |
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.
To which abcd124
is this referring to?
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.
stale comment, removed.
console.log("Version we're upgrading from: " + fromTomlVersion); | ||
|
||
// abcd124 ensures there's no bracnh with the same name that will stop us from creating the workspace. | ||
// tmp/ is ignored in the bouncer .gitignore file. |
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.
Would it make sense to ask the OS for a temporary directory? We do that with rust in other places, but not sure how to do that with JS. Looks like mktemp
is a common GNU utility for that (seems to come by default with osx 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.
Maybe, I did think about doing something like this, but I liked keeping everything in this same file structure where possible rather than going out to /var/ etc, where the folder names change. Is a little simpler to reason about the file paths this way. And if wanted to add an option to not clean up the files when upgraded - it's nicer to have the prebuilt files in a pre-known directory for example.
4130ea8
to
8c45a61
Compare
Pull Request
Closes: PRO-899
Checklist
Please conduct a thorough self-review before opening the PR.
Summary
Automates the process of upgrading from one commit to another - as long as the versions are compatible with the old CFE. Incompatible coming next 🚀
Pre requisite:
For example: If you're on tag 0.10.0, you can run:
It'll do everything from compile the new runtime at the commit specified, writing the version bumps in the Cargo.toml files so that the version is correctly updated in the runtime storage to submitting the runtime upgrade to the network.
It does all this using git worktree so it doesn't override anything you might have in progress on your current working branch.