-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Job hook provider now sets shell name for script handler #1826
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
dd3288f
Job hook provider now sets shell name for script handler
nikola-jokic 916360b
Merge branch 'actions:main' into nikola-jokic/bug/1825
nikola-jokic cc19f15
fixed script handler and job hook provider to work with the name with…
nikola-jokic 33dbe4b
returned used import by osx
nikola-jokic 8c3aae0
fixed order of imports
nikola-jokic 12cfebc
added quotes around resolved script path allowing space in script path
nikola-jokic aeb0715
added quotes around bash and sh _defaultArguments
nikola-jokic 6c92798
Changed double quotes to single quotes in sh -e
nikola-jokic 64ca058
Changed double quotes to single quotes in bash
nikola-jokic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
using System; | ||
using System.IO; | ||
using System.Linq; | ||
using GitHub.Runner.Sdk; | ||
|
||
namespace GitHub.Runner.Sdk | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,8 +13,8 @@ internal class ScriptHandlerHelpers | |
["cmd"] = "/D /E:ON /V:OFF /S /C \"CALL \"{0}\"\"", | ||
["pwsh"] = "-command \". '{0}'\"", | ||
["powershell"] = "-command \". '{0}'\"", | ||
["bash"] = "--noprofile --norc -e -o pipefail {0}", | ||
["sh"] = "-e {0}", | ||
["bash"] = "--noprofile --norc -e -o pipefail '{0}'", | ||
["sh"] = "-e '{0}'", | ||
["python"] = "{0}" | ||
}; | ||
|
||
|
@@ -82,18 +82,23 @@ internal static (string shellCommand, string shellArgs) ParseShellOptionString(s | |
} | ||
} | ||
|
||
internal static string GetDefaultShellForScript(string path, Common.Tracing trace, string prependPath) | ||
internal static string GetDefaultShellNameForScript(string path, Common.Tracing trace, string prependPath) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NOTE: This will cause conflicts for the container hook PR, but I'd rather solve them there |
||
{ | ||
var format = "{0} {1}"; | ||
switch (Path.GetExtension(path)) | ||
{ | ||
case ".sh": | ||
// use 'sh' args but prefer bash | ||
var pathToShell = WhichUtil.Which("bash", false, trace, prependPath) ?? WhichUtil.Which("sh", true, trace, prependPath); | ||
return string.Format(format, pathToShell, _defaultArguments["sh"]); | ||
if (WhichUtil.Which("bash", false, trace, prependPath) != null) | ||
{ | ||
return "bash"; | ||
} | ||
return "sh"; | ||
case ".ps1": | ||
var pathToPowershell = WhichUtil.Which("pwsh", false, trace, prependPath) ?? WhichUtil.Which("powershell", true, trace, prependPath); | ||
return string.Format(format, pathToPowershell, _defaultArguments["powershell"]); | ||
if (WhichUtil.Which("pwsh", false, trace, prependPath) != null) | ||
{ | ||
return "pwsh"; | ||
} | ||
return "powershell"; | ||
default: | ||
throw new ArgumentException($"{path} is not a valid path to a script. Make sure it ends in '.sh' or '.ps1'."); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Using
!IsActionStep
to explicitly limit the scope of this change to job hooks (and later container hooks - even if a container hook is a run-script-step or run-container-step, the ScriptHandler object executing the hook will not have an associated action)