Skip to content

Commit d3c64be

Browse files
authored
Do not assume windows_build_command is a single line (#154)
`windows_build_command` was prefixed with a `Invoke-Program` to ensure we catch errors, but this then misses multiline commands. Move `Invoke-Program` up into the default command and then assume that it is passed if a non-default command is used. Note that `$ErrorActionPreference = 'Stop'` is not an option here - it only stops for cmdlets, not native commands. `$PSNativeCommandUseErrorActionPreference = $true` allows stopping on native commands too, but that was only introduced in PowerShell 7.3. windowsservercore-ltsc2022 has 5.1 by default (though we could install a newer if we wanted to). Update PR testing in this repo to use `Invoke-Program` to then actually catch failures.
1 parent 818776f commit d3c64be

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

.github/workflows/pull_request.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ jobs:
4545
windows_build_command: |
4646
mkdir MyPackage
4747
cd MyPackage
48-
swift package init --type library
49-
swift build
48+
Invoke-Program swift package init --type library
49+
Invoke-Program swift build
5050
enable_windows_docker: true
5151

5252
tests_without_docker:
@@ -59,8 +59,8 @@ jobs:
5959
windows_build_command: |
6060
mkdir MyPackage
6161
cd MyPackage
62-
swift package init --type library
63-
swift build
62+
Invoke-Program swift package init --type library
63+
Invoke-Program swift build
6464
enable_windows_docker: false
6565

6666
tests_macos:

.github/workflows/swift_package_test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ on:
102102
Windows Command Prompt command to build and test the package.
103103
Note that Powershell does not automatically exit if a subcommand fails. The Invoke-Program utility is available to propagate non-zero exit codes.
104104
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`.
105-
default: "swift test"
105+
default: "Invoke-Program swift test"
106106
macos_env_vars:
107107
description: "Newline separated list of environment variables"
108108
type: string
@@ -450,7 +450,7 @@ jobs:
450450
Invoke-Program swift test --version
451451
Invoke-Program cd $Source
452452
${{ inputs.windows_pre_build_command }}
453-
Invoke-Program ${{ inputs.windows_build_command }} ${{ (contains(matrix.swift_version, 'nightly') && inputs.swift_nightly_flags) || inputs.swift_flags }}
453+
${{ inputs.windows_build_command }} ${{ (contains(matrix.swift_version, 'nightly') && inputs.swift_nightly_flags) || inputs.swift_flags }}
454454
'@ >> $env:TEMP\test-script\run.ps1
455455
# Docker build
456456
- name: Docker Build / Test

0 commit comments

Comments
 (0)