From 9c3a8c948fcad2f01696835ae50ba4c598f1fde5 Mon Sep 17 00:00:00 2001 From: Jakub Olejnik Date: Thu, 9 Nov 2023 15:48:26 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=B7=20Add=20CI=20job?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 24 ++++++++-- .github/workflows/pr.yml | 9 ++++ .github/workflows/tests.yml | 47 +++++++++++++++---- Package.swift | 4 +- Tests/ACKategoriesTests/ColorTests.swift | 3 ++ .../Extensions/UIWindow.swift | 9 +--- .../PropertyWrappers/UserDefaultTests.swift | 2 +- .../ACKategoriesTests/ReusableViewTests.swift | 2 + .../ACKategoriesTests/UIStackViewTests.swift | 11 ++--- .../UIViewControllerChildrenTests.swift | 10 +--- Tests/ACKategoriesTests/UIViewTests.swift | 10 +--- 11 files changed, 87 insertions(+), 44 deletions(-) create mode 100644 .github/workflows/pr.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cd68efc6..025aa858 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,7 +1,6 @@ -# https://help.github.com/en/github/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#jobsjob_idname name: Build -on: [pull_request, push, workflow_dispatch] +on: [workflow_call] jobs: carthage: @@ -12,4 +11,23 @@ jobs: - uses: AckeeCZ/load-xcode-version@1.1.0 - name: Build run: carthage build --no-skip-current --cache-builds --use-xcframeworks - \ No newline at end of file + - uses: actions/cache@v3 + with: + path: Carthage + key: ${{ runner.os }}-carthage-${{ hashFiles('**/Cartfile.resolved') }} + restore-keys: | + ${{ runner.os }}-carthage- + spm: + name: SPM + runs-on: macos-13 + steps: + - uses: actions/checkout@v4 + - uses: AckeeCZ/load-xcode-version@1.1.0 + - name: Build + run: swift build -c release + - uses: actions/cache@v3 + with: + path: .build + key: ${{ runner.os }}-spm-${{ hashFiles('**/Package.resolved') }} + restore-keys: | + ${{ runner.os }}-spm- \ No newline at end of file diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml new file mode 100644 index 00000000..2041e407 --- /dev/null +++ b/.github/workflows/pr.yml @@ -0,0 +1,9 @@ +name: PR + +on: [pull_request] + +jobs: + tests: + uses: ./.github/workflows/tests.yml + + \ No newline at end of file diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a69e5b5f..55722fef 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,25 +1,56 @@ name: Tests -on: [pull_request, push] +on: [workflow_call] jobs: - tests: - name: Run tests + xcodebuild: + name: Xcodebuild runs-on: macos-13 + env: + IOS_DEVICE: iPhone 15 Pro Max steps: - uses: actions/checkout@v4 - uses: AckeeCZ/load-xcode-version@1.1.0 - - name: Run iOS tests - run: set -o pipefail && xcodebuild test -scheme ACKategories-iOS -resultBundlePath Tests-iOS.xcresult -sdk iphonesimulator -destination "platform=iOS Simulator,name=iPhone 15 Pro Max,OS=latest" ONLY_ACTIVE_ARCH=YES | xcpretty + - name: iOS tests + run: set -o pipefail && xcodebuild test -scheme ACKategories -resultBundlePath Tests-iOS.xcresult -sdk iphonesimulator -destination "platform=iOS Simulator,name=$IOS_DEVICE,OS=latest" ONLY_ACTIVE_ARCH=YES | xcpretty - uses: actions/upload-artifact@v3 if: failure() with: name: Tests-iOS.xcresult path: Tests-iOS.xcresult - - name: Run macOS tests - run: set -o pipefail && xcodebuild test -scheme ACKategoriesCore -resultBundlePath Tests-macOS.xcresult -destination 'platform=OS X,arch=x86_64' | xcpretty + - name: iOS responder tests + run: set -o pipefail && xcodebuild test -scheme ACKategories -resultBundlePath Tests-iOS-Responder.xcresult -sdk iphonesimulator -destination "platform=iOS Simulator,name=$IOS_DEVICE,OS=latest" ONLY_ACTIVE_ARCH=YES | xcpretty + - uses: actions/upload-artifact@v3 + if: failure() + with: + name: Tests-iOS-Responder.xcresult + path: Tests-iOS-Responder.xcresult + - name: macOS tests + run: set -o pipefail && xcodebuild test -scheme ACKategories -resultBundlePath Tests-macOS.xcresult -destination 'platform=OS X,arch=x86_64' | xcpretty - uses: actions/upload-artifact@v3 if: failure() with: name: Tests-macOS.xcresult - path: Tests-macOS.xcresult \ No newline at end of file + path: Tests-macOS.xcresult + - name: watchOS tests + run: set -o pipefail && xcodebuild test -scheme ACKategories -resultBundlePath Tests-watchOS.xcresult -sdk watchsimulator -destination "platform=watchOS Simulator,name=Apple Watch Ultra 2 (49mm),OS=latest" ONLY_ACTIVE_ARCH=YES | xcpretty + - uses: actions/upload-artifact@v3 + if: failure() + with: + name: Tests-watchOS.xcresult + path: Tests-watchOS.xcresult + - name: tvOS tests + run: set -o pipefail && xcodebuild test -scheme ACKategories -resultBundlePath Tests-tvOS.xcresult -sdk appletvsimulator -destination "platform=tvOS Simulator,name=Apple TV 4K (3rd generation),OS=latest" ONLY_ACTIVE_ARCH=YES | xcpretty + - uses: actions/upload-artifact@v3 + if: failure() + with: + name: Tests-tvOS.xcresult + path: Tests-tvOS.xcresult + spm: + name: SPM + runs-on: macos-13 + steps: + - uses: actions/checkout@v4 + - uses: AckeeCZ/load-xcode-version@1.1.0 + - name: SPM tests + run: swift test \ No newline at end of file diff --git a/Package.swift b/Package.swift index 655dbf45..bd15de2e 100644 --- a/Package.swift +++ b/Package.swift @@ -5,7 +5,9 @@ let package = Package( name: "ACKategories", platforms: [ .iOS(.v12), - .macOS(.v10_13) + .macOS(.v10_13), + .watchOS(.v5), + .tvOS(.v12), ], products: [ .library(name: "ACKategories", targets: ["ACKategories"]), diff --git a/Tests/ACKategoriesTests/ColorTests.swift b/Tests/ACKategoriesTests/ColorTests.swift index 75f5c2c5..09f794aa 100644 --- a/Tests/ACKategoriesTests/ColorTests.swift +++ b/Tests/ACKategoriesTests/ColorTests.swift @@ -1,5 +1,7 @@ +#if canImport(UIKit) import XCTest import ACKategories +import UIKit final class ColorTests: XCTestCase { @@ -71,3 +73,4 @@ final class ColorTests: XCTestCase { XCTAssertTrue(color.isDark) } } +#endif diff --git a/Tests/ACKategoriesTests/Extensions/UIWindow.swift b/Tests/ACKategoriesTests/Extensions/UIWindow.swift index a0419e4a..486ed905 100644 --- a/Tests/ACKategoriesTests/Extensions/UIWindow.swift +++ b/Tests/ACKategoriesTests/Extensions/UIWindow.swift @@ -1,10 +1,4 @@ -// -// UIWindow.swift -// ACKategories-iOSTests -// -// Created by Lukáš Hromadník on 23.11.2020. -// - +#if canImport(UIKit) import UIKit extension UIWindow { @@ -12,3 +6,4 @@ extension UIWindow { UIWindow(frame: UIScreen.main.bounds) } } +#endif diff --git a/Tests/ACKategoriesTests/PropertyWrappers/UserDefaultTests.swift b/Tests/ACKategoriesTests/PropertyWrappers/UserDefaultTests.swift index 972ae1b2..bb4fd96b 100644 --- a/Tests/ACKategoriesTests/PropertyWrappers/UserDefaultTests.swift +++ b/Tests/ACKategoriesTests/PropertyWrappers/UserDefaultTests.swift @@ -3,7 +3,7 @@ import Foundation import XCTest import ACKategories -@available(iOS 13.0, *) +@available(iOS 13.0, macOS 10.15, *) final class UserDefaultTests: XCTestCase { private var subject: MyUserDefaultProvider! private var userDefaults: UserDefaults! diff --git a/Tests/ACKategoriesTests/ReusableViewTests.swift b/Tests/ACKategoriesTests/ReusableViewTests.swift index 817f9afa..f9bb0739 100644 --- a/Tests/ACKategoriesTests/ReusableViewTests.swift +++ b/Tests/ACKategoriesTests/ReusableViewTests.swift @@ -1,3 +1,4 @@ +#if canImport(UIKit) import ACKategories import UIKit import XCTest @@ -36,3 +37,4 @@ final class ReusableViewTests: XCTestCase { XCTAssertFalse(prototype === CustomView()) } } +#endif diff --git a/Tests/ACKategoriesTests/UIStackViewTests.swift b/Tests/ACKategoriesTests/UIStackViewTests.swift index 1047dca0..701d3067 100644 --- a/Tests/ACKategoriesTests/UIStackViewTests.swift +++ b/Tests/ACKategoriesTests/UIStackViewTests.swift @@ -1,13 +1,7 @@ -// -// UIStackViewTests.swift -// ACKategories -// -// Created by Jakub Olejník on 13/06/2018. -// Copyright © 2018 Ackee, s.r.o. All rights reserved. -// - +#if canImport(UIKit) import XCTest import ACKategories +import UIKit final class UIStackViewTests: XCTestCase { @@ -26,3 +20,4 @@ final class UIStackViewTests: XCTestCase { } } +#endif diff --git a/Tests/ACKategoriesTests/UIViewControllerChildrenTests.swift b/Tests/ACKategoriesTests/UIViewControllerChildrenTests.swift index 316dc2c8..f9c1f971 100644 --- a/Tests/ACKategoriesTests/UIViewControllerChildrenTests.swift +++ b/Tests/ACKategoriesTests/UIViewControllerChildrenTests.swift @@ -1,11 +1,4 @@ -// -// UIViewControllerChildrenTests.swift -// ACKategories -// -// Created by Jakub Olejník on 13/04/2018. -// Copyright © 2018 Josef Dolezal. All rights reserved. -// - +#if canImport(UIKit) import UIKit import XCTest import ACKategories @@ -72,3 +65,4 @@ final class UIViewControllerChildrenTests: XCTestCase { XCTAssertEqual(childVC.parent, parentVC) } } +#endif diff --git a/Tests/ACKategoriesTests/UIViewTests.swift b/Tests/ACKategoriesTests/UIViewTests.swift index 65407934..3806bcf6 100644 --- a/Tests/ACKategoriesTests/UIViewTests.swift +++ b/Tests/ACKategoriesTests/UIViewTests.swift @@ -1,11 +1,4 @@ -// -// UIViewTests.swift -// UnitTests -// -// Created by Jakub Olejník on 14/06/2019. -// Copyright © 2019 Ackee, s.r.o. All rights reserved. -// - +#if canImport(UIKit) import UIKit import XCTest import ACKategories @@ -82,3 +75,4 @@ final class UIViewTests: XCTestCase { XCTAssertNil(weakSpacer) } } +#endif