Skip to content

Commit db04768

Browse files
committed
Enable SwiftBuild in pipeline
Ensure we run the pipeliines against SwiftBuild to give us extra confidence with the tooling Skip running SwiftBuild on Windows as it's currently failing. Fixes: #9070
1 parent cb587d2 commit db04768

File tree

5 files changed

+197
-68
lines changed

5 files changed

+197
-68
lines changed

.github/workflows/pull_request.yml

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,54 @@ concurrency:
1212
cancel-in-progress: true
1313

1414
jobs:
15-
tests:
16-
name: Test
15+
tests-using-native:
16+
needs: [soundness]
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
buildSystem: ["native", "swiftbuild"]
21+
linuxSwiftVersion: ['["nightly-main", "nightly-6.2"]', '["nightly-main"]']
22+
enable_windows_checks: [true]
23+
exclude:
24+
- buildSystem: "swiftbuild"
25+
linuxSwiftVersion: '["nightly-main", "nightly-6.2"]'
26+
- buildSystem: "swiftbuild"
27+
enable_windows_checks: true
28+
- buildSystem: "native"
29+
linuxSwiftVersion: '["nightly-main"]'
30+
name: Test (${{ matrix.buildSystem }})
31+
uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@0.0.1
32+
with:
33+
linux_os_versions: '["amazonlinux2", "bookworm", "noble", "jammy", "rhel-ubi9"]'
34+
linux_swift_versions: ${{ matrix.linuxSwiftVersion }}
35+
linux_pre_build_command: ./.github/scripts/prebuild.sh
36+
linux_build_command: 'swift run swift-build --build-tests --build-system ${{ matrix.buildSystem}}'
37+
windows_swift_versions: '["nightly-main"]'
38+
windows_pre_build_command: 'Invoke-Program .\.github\scripts\prebuild.ps1'
39+
windows_build_command: 'Invoke-Program swift run swift-build --build-tests --build-system ${{ matrix.buildSystem}}'
40+
enable_windows_checks: ${{ matrix.enable_windows_checks }}
41+
enable_ios_checks: true
42+
enable_macos_checks: true
43+
macos_exclude_xcode_versions: "[{\"xcode_version\": \"16.3\"}, {\"xcode_version\": \"16.4\"}]"
44+
macos_build_command: 'swift run swift-build --build-tests --build-system ${{ matrix.buildSystem}}'
45+
46+
tests-using-swiftbuild:
47+
name: Test (all SwiftBuild)
48+
needs: [soundness]
1749
uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@0.0.1
1850
with:
1951
linux_os_versions: '["amazonlinux2", "bookworm", "noble", "jammy", "rhel-ubi9"]'
2052
linux_swift_versions: '["nightly-main"]'
2153
linux_pre_build_command: ./.github/scripts/prebuild.sh
22-
linux_build_command: 'swift build'
54+
linux_build_command: 'swift run --build-system swiftbuild swift-build --build-tests --build-system swiftbuild'
55+
enable_windows_checks: false
2356
windows_swift_versions: '["nightly-main"]'
2457
windows_pre_build_command: 'Invoke-Program .\.github\scripts\prebuild.ps1'
25-
windows_build_command: 'Invoke-Program swift build'
58+
windows_build_command: 'Invoke-Program swift run --build-system swiftbuild swift-build --build-tests --build-system swiftbuild'
2659
enable_ios_checks: true
2760
enable_macos_checks: true
2861
macos_exclude_xcode_versions: "[{\"xcode_version\": \"16.3\"}, {\"xcode_version\": \"16.4\"}]"
29-
macos_build_command: 'swift build'
62+
macos_build_command: 'swift run --build-system swiftbuild swift-build --build-tests --build-system swiftbuild'
3063

3164
soundness:
3265
name: Soundness

Sources/SwiftBuildSupport/PackagePIFBuilder+Helpers.swift

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ import enum SwiftBuild.ProjectModel
6363

6464
enum TargetSuffix: String {
6565
case testable, dynamic
66-
66+
6767
func hasSuffix(id: GUID) -> Bool {
6868
id.value.hasSuffix("-\(self.rawValue)")
6969
}
@@ -524,18 +524,18 @@ extension PackageGraph.ResolvedModule {
524524

525525
/// Target-specific single-value build settings declared in the manifest and that apply to the target itself.
526526
var targetSingleValueSettings: [BuildConfiguration: SingleValueSettingsByPlatform] = [:]
527-
527+
528528
/// Target-specific multiple-value build settings declared in the manifest and that apply to the target itself.
529529
var targetMultipleValueSettings: [BuildConfiguration: MultipleValueSettingsByPlatform] = [:]
530530

531531
/// Target-specific single-value build settings that should be imparted to client targets (packages and projects).
532532
var impartedSingleValueSettings: SingleValueSettingsByPlatform = [:]
533-
533+
534534
/// Target-specific multiple-value build settings that should be imparted to client targets (packages and projects).
535535
var impartedMultipleValueSettings: MultipleValueSettingsByPlatform = [:]
536-
536+
537537
// MARK: - Convenience Methods
538-
538+
539539
/// Apply all settings to a ProjectModel.BuildSettings instance
540540
func apply(to buildSettings: inout ProjectModel.BuildSettings, for configuration: BuildConfiguration) {
541541
// Apply single value settings for all platforms
@@ -550,7 +550,7 @@ extension PackageGraph.ResolvedModule {
550550
}
551551
}
552552
}
553-
553+
554554
// Apply multiple value settings for all platforms
555555
if let multipleValuesByPlatform = targetMultipleValueSettings[configuration] {
556556
// First, collect all multiple-value settings that are being used
@@ -560,7 +560,7 @@ extension PackageGraph.ResolvedModule {
560560
usedMultipleValueSettings.insert(setting)
561561
}
562562
}
563-
563+
564564
// Now apply the platform-specific values
565565
for (platform, multipleValues) in multipleValuesByPlatform {
566566
for (setting, values) in multipleValues {
@@ -577,7 +577,7 @@ extension PackageGraph.ResolvedModule {
577577
}
578578
}
579579
}
580-
580+
581581
/// Apply imparted settings to a ProjectModel.BuildSettings instance
582582
func applyImparted(to buildSettings: inout ProjectModel.BuildSettings) {
583583
// Apply imparted single value settings for all platforms
@@ -590,7 +590,7 @@ extension PackageGraph.ResolvedModule {
590590
}
591591
}
592592
}
593-
593+
594594
// Apply imparted multiple value settings for all platforms
595595
for (platform, multipleValues) in impartedMultipleValueSettings {
596596
for (setting, values) in multipleValues {
@@ -621,7 +621,7 @@ extension PackageGraph.ResolvedModule {
621621
let values: [String]
622622
let singleValueSetting: ProjectModel.BuildSettings.SingleValueSetting?
623623
let multipleValueSetting: ProjectModel.BuildSettings.MultipleValueSetting?
624-
624+
625625
switch declaration {
626626
case .LINK_FRAMEWORKS:
627627
singleValueSetting = nil
@@ -1032,6 +1032,12 @@ extension ProjectModel.BuildSettings {
10321032
self[.PRODUCT_BUNDLE_IDENTIFIER] = "\(packageIdentity).\(productName)".spm_mangledToBundleIdentifier()
10331033
self[.SWIFT_PACKAGE_NAME] = packageName ?? nil
10341034

1035+
// This should really be swift-build defaults set in the .xcspec files, but changing that requires
1036+
// some extensive testing to ensure xcode projects are not effected.
1037+
// So for now lets just force it here.
1038+
self[.EXECUTABLE_PREFIX] = "lib"
1039+
self[.EXECUTABLE_PREFIX, Platform.windows] = ""
1040+
10351041
if !createDylibForDynamicProducts {
10361042
self[.GENERATE_INFOPLIST_FILE] = "YES"
10371043
// If the built framework is named same as one of the target in the package,
@@ -1106,7 +1112,7 @@ extension ObservabilityScope {
11061112

11071113
let indentation = String(repeating: " ", count: Int(indent))
11081114
let message = "PIF: \(indentation)\(message)"
1109-
1115+
11101116
let diagnostic = Diagnostic(severity: severity, message: message, metadata: metadata)
11111117
self.emit(diagnostic)
11121118
}
@@ -1133,7 +1139,7 @@ public struct SourceLocation: Sendable {
11331139

11341140
public init(_ file: StaticString, _ line: UInt) {
11351141
precondition(file.description.hasContent)
1136-
1142+
11371143
self.file = file
11381144
self.line = line
11391145
}

Tests/PackageLoadingTests/PackageBuilderTests.swift

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,7 +1077,7 @@ struct PackageBuilderTests {
10771077
try TargetDescription(name: "Random"),
10781078
]
10791079
)
1080-
1080+
10811081
try PackageBuilderTester(manifest, in: fs) { package, diagnostics in
10821082
try package.checkModule("Random") { result in
10831083
#expect("/\(predefinedSourceDir)" == result.target.path)
@@ -1177,7 +1177,7 @@ struct PackageBuilderTests {
11771177
try TargetDescription(name: "MyTests", type: .test),
11781178
]
11791179
)
1180-
1180+
11811181
try PackageBuilderTester(manifest, in: fs) { package, diagnostics in
11821182
try package.checkModule("MyTests") { result in
11831183
#expect("/\(predefinedSourceDir)" == result.target.path)
@@ -1280,7 +1280,7 @@ struct PackageBuilderTests {
12801280
try TargetDescription(name: "MyPlugin", type: .plugin, pluginCapability: .buildTool),
12811281
]
12821282
)
1283-
1283+
12841284
try PackageBuilderTester(manifest, in: fs) { package, diagnostics in
12851285
try package.checkModule("MyPlugin") { result in
12861286
result.checkSources(root: result.target.path.appending(component: predefinedSourceDir).pathString, paths: "Foo.swift")
@@ -2838,19 +2838,19 @@ struct PackageBuilderTests {
28382838
// invalid - same target in package "Bar"
28392839
"Bar",
28402840
"Bar",
2841-
2841+
28422842
// invalid - same target in package "Bar"
28432843
"Bar2",
28442844
.product(name: "Bar2", package: "Bar"),
2845-
2845+
28462846
// invalid - same target in this package
28472847
"Foo2",
28482848
"Foo2",
2849-
2849+
28502850
// invalid - same target in this package
28512851
"Foo3",
28522852
.target(name: "Foo3"),
2853-
2853+
28542854
// valid - different packages
28552855
"Qux",
28562856
.product(name: "Qux", package: "Bar")
@@ -2979,7 +2979,7 @@ struct PackageBuilderTests {
29792979
func testXcodeResources5_4AndEarlier() throws {
29802980
// In SwiftTools 5.4 and earlier, supported xcbuild file types are supported by default.
29812981
// Of course, modern file types such as xcstrings won't be supported here because those require a newer Swift tools version in general.
2982-
2982+
29832983
let root: AbsolutePath = "/Foo"
29842984
let foo = root.appending(components: "Sources", "Foo")
29852985

@@ -3011,11 +3011,11 @@ struct PackageBuilderTests {
30113011
}
30123012
}
30133013
}
3014-
3014+
30153015
@Test
30163016
func testXcodeResources5_5AndLater() throws {
30173017
// In SwiftTools 5.5 and later, xcbuild file types are only supported when explicitly passed via additionalFileRules.
3018-
3018+
30193019
let root: AbsolutePath = "/Foo"
30203020
let foo = root.appending(components: "Sources", "Foo")
30213021

@@ -3140,7 +3140,7 @@ struct PackageBuilderTests {
31403140
internalSourcesDir.appending("Internal.swift").pathString,
31413141
productSourcesDir.appending("Product.swift").pathString,
31423142
snippetsDir.appending("ASnippet.swift").pathString)
3143-
3143+
31443144
let manifest = Manifest.createRootManifest(
31453145
displayName: "Foo", toolsVersion: .v5_7,
31463146
products: [
@@ -3150,7 +3150,7 @@ struct PackageBuilderTests {
31503150
try TargetDescription(name: "Internal"),
31513151
try TargetDescription(name: "Product"),
31523152
])
3153-
3153+
31543154
try PackageBuilderTester(manifest, path: root, in: fs) { result, diagnostics in
31553155
result.checkProduct("Product") { product in
31563156
product.check(type: .library(.automatic), targets: ["Product"])
@@ -3315,7 +3315,7 @@ struct PackageBuilderTests {
33153315
}
33163316
}
33173317
}
3318-
3318+
33193319
@Test
33203320
func testCWarningControlFlags() throws {
33213321
let fs = InMemoryFileSystem(emptyFiles:

0 commit comments

Comments
 (0)