Skip to content

Commit 39eb0d2

Browse files
committed
Add a test package for CI
We currently have setup the workflows in this repository to test the various reusable workflows. The workflows that require a Swift package have created their own package as a pre-build command. While this worked so far it limits the kinds of packages that we can setup. This PR is committing a Swift Package to the `tests` folder which we can shape more complicated ways to test the various workflows better.
1 parent 30fccd9 commit 39eb0d2

File tree

5 files changed

+44
-29
lines changed

5 files changed

+44
-29
lines changed

.github/workflows/pull_request.yml

Lines changed: 10 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ jobs:
1717
enable_macos_checks: false
1818
enable_windows_checks: false
1919
wasm_sdk_pre_build_command: |
20-
mkdir MyPackage
21-
cd MyPackage
22-
swift package init --type library
20+
cd tests/TestPackage
2321
enable_embedded_wasm_sdk_build: true
2422

2523
tests_with_docker:
@@ -29,32 +27,22 @@ jobs:
2927
# Linux
3028
linux_os_versions: '["jammy", "rhel-ubi9", "amazonlinux2"]'
3129
linux_build_command: |
32-
mkdir MyPackage
33-
cd MyPackage
34-
swift package init --type library
30+
cd tests/TestPackage
3531
swift build
3632
linux_static_sdk_pre_build_command: |
37-
mkdir MyPackage
38-
cd MyPackage
39-
swift package init --type library
33+
cd tests/TestPackage
4034
enable_linux_static_sdk_build: true
4135
# Wasm
4236
wasm_sdk_pre_build_command: |
43-
mkdir MyPackage
44-
cd MyPackage
45-
swift package init --type library
37+
cd tests/TestPackage
4638
enable_wasm_sdk_build: true
4739
# Android
4840
android_sdk_pre_build_command: |
49-
mkdir MyPackage
50-
cd MyPackage
51-
swift package init --type library
41+
cd tests/TestPackage
5242
enable_android_sdk_build: true
5343
# Windows
5444
windows_build_command: |
55-
mkdir MyPackage
56-
cd MyPackage
57-
Invoke-Program swift package init --type library
45+
cd tests/TestPackage
5846
Invoke-Program swift build
5947
enable_windows_docker: true
6048

@@ -66,15 +54,11 @@ jobs:
6654
enable_linux_checks: false
6755
# Android
6856
android_sdk_pre_build_command: |
69-
mkdir MyPackage
70-
cd MyPackage
71-
swift package init --type library
57+
cd tests/TestPackagey
7258
enable_android_sdk_build: true
7359
# Windows
7460
windows_build_command: |
75-
mkdir MyPackage
76-
cd MyPackage
77-
Invoke-Program swift package init --type library
61+
cd tests/TestPackage
7862
Invoke-Program swift build
7963
enable_windows_docker: false
8064

@@ -87,9 +71,7 @@ jobs:
8771
# macOS
8872
enable_macos_checks: true
8973
macos_build_command: |
90-
mkdir MyPackage
91-
cd MyPackage
92-
xcrun swift package init --type library
74+
cd tests/TestPackage
9375
xcrun swift build
9476
9577
build_tests_ios:
@@ -101,8 +83,7 @@ jobs:
10183
# iOS
10284
enable_ios_checks: true
10385
ios_pre_build_command: |
104-
pwd
105-
xcrun swift package init --type library
86+
cd tests/TestPackage
10687
10788
soundness:
10889
name: Soundness

tests/TestPackage/Package.swift

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// swift-tools-version: 6.0
2+
3+
import PackageDescription
4+
5+
let package = Package(
6+
name: "TestPackage",
7+
targets: [
8+
.target(
9+
name: "Target1"
10+
),
11+
.target(
12+
name: "Target2",
13+
dependencies: [
14+
"Target1"
15+
]
16+
),
17+
.testTarget(
18+
name: "Target1Tests",
19+
dependencies: ["Target1"]
20+
),
21+
]
22+
)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
public func foo() { }
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import Target1
2+
3+
public func bar() {
4+
foo()
5+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import Testing
2+
import Target1
3+
4+
@Test func example() async throws {
5+
foo()
6+
}

0 commit comments

Comments
 (0)