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

Option to force build before deploy #97

Merged
merged 1 commit into from
Sep 25, 2023

Conversation

itowlson
Copy link
Contributor

Fixes #95.

Happy path:

ivan@hecate:~/testing/hello3$ spin deploy --build
Building component hello3 with `cargo build --target wasm32-wasi --release`
   Compiling hello3 v0.1.0 (/home/ivan/testing/hello3)
    Finished release [optimized] target(s) in 1.19s
Finished building all Spin components
Uploading hello3 version 0.1.0+r73691dd...
Deploying...
Waiting for application to become ready.......... ready
Available Routes:
  hello3: https://hello3-prfvru2v.fermyon.app (wildcard)

Sad path:

ivan@hecate:~/testing/hello3$ spin deploy --build
Building component hello3 with `cargo build --target wasm32-wasi --release`
   Compiling hello3 v0.1.0 (/home/ivan/testing/hello3)
error[E0425]: cannot find function, tuple struct or tuple variant `Sum` in this scope
  --> src/lib.rs:12:15
   |
12 |         .body(Sum("Hello, Mistress Ploppy".into()))?)
   |               ^^^ not found in this scope

For more information about this error, try `rustc --explain E0425`.
error: could not compile `hello3` (lib) due to previous error
Error: Build command for component hello3 failed with status Exited(101)
Error: Build failed: deployment cancelled

I know that's a lot of errors at the end but that's fiddly to fix with the way Rust handles Result::Err exits. It can be addressed but I'm not keen to rework that as part of this PR.

Comment on lines +94 to +85
#[clap(long, takes_value = false, env = "SPIN_ALWAYS_BUILD")]
pub build: bool,
Copy link
Collaborator

Choose a reason for hiding this comment

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

We could potentially add a shorter argument "-b"? Just curious and do not have any strong preference or is this match with spin

Copy link
Contributor Author

Choose a reason for hiding this comment

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

spin up currently only supports the long form.


async fn run_spin_build(&self) -> Result<()> {
let manifest_path = self.app()?;
let spin_bin = std::env::var("SPIN_BIN_PATH")?;
Copy link
Collaborator

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 add this as a constant? I mean the string "SPIN_BIN_PATH"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried creating a const but it ended up feeling like noise so I rage-encapsulated it as a "give me the Spin binary path" function instead

/// Specifies to perform `spin build` before deploying the application.
#[clap(long, takes_value = false, env = "SPIN_ALWAYS_BUILD")]
pub build: bool,

/// Deploy existing bindle if it already exists on bindle server
#[clap(short = 'e', long = "deploy-existing-bindle")]
Copy link
Member

Choose a reason for hiding this comment

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

Does the build option conflict with deploy existing bindle? How should one think about these two options?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does the deploy existing bindle option still exist? I couldn't see it in the code but yeah there's not much point doing a build of the local app just to deploy an existing remote app (although I think it would be harmless but I'm not sure what deploy existing bindle does).

Copy link
Contributor Author

@itowlson itowlson Sep 25, 2023

Choose a reason for hiding this comment

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

Oh I see it existed in main when I wrote this PR but not when I looked at main just now. So I think this conundrum has gone away (thanks Vaughn and Team OCI)

Copy link
Member

Choose a reason for hiding this comment

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

Not sure. It would be nice to sync on all the bindle related code for 2.0 (added to 2.0 board). For now, does it make sense to add a conflicts_with requirement to the deploy-existing-bindle flag for clarity? Agree on it being harmless though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry - I wasn't clear because I was figuring things out as I went! I can't add a conflicts_with on deploy-existing-bindle because deploy-existing-bindle was removed. There is no bindle any more: there is only OCI. And there is no longer a redeploy option. So the problem goes away.

Copy link
Member

Choose a reason for hiding this comment

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

excellent!

Signed-off-by: itowlson <ivan.towlson@fermyon.com>
@itowlson itowlson merged commit 54a113a into fermyon:main Sep 25, 2023
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Detect SPIN_ALWAYS_BUILD
4 participants