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

Finish spacetimedb-update functionality #2126

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

coolreader18
Copy link
Collaborator

@coolreader18 coolreader18 commented Jan 14, 2025

Description of Changes

based off #2011

Adds implementations to all the subcommands of spacetime version.

Expected github release artifact structure:

  • artifact filename: spacetime-{rustc-target-triple}.{ext}
    • ext = if windows { "zip" } else { "tar.gz" }
  • artifact contents:
    • spacetimedb-cli[.exe], spacetimedb-standalone[.exe], spacetimedb-update[.exe]

cc @clockworklabs/devops - feedback on this^^ would be nice. I kept the edge cases since that's how it already was and I figured that might make it easier in the release workflow, but honestly I'd prefer if it was just spacetime-{rustc-target-triple}.{ext} if possible. Not sure where the release flow is or if it's even automated. Implemented in #2193.

Expected complexity level and risk

3 - a complex bit of code that's implementing a theoretically perpetual contract between spacetimedb-update, github release artifacts, and the directory structure.

Testing

  • Manually tested that spacetime version install works
  • I'm working on an automated regrtest to make sure the functionality works.
  • reviewer: if you wanna, play around with it and try and catch out any edge cases?

@coolreader18 coolreader18 force-pushed the noa/spacetime-update-impl branch 5 times, most recently from 621fba2 to 59ec2a0 Compare January 17, 2025 18:17
@coolreader18 coolreader18 marked this pull request as ready for review January 17, 2025 20:43
@bfops
Copy link
Collaborator

bfops commented Jan 18, 2025

(It looks like this currently isn't passing CI, so I'm holding off on review)

crates/auth/Cargo.toml Outdated Show resolved Hide resolved
crates/cli/src/config.rs Outdated Show resolved Hide resolved
crates/paths/src/cli.rs Outdated Show resolved Hide resolved
@bfops
Copy link
Collaborator

bfops commented Jan 29, 2025

Review notes:

  • The previous functionality of spacetime version is now accomplished by spacetime --version (and spacetime version list indicates which version is the current one)

let status = cmd
.status()
.with_context(|| format!("exec failed for {}", bin_path.display()))?;
let status = result.with_context(|| format!("exec failed for {}", bin_path.display()))?;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe these changes are to address #2133.

Given that that issue has a different purpose and surface area for testing than the update functionality, I would like to suggest addressing it in a separate PR.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Split out into #2200.

@bfops
Copy link
Collaborator

bfops commented Jan 29, 2025

Note to self: I still need to:

  • review crates/cli/src/subcommands/version.rs
  • review crates/paths
  • review crates/update itself
  • jot down what I think the surface area for testing is here

@coolreader18 coolreader18 mentioned this pull request Jan 29, 2025
1 task
crates/paths/src/cli.rs Outdated Show resolved Hide resolved
crates/paths/src/cli.rs Outdated Show resolved Hide resolved
@coolreader18 coolreader18 force-pushed the noa/spacetime-update-impl branch from 35e5488 to 030c9b3 Compare January 31, 2025 18:50
@coolreader18
Copy link
Collaborator Author

I removed the rm-core-as-dep-of-cli commit from this branch, I'll do it as a follow-up PR.

@coolreader18 coolreader18 force-pushed the noa/spacetime-update-impl branch from 030c9b3 to 80940cc Compare January 31, 2025 19:00
};
#[cfg(windows)]
let result = {
cmd.env("SPACETIMEDB_UPDATE_MULTICALL_APPLET", applet);
Copy link
Collaborator

@bfops bfops Jan 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this needed because the args[0] behavior is different on windows than on linux e.g. if going via a shortcut/symlink?

What's the advantage of doing this differently on windows vs unix than just always doing this env-based approach?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ultimately this is a hack to get behavior like argv0 on windows. In the future, there'll hopefully be a function akin to argv0 on windows, but for now this is the best approximation. rust-lang/rust#66510

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense. I think my question remains though: if the "hack" is good enough for windows, why not just use it on both platforms and have less surface area for edge cases?

Copy link
Collaborator Author

@coolreader18 coolreader18 Feb 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I probably don't have an answer for that besides "that feels icky". would you like me to change it?

crates/paths/src/cli.rs Outdated Show resolved Hide resolved
@bfops
Copy link
Collaborator

bfops commented Jan 31, 2025

(I merged in master to bump CI. The Internal tests were failing due to them running before https://github.com/clockworklabs/SpacetimeDBPrivate/pull/1279 merged).

let args = args.collect::<Vec<_>>();
if args.first().is_some_and(|s| s == "version") {
// if the first arg is unambiguously `version`, go straight to `spacetime version`
spacetimedb_update_main()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q: is this case necessary for some reason? Won't the CLI end up delegating back to spacetimedb-update anyway?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but there's no perfect way for the cli to find the update binary again. If you're running via cargo run or something, it'll find cli_bin_path in ~/.local, but then spacetime version will delegate to a different binary. It all sucks, but I feel this avoids the most bad edge cases.

@coolreader18 coolreader18 force-pushed the noa/spacetime-update-impl branch from 90089f7 to 05186de Compare February 4, 2025 22:11
@coolreader18 coolreader18 force-pushed the noa/spacetime-update-impl branch from 05186de to 7f72ea7 Compare February 4, 2025 22:22
#[clap(allow_hyphen_values = true)]
args: Vec<OsString>,
},
SelfInstall {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this subcommand is new since my last review? What motivated this?

fn main() {
let target = std::env::var("TARGET").unwrap();
println!("cargo::rustc-env=BUILD_TARGET={target}");
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not very familiar with massaging the build process - what's this for?


/// Set a local installation of SpacetimeDB as a custom version.
#[derive(clap::Args)]
pub(super) struct Link {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is new since my last review - why did we add this in here? It does seem convenient but it's whole extra bit of surface area that I think we could add in a backwards-compatible way later. Was it part of some spec somewhere or did Tyler request it or something?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Directory structure - Implement new spacetimedb-update cli
2 participants