Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 9 additions & 1 deletion .github/workflows/upgrade-version-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,16 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
# pnpm is required for regenerating the typescript bindings
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- uses: pnpm/action-setup@v4
with:
run_install: true
- name: Verify that upgrade-version still works
run: cargo bump-versions 123.456.789 --rust-and-cli --csharp --typescript
run: cargo bump-versions 123.456.789 --rust-and-cli --csharp --typescript --accept-snapshots
- name: Show diff
run: git diff HEAD

48 changes: 48 additions & 0 deletions tools/upgrade-version/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@ fn main() -> anyhow::Result<()> {
.help("Update all targets (equivalent to --typescript --rust-and-cli --csharp)")
.conflicts_with_all(["typescript", "rust-and-cli", "csharp"]),
)
.arg(
Arg::new("accept-snapshots")
.long("accept-snapshots")
.action(clap::ArgAction::SetTrue)
.help("If there are snapshots to review automatically accept them all."),
)
.group(
ArgGroup::new("update-targets")
.args(["all", "typescript", "rust-and-cli", "csharp"])
Expand Down Expand Up @@ -184,7 +190,49 @@ fn main() -> anyhow::Result<()> {

process_license_file("LICENSE.txt", &full_version);
process_license_file("licenses/BSL.txt", &full_version);
println!("$> cargo check");
cmd!("cargo", "check").run().expect("Cargo check failed!");

println!("$> pnpm install");
cmd!("pnpm", "install").run().expect("pnpm run build failed!");

println!("$> pnpm run build");
cmd!("pnpm", "run", "build").run().expect("pnpm run build failed!");

println!("$> pnpm --dir templates/chat-react-ts generate");
cmd!("pnpm", "--dir", "templates/chat-react-ts", "generate")
.run()
.expect("pnpm generate failed!");

if matches.get_flag("accept-snapshots") {
// Generate and auto-accept snapshots
println!("$> INSTA_UPDATE=always cargo test -p spacetimedb-codegen --test codegen");
cmd!("cargo", "test", "-p", "spacetimedb-codegen", "--test", "codegen")
.env("INSTA_UPDATE", "always")
.run()
.expect("cargo test -p spacetimedb-codegen --test codegen (INSTA_UPDATE=always) failed!");
} else {
println!("$> cargo install cargo-insta");
cmd!("cargo", "install", "cargo-insta")
.run()
.expect("cargo install cargo-insta failed!");

// Initial test - this will generate snapshots. This is expected to fail.
println!("$> cargo test -p spacetimedb-codegen --test codegen");
let _ = cmd!("cargo", "test", "-p", "spacetimedb-codegen", "--test", "codegen").run();

// Review the new snapshots
println!("$> cargo insta review");
cmd!("cargo", "insta", "review")
.run()
.expect("cargo insta review failed!");

// Test again now that the user has had a chance to accept the snapshots
println!("$> cargo test -p spacetimedb-codegen --test codegen");
cmd!("cargo", "test", "-p", "spacetimedb-codegen", "--test", "codegen")
.run()
.expect("cargo test -p spacetimedb-codegen --test codegen failed!");
}
}

if matches.get_flag("typescript") || matches.get_flag("all") {
Expand Down
Loading