-
Notifications
You must be signed in to change notification settings - Fork 251
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: add workdir for component build command #515
Conversation
Signed-off-by: Moritz <moritz.zielke@gmail.com>
crates/build/src/lib.rs
Outdated
@@ -38,13 +38,13 @@ async fn build_component(raw: RawComponentManifest, src: impl AsRef<Path>) -> Re | |||
"Executing the build command for component {}: {}", | |||
raw.id, b.command | |||
); | |||
let workdir = construct_workdir(src.as_ref(), b.workdir.as_ref())?; | |||
if !src.as_ref().starts_with(workdir.as_path()) { |
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.
This won't catch --workdir=..
. Perhaps it should be:
if !src.as_ref().starts_with(workdir.as_path()) { | |
if b.workdir.is_some() { |
or just print the workdir unconditionally.
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.
The workdir
returned by construct_workdir
is absolutized, so it shouldn't contain dots. But that's implicit and your suggestion definitely makes the intent clearer.
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.
Right, and workdir
is also absolutized at this point, so --workdir=..
would always resolve to a prefix of src
.
Signed-off-by: Moritz <moritz.zielke@gmail.com>
Signed-off-by: Moritz <moritz.zielke@gmail.com>
The test which failed on windows is refactored, it should be independent of the OS now. I can't test it on windows myself, unfortunately, since I don't have a windows machine. Waiting on CI. |
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.
Thanks for the PR!
That didn't work. These assertions seem to be failing in windows-latest CI: Maybe use |
Ah sorry, you probably can't see the CI logs:
Looks like its a Windows Additionally, as I was looking at the docs for |
Could the following work cross-platform?
command = "touch foo" # quick and doesn't produce large artifacts
Then we would be testing the behavior of If this works, I think
I'm going to replace |
👍 Sounds like a good plan.
Those are just exact opposites.
I don't think it makes a ton of difference either way; I think those two relative path forms are uncommon on Windows anyway. |
I'm going to give it a try! Maybe rather in a separate PR?
Oops sorry, I meant to say I'm going to replace it with |
Do you mean replacing this one or after this one? We don't want to merge a PR that breaks CI. |
It was testing a private function. Instead, the behavior will be tested by an integration test for spin build. Signed-off-by: Moritz <moritz.zielke@gmail.com>
Signed-off-by: Moritz <moritz.zielke@gmail.com>
The Assuming CI now passes on Windows too, the idea was to merge this PR as is and then open a new one to add the integration test of |
Sounds good; thanks for the contribution! |
Fixes #406
If
workdir
is not relative an error is returned, assuming it's best to aborton encountering an invalid value in the configuration. Alternatively, an invalid
workdir
could be ignored and a warning be logged.Specifying a
workdir
which is not a subdirectory ofsrc
is currentlyallowed, for example
../other-app
. I'm assuming that's okay sinceusers should inspect
spin.toml
anyway before running spin (e.g. to check ifthey really want to execute the build command).
Example usage
In
examples/foo/spin.toml
updated resp. add the following:After building
spin
with these changes, it is possible to:Signed-off-by: Moritz moritz.zielke@gmail.com