-
Notifications
You must be signed in to change notification settings - Fork 140
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
actions: run: Check script exists during recipe verification #302
base: main
Are you sure you want to change the base?
Conversation
a8a574e
to
f4d49c5
Compare
fwiw this would be a great change to start adding test for |
27c3f44
to
fb2c1c0
Compare
fb2c1c0
to
8fd0ace
Compare
8fd0ace
to
8c6a800
Compare
Rework the logic to extract the script path and arguments into one place such that the code is more readable with less duplication. Signed-off-by: Christopher Obbard <[email protected]>
The label for the run action currently contains all of the arguments of a script; change this to just show the base path of the script so we don't pollute the log. Signed-off-by: Christopher Obbard <[email protected]>
If a script doesn't exist or the permissions are wrong, the recipe exits during the recipe execution. Let's do some early checks in the Verify stage to ensure the script exists on the host filesystem and a basic check that the file has executable permission bit set. This check also follows symlinks. Signed-off-by: Christopher Obbard <[email protected]>
Signed-off-by: Christopher Obbard <[email protected]>
8c6a800
to
5fe7313
Compare
@@ -120,7 +120,7 @@ func (run *RunAction) doRun(context debos.DebosContext) error { | |||
} | |||
cmdline = []string{run.scriptPath} | |||
cmdline = append(cmdline, run.scriptArgs...) | |||
label = path.Base(run.Script) | |||
label = path.Base(run.scriptPath) |
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.
but then you don't see the arguments to the script anymore, which is a loss.. Probably this doesn't belong in this PR (it doesn't help with your stated target i think) but preventing "pollution" we could do either by:
- unify truncating the length like the Command handling does
- printing what gets run first and then either not or only providing a minimal label on each line after
return err | ||
} | ||
|
||
if stat.IsDir() { |
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.
Rather then checking if it's a Dir this should proably check if it's a regular file
} | ||
|
||
/* Check the script is executable */ | ||
if stat.Mode()&0111 == 0 { |
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.
executable and readable ideally; though i don't think golang gives you nice helpers for that unfortunately :/
@@ -136,6 +136,8 @@ jobs: | |||
test: { name: "arch", case: "arch" } | |||
- backend: kvm | |||
test: { name: "apertis", case: "apertis" } | |||
- backend: kvm | |||
test: { name: "run", case: "run" } |
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.
kvm actually has the highest latency atm because of the runner setup; and really this should probably run on all types.. That said could you merge it with an existing tests so we don't need a new CI job for it ?
e.g. maybe merge it with the recipes test and the overlay test :)
If a script doesn't exist or the permissions are wrong, the
recipe exits during execution. Let's check early if the
script exists on the host filesystem and that the file has
executable permission bit set.
Signed-off-by: Christopher Obbard [email protected]