Add pwsh as the default shell for windows runners

This commit is contained in:
Alvaro Muñoz
2024-10-17 10:40:33 +02:00
parent 09f1fd1a81
commit b072cfa1f7
2 changed files with 31 additions and 2 deletions

View File

@@ -1438,12 +1438,18 @@ class RunImpl extends StepImpl {
/** Gets the shell for this `run` mapping. */
string getShell() {
if exists(n.lookup("shell").(YamlString).getValue())
if exists(n.lookup("shell"))
then result = n.lookup("shell").(YamlString).getValue()
else
if exists(this.getInScopeDefaultValue("run", "shell"))
then result = this.getInScopeDefaultValue("run", "shell").getValue()
else result = "bash"
else
if this.getEnclosingJob().getARunsOnLabel().matches(["ubuntu%", "macos%"])
then result = "bash"
else
if this.getEnclosingJob().getARunsOnLabel().matches("windows%")
then result = "pwsh"
else result = "bash"
}
ShellScriptImpl getScript() { result = scriptScalar }

View File

@@ -0,0 +1,23 @@
on: push
jobs:
job1:
runs-on: ubuntu-latest
steps:
- shell: pwsh
run: Write-Output "foo"
job2:
runs-on: ubuntu-latest
steps:
- run: echo "foo"
job3:
runs-on: windows-latest
steps:
- shell: bash
run: echo "foo"
job4:
runs-on: windows-latest
steps:
- run: Write-Output "foo"