diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index a62aa6d..09c9019 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -9,13 +9,15 @@ name: Build and Test on: - push: - branches: - - main - pull_request: - workflow_dispatch: + workflow_call: jobs: + reuse_action: + name: REUSE Compliance Check + uses: StanfordBDHG/.github/.github/workflows/reuse.yml@v2 + swiftlint: + name: SwiftLint + uses: StanfordBDHG/.github/.github/workflows/swiftlint.yml@v2 packageios: name: Build and Test Swift Package iOS uses: StanfordBDHG/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2 @@ -59,7 +61,6 @@ jobs: name: Build and Test iOS uses: StanfordBDHG/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2 with: - runsonlabels: '["macOS", "self-hosted"]' path: 'Tests/UITests' scheme: TestApp resultBundle: TestApp-iOS.xcresult @@ -68,7 +69,6 @@ jobs: name: Build and Test iPadOS uses: StanfordBDHG/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2 with: - runsonlabels: '["macOS", "self-hosted"]' path: 'Tests/UITests' scheme: TestApp destination: 'platform=iOS Simulator,name=iPad Air (5th generation)' @@ -98,7 +98,6 @@ jobs: name: Build and Test tvOS uses: StanfordBDHG/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2 with: - runsonlabels: '["macOS", "self-hosted"]' path: 'Tests/UITests' scheme: TestApp destination: 'platform=tvOS Simulator,name=Apple TV 4K (3rd generation)' diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..c64e9ff --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,25 @@ +# +# 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 +# + +name: Main + +on: + push: + branches: + - main + workflow_dispatch: + +concurrency: + group: main + cancel-in-progress: false + +jobs: + buildandtest: + name: Build and Test + uses: ./.github/workflows/build-and-test.yml + secrets: inherit diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 45ed630..272edeb 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -12,10 +12,12 @@ on: pull_request: workflow_dispatch: +concurrency: + group: build-${{ github.ref }} + cancel-in-progress: true + jobs: - reuse_action: - name: REUSE Compliance Check - uses: StanfordBDHG/.github/.github/workflows/reuse.yml@v2 - swiftlint: - name: SwiftLint - uses: StanfordBDHG/.github/.github/workflows/swiftlint.yml@v2 + buildandtest: + name: Build and Test + uses: ./.github/workflows/build-and-test.yml + secrets: inherit 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..82a97bb 100644 --- a/Tests/UITests/TestAppUITests/TestAppUITests.swift +++ b/Tests/UITests/TestAppUITests/TestAppUITests.swift @@ -6,6 +6,7 @@ // SPDX-License-Identifier: MIT // +import OSLog import XCTest @@ -20,6 +21,8 @@ class TestAppUITests: XCTestCase { func testTemplatePackage() throws { let app = XCUIApplication() app.launch() + XCTAssert(app.staticTexts["Stanford University"].waitForExistence(timeout: 0.1)) + XCTAssert(app.staticTexts[operatingSystem].exists) } } diff --git a/Tests/UITests/UITests.xcodeproj/project.pbxproj b/Tests/UITests/UITests.xcodeproj/project.pbxproj index 25c3d4a..e880b01 100644 --- a/Tests/UITests/UITests.xcodeproj/project.pbxproj +++ b/Tests/UITests/UITests.xcodeproj/project.pbxproj @@ -16,6 +16,10 @@ 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 */; }; + 2FB5B6E22C2F707A009162E6 /* OperatingSystem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2FB5B6DF2C2F6C50009162E6 /* OperatingSystem.swift */; }; + 2FB5B6E32C2F707B009162E6 /* OperatingSystem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2FB5B6DF2C2F6C50009162E6 /* OperatingSystem.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -73,6 +77,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 +143,7 @@ isa = PBXGroup; children = ( 2FA7382B290ADFAA007ACEB9 /* TestApp.swift */, + 2FB5B6DF2C2F6C50009162E6 /* OperatingSystem.swift */, 2F6D139928F5F386007C25D6 /* Assets.xcassets */, ); path = TestApp; @@ -326,6 +332,7 @@ buildActionMask = 2147483647; files = ( 2FA7382C290ADFAA007ACEB9 /* TestApp.swift in Sources */, + 2FB5B6E02C2F6C50009162E6 /* OperatingSystem.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -333,6 +340,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 2FB5B6E22C2F707A009162E6 /* OperatingSystem.swift in Sources */, 2F8A431329130A8C005D2B8F /* TestAppUITests.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -341,6 +349,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 2FB5B6E12C2F6DBC009162E6 /* OperatingSystem.swift in Sources */, 2F9CBED72A76C752009818FF /* TestApp.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -349,6 +358,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 2FB5B6E32C2F707B009162E6 /* OperatingSystem.swift in Sources */, 2F9CBEDB2A76C7EC009818FF /* TestAppUITests.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0;