|
37 | 37 | default: ""
|
38 | 38 | windows_build_command:
|
39 | 39 | type: string
|
40 |
| - description: "Windows Command Prompt command to build and test the package" |
| 40 | + description: | |
| 41 | + Windows Command Prompt command to build and test the package. |
| 42 | + Note that Powershell does not automatically exit if a subcommand fails. The Invoke-Program utility is available to propagate non-zero exit codes. |
| 43 | + It is strongly encouraged to run all command using `Invoke-Program` unless you want to continue on error eg. `Invoke-Program git apply patch.diff` instead of `git apply patch.diff`. |
41 | 44 | default: "swift test"
|
42 | 45 | linux_env_vars:
|
43 | 46 | description: "List of environment variables"
|
@@ -103,15 +106,23 @@ jobs:
|
103 | 106 | - name: Create test script
|
104 | 107 | run: |
|
105 | 108 | mkdir $env:TEMP\test-script
|
106 |
| - echo 'Set-PSDebug -Trace 1' >> $env:TEMP\test-script\run.ps1 |
107 |
| - echo '$ErrorActionPreference = "Stop"' >> $env:TEMP\test-script\run.ps1 |
108 |
| - echo 'swift --version' >> $env:TEMP\test-script\run.ps1 |
109 |
| - echo 'swift test --version' >> $env:TEMP\test-script\run.ps1 |
110 |
| - echo 'cd C:\source\' >> $env:TEMP\test-script\run.ps1 |
111 | 109 | echo @'
|
| 110 | + Set-PSDebug -Trace 1 |
| 111 | +
|
| 112 | + # Run the command following `Invoke-Program`. |
| 113 | + # If that command returns a non-zero exit code, return the same exit code from this script. |
| 114 | + function Invoke-Program($Executable) { |
| 115 | + & $Executable @args |
| 116 | + if ($LastExitCode -ne 0) { |
| 117 | + exit $LastExitCode |
| 118 | + } |
| 119 | + } |
| 120 | + Invoke-Program swift --version |
| 121 | + Invoke-Program swift test --version |
| 122 | + Invoke-Program cd C:\source\ |
112 | 123 | ${{ inputs.windows_pre_build_command }}
|
| 124 | + Invoke-Program ${{ inputs.windows_build_command }} ${{ (contains(matrix.swift_version, 'nightly') && inputs.swift_nightly_flags) || inputs.swift_flags }} |
113 | 125 | '@ >> $env:TEMP\test-script\run.ps1
|
114 |
| - echo '${{ inputs.windows_build_command }} ${{ (contains(matrix.swift_version, 'nightly') && inputs.swift_nightly_flags) || inputs.swift_flags }}' >> $env:TEMP\test-script\run.ps1 |
115 | 126 | - name: Build / Test
|
116 | 127 | timeout-minutes: 60
|
117 | 128 | run: |
|
|
0 commit comments