diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1b2bb5d9..937d4e73 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,34 +8,17 @@ on: jobs: spm-15: - name: Build Xcode 15 + name: Swift Build Xcode 15 runs-on: macos-13 - strategy: - matrix: - platforms: [ - 'iOS_17,watchOS_10', - 'macOS_14,tvOS_17', - ] - fail-fast: false steps: - name: Checkout Repo uses: actions/checkout@v3 - name: Select Xcode Version run: sudo xcode-select --switch /Applications/Xcode_15.0.1.app/Contents/Developer - name: Build and Test Framework - run: Scripts/build.swift ${{ matrix.platforms }} + run: xcrun swift test -c release --enable-code-coverage -Xswiftc -enable-testing - name: Prepare Coverage Reports run: ./Scripts/prepare-coverage-reports.sh - name: Upload Coverage Reports if: success() uses: codecov/codecov-action@v3 - spm-15-swift: - name: Swift Build Xcode 15 - runs-on: macos-13 - steps: - - name: Checkout Repo - uses: actions/checkout@v3 - - name: Select Xcode Version - run: sudo xcode-select --switch /Applications/Xcode_15.0.1.app/Contents/Developer - - name: Build and Test Framework - run: xcrun swift test -c release -Xswiftc -enable-testing diff --git a/Scripts/build.swift b/Scripts/build.swift deleted file mode 100755 index 76a130d3..00000000 --- a/Scripts/build.swift +++ /dev/null @@ -1,199 +0,0 @@ -#!/usr/bin/env swift - -import Foundation - -// Usage: build.swift platforms - -func execute(commandPath: String, arguments: [String]) throws { - let task = Process() - task.launchPath = commandPath - task.arguments = arguments - print("Launching command: \(commandPath) \(arguments.joined(separator: " "))") - task.launch() - task.waitUntilExit() - guard task.terminationStatus == 0 else { - throw TaskError.code(task.terminationStatus) - } -} - -enum TaskError: Error { - case code(Int32) -} - -enum Platform: String, CaseIterable, CustomStringConvertible { - case iOS_13 - case iOS_14 - case iOS_15 - case iOS_16 - case iOS_17 - case tvOS_13 - case tvOS_14 - case tvOS_15 - case tvOS_16 - case tvOS_17 - case macOS_10_15 - case macOS_11 - case macOS_12 - case macOS_13 - case macOS_14 - case watchOS_6 - case watchOS_7 - case watchOS_8 - case watchOS_9 - case watchOS_10 - - var destination: String { - switch self { - case .iOS_13: - return "platform=iOS Simulator,OS=13.7,name=iPad Pro (12.9-inch) (4th generation)" - case .iOS_14: - return "platform=iOS Simulator,OS=14.4,name=iPad Pro (12.9-inch) (4th generation)" - case .iOS_15: - return "platform=iOS Simulator,OS=15.5,name=iPad Pro (12.9-inch) (5th generation)" - case .iOS_16: - return "platform=iOS Simulator,OS=16.4,name=iPad Pro (12.9-inch) (6th generation)" - case .iOS_17: - return "platform=iOS Simulator,OS=17.0.1,name=iPad Pro (12.9-inch) (6th generation)" - - case .tvOS_13: - return "platform=tvOS Simulator,OS=13.4,name=Apple TV" - case .tvOS_14: - return "platform=tvOS Simulator,OS=14.3,name=Apple TV" - case .tvOS_15: - return "platform=tvOS Simulator,OS=15.4,name=Apple TV" - case .tvOS_16: - return "platform=tvOS Simulator,OS=16.4,name=Apple TV" - case .tvOS_17: - return "platform=tvOS Simulator,OS=17.0,name=Apple TV" - - case .macOS_10_15, - .macOS_11, - .macOS_12, - .macOS_13, - .macOS_14: - return "platform=OS X" - - case .watchOS_6: - return "OS=6.2.1,name=Apple Watch Series 4 - 44mm" - case .watchOS_7: - return "OS=7.2,name=Apple Watch Series 6 - 44mm" - case .watchOS_8: - return "OS=8.5,name=Apple Watch Series 6 - 44mm" - case .watchOS_9: - return "OS=9.4,name=Apple Watch Series 7 (45mm)" - case .watchOS_10: - return "OS=10.0,name=Apple Watch Series 7 (45mm)" - } - } - - var sdk: String { - switch self { - case .iOS_13, - .iOS_14, - .iOS_15, - .iOS_16, - .iOS_17: - return "iphonesimulator" - - case .tvOS_13, - .tvOS_14, - .tvOS_15, - .tvOS_16, - .tvOS_17: - return "appletvsimulator" - - case .macOS_10_15: - return "macosx10.15" - case .macOS_11: - return "macosx11.1" - case .macOS_12: - return "macosx12.3" - case .macOS_13: - return "macosx13.3" - case .macOS_14: - return "macosx14.0" - - case .watchOS_6, - .watchOS_7, - .watchOS_8, - .watchOS_9, - .watchOS_10: - return "watchsimulator" - } - } - - var shouldTest: Bool { - switch self { - case .iOS_13, - .iOS_14, - .iOS_15, - .iOS_16, - .iOS_17, - .tvOS_13, - .tvOS_14, - .tvOS_15, - .tvOS_16, - .tvOS_17, - .macOS_10_15, - .macOS_11, - .macOS_12, - .macOS_13, - .macOS_14: - return true - - case .watchOS_6, - .watchOS_7, - .watchOS_8, - .watchOS_9, - .watchOS_10: - // watchOS does not support unit testing (yet?). - return false - } - } - - var derivedDataPath: String { - ".build/derivedData/" + description - } - - var description: String { - rawValue - } -} - -guard CommandLine.arguments.count > 1 else { - print("Usage: build.swift platforms") - throw TaskError.code(1) -} - -let rawPlatforms = CommandLine.arguments[1].components(separatedBy: ",") - -for rawPlatform in rawPlatforms { - guard let platform = Platform(rawValue: rawPlatform) else { - print("Received unknown platform type \(rawPlatform)") - print("Possible platform types are: \(Platform.allCases)") - throw TaskError.code(1) - } - - var xcodeBuildArguments = [ - "-scheme", "SafeDI", - "-sdk", platform.sdk, - "-derivedDataPath", platform.derivedDataPath, - "-PBXBuildsContinueAfterErrors=0", - "OTHER_SWIFT_FLAGS=-warnings-as-errors -D CI", - ] - - if !platform.destination.isEmpty { - xcodeBuildArguments.append("-destination") - xcodeBuildArguments.append(platform.destination) - } - if platform.shouldTest { - xcodeBuildArguments.append("-enableCodeCoverage") - xcodeBuildArguments.append("YES") - } - xcodeBuildArguments.append("build") - if platform.shouldTest { - xcodeBuildArguments.append("test") - } - - try execute(commandPath: "/usr/bin/xcodebuild", arguments: xcodeBuildArguments) -} diff --git a/Scripts/prepare-coverage-reports.sh b/Scripts/prepare-coverage-reports.sh index ef0d2b90..79967f88 100755 --- a/Scripts/prepare-coverage-reports.sh +++ b/Scripts/prepare-coverage-reports.sh @@ -2,17 +2,14 @@ set -e function exportlcov() { - build_type=$1 - executable_name=$2 + executable_name=$1 - executable=$(find "${directory}" -type f -name $executable_name) - profile=$(find "${directory}" -type f -name 'Coverage.profdata') + executable=$(find .build/*/*/$executable_name.xctest/Contents/*/$executable_name -type f) + profile=$(find .build -type f -name 'default.profdata') output_file_name="$executable_name.lcov" can_proceed=true - if [[ $build_type == watchOS* ]]; then - echo "\tAborting creation of $output_file_name – watchOS not supported." - elif [[ -z $profile ]]; then + if [[ -z $profile ]]; then echo "\tAborting creation of $output_file_name – no profile found." elif [[ -z $executable ]]; then echo "\tAborting creation of $output_file_name – no executable found." @@ -26,9 +23,4 @@ function exportlcov() { fi } -for directory in $(git rev-parse --show-toplevel)/.build/derivedData/*/; do - build_type=$(basename $directory) - echo "Finding coverage information for $build_type" - - exportlcov $build_type 'SafeDITests' -done +exportlcov 'SafeDIPackageTests' diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 00000000..f2d54bc6 --- /dev/null +++ b/codecov.yml @@ -0,0 +1,14 @@ +codecov: + require_ci_to_pass: yes + +comment: + layout: "reach,diff,flags,tree" + behavior: default + require_changes: no + +coverage: + status: + project: + default: + target: 60% + patch: off