From 1e60a78cc443936513f2793b8de5ed3580a48a32 Mon Sep 17 00:00:00 2001 From: Paul Schmiedmayer Date: Fri, 28 Jun 2024 15:20:45 -0700 Subject: [PATCH] Update Setup --- .github/workflows/build-and-test.yml | 74 ++++++++++--------- Tests/UITests/TestApp/OperatingSystem.swift | 20 +++++ Tests/UITests/TestApp/TestApp.swift | 1 + .../TestAppUITests/TestAppUITests.swift | 14 ++++ .../UITests/UITests.xcodeproj/project.pbxproj | 6 ++ 5 files changed, 79 insertions(+), 36 deletions(-) create mode 100644 Tests/UITests/TestApp/OperatingSystem.swift diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 650e890..3cb773c 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -57,50 +57,52 @@ jobs: # resultBundle: TemplatePackage-macOS.xcresult # destination: 'platform=macOS,arch=arm64' # artifactname: TemplatePackage-macOS.xcresult - # ios: - # name: Build and Test iOS - # uses: StanfordBDHG/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2 - # with: - # path: 'Tests/UITests' - # scheme: TestApp - # resultBundle: TestApp-iOS.xcresult - # artifactname: TestApp-iOS.xcresult - # ipados: - # name: Build and Test iPadOS - # uses: StanfordBDHG/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2 - # with: - # path: 'Tests/UITests' - # scheme: TestApp - # destination: 'platform=iOS Simulator,name=iPad Air (5th generation)' - # resultBundle: TestApp-iPadOS.xcresult - # artifactname: TestApp-iPadOS.xcresult + ios: + name: Build and Test iOS + uses: StanfordBDHG/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2 + with: + path: 'Tests/UITests' + scheme: TestApp + resultBundle: TestApp-iOS.xcresult + artifactname: TestApp-iOS.xcresult + ipados: + name: Build and Test iPadOS + uses: StanfordBDHG/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2 + with: + path: 'Tests/UITests' + scheme: TestApp + destination: 'platform=iOS Simulator,name=iPad Air (5th generation)' + resultBundle: TestApp-iPadOS.xcresult + artifactname: TestApp-iPadOS.xcresult watchos: name: Build and Test watchOS uses: StanfordBDHG/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2 with: + runsonlabels: '["macOS", "self-hosted"]' path: 'Tests/UITests' scheme: TestAppWatchApp - destination: 'id=3C5F6AF7-5AB7-4FA4-9684-305E2533D6EA' + destination: 'platform=watchOS Simulator,name=Apple Watch Series 9 (45mm)' resultBundle: TestApp-watchOS.xcresult artifactname: TestApp-watchOS.xcresult - # visionos: - # name: Build and Test visionOS - # uses: StanfordBDHG/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2 - # with: - # path: 'Tests/UITests' - # scheme: TestApp - # destination: 'platform=visionOS Simulator,name=Apple Vision Pro' - # resultBundle: TestApp-visionOS.xcresult - # artifactname: TestApp-visionOS.xcresult - # tvos: - # name: Build and Test tvOS - # uses: StanfordBDHG/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2 - # with: - # path: 'Tests/UITests' - # scheme: TestApp - # destination: 'platform=tvOS Simulator,name=Apple TV 4K (3rd generation)' - # resultBundle: TestApp-tvOS.xcresult - # artifactname: TestApp-tvOS.xcresult + visionos: + name: Build and Test visionOS + uses: StanfordBDHG/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2 + with: + runsonlabels: '["macOS", "self-hosted"]' + path: 'Tests/UITests' + scheme: TestApp + destination: 'platform=visionOS Simulator,name=Apple Vision Pro' + resultBundle: TestApp-visionOS.xcresult + artifactname: TestApp-visionOS.xcresult + tvos: + name: Build and Test tvOS + uses: StanfordBDHG/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2 + with: + path: 'Tests/UITests' + scheme: TestApp + destination: 'platform=tvOS Simulator,name=Apple TV 4K (3rd generation)' + resultBundle: TestApp-tvOS.xcresult + artifactname: TestApp-tvOS.xcresult # codeql: # name: CodeQL # uses: StanfordBDHG/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2 diff --git a/Tests/UITests/TestApp/OperatingSystem.swift b/Tests/UITests/TestApp/OperatingSystem.swift new file mode 100644 index 0000000..201ed6e --- /dev/null +++ b/Tests/UITests/TestApp/OperatingSystem.swift @@ -0,0 +1,20 @@ +// +// This source file is part of the TemplatePackage open-source project +// +// SPDX-FileCopyrightText: 2022 Stanford University and the project authors (see CONTRIBUTORS.md) +// +// SPDX-License-Identifier: MIT +// + + +#if os(macOS) +let operatingSystem = "macOS" +#elseif os(iOS) +let operatingSystem = "iOS" +#elseif os(watchOS) +let operatingSystem = "watchOS" +#elseif os(visionOS) +let operatingSystem = "visionOS" +#elseif os(tvOS) +let operatingSystem = "tvOS" +#endif diff --git a/Tests/UITests/TestApp/TestApp.swift b/Tests/UITests/TestApp/TestApp.swift index 90fdb20..4ddb27e 100644 --- a/Tests/UITests/TestApp/TestApp.swift +++ b/Tests/UITests/TestApp/TestApp.swift @@ -15,6 +15,7 @@ struct UITestsApp: App { var body: some Scene { WindowGroup { Text(TemplatePackage().stanford) + Text(operatingSystem) } } } diff --git a/Tests/UITests/TestAppUITests/TestAppUITests.swift b/Tests/UITests/TestAppUITests/TestAppUITests.swift index d422843..39d2a15 100644 --- a/Tests/UITests/TestAppUITests/TestAppUITests.swift +++ b/Tests/UITests/TestAppUITests/TestAppUITests.swift @@ -21,5 +21,19 @@ class TestAppUITests: XCTestCase { let app = XCUIApplication() app.launch() XCTAssert(app.staticTexts["Stanford University"].waitForExistence(timeout: 0.1)) + + if app.staticTexts["macOS"].exists { + print("Template Package is running on macOS.") + } else if app.staticTexts["iOS"].exists { + print("Template Package is running on iOS.") + } else if app.staticTexts["watchOS"].exists { + print("Template Package is running on watchOS.") + } else if app.staticTexts["visionOS"].exists { + print("Template Package is running on visionOS.") + } else if app.staticTexts["tvOS"].exists { + print("Template Package is running on tvOS.") + } else { + XCTFail("Running on an unexpected operating system.") + } } } diff --git a/Tests/UITests/UITests.xcodeproj/project.pbxproj b/Tests/UITests/UITests.xcodeproj/project.pbxproj index 25c3d4a..5f691f9 100644 --- a/Tests/UITests/UITests.xcodeproj/project.pbxproj +++ b/Tests/UITests/UITests.xcodeproj/project.pbxproj @@ -16,6 +16,8 @@ 2F9CBEDA2A76C795009818FF /* TemplatePackage in Frameworks */ = {isa = PBXBuildFile; productRef = 2F9CBED92A76C795009818FF /* TemplatePackage */; }; 2F9CBEDB2A76C7EC009818FF /* TestAppUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2F8A431229130A8C005D2B8F /* TestAppUITests.swift */; }; 2FA7382C290ADFAA007ACEB9 /* TestApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2FA7382B290ADFAA007ACEB9 /* TestApp.swift */; }; + 2FB5B6E02C2F6C50009162E6 /* OperatingSystem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2FB5B6DF2C2F6C50009162E6 /* OperatingSystem.swift */; }; + 2FB5B6E12C2F6DBC009162E6 /* OperatingSystem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2FB5B6DF2C2F6C50009162E6 /* OperatingSystem.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -73,6 +75,7 @@ 2F9CBEBF2A76C412009818FF /* TestAppWatchAppUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = TestAppWatchAppUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 2FA7382B290ADFAA007ACEB9 /* TestApp.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestApp.swift; sourceTree = ""; }; 2FB0758A299DDB9000C0B37F /* TestApp.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; path = TestApp.xctestplan; sourceTree = ""; }; + 2FB5B6DF2C2F6C50009162E6 /* OperatingSystem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OperatingSystem.swift; sourceTree = ""; }; 2FF8922E2A770D4200903A5A /* TestAppWatchApp.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; path = TestAppWatchApp.xctestplan; sourceTree = ""; }; /* End PBXFileReference section */ @@ -138,6 +141,7 @@ isa = PBXGroup; children = ( 2FA7382B290ADFAA007ACEB9 /* TestApp.swift */, + 2FB5B6DF2C2F6C50009162E6 /* OperatingSystem.swift */, 2F6D139928F5F386007C25D6 /* Assets.xcassets */, ); path = TestApp; @@ -326,6 +330,7 @@ buildActionMask = 2147483647; files = ( 2FA7382C290ADFAA007ACEB9 /* TestApp.swift in Sources */, + 2FB5B6E02C2F6C50009162E6 /* OperatingSystem.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -341,6 +346,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 2FB5B6E12C2F6DBC009162E6 /* OperatingSystem.swift in Sources */, 2F9CBED72A76C752009818FF /* TestApp.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0;