From 8e95775117a865516243c57233befc2049abc009 Mon Sep 17 00:00:00 2001 From: Matias Piipari Date: Fri, 5 Nov 2021 13:12:47 +0200 Subject: [PATCH] Introduces a matrix build (#18) * Specifies the Xcode version, and build destination, accurately. * Update the iOS build target destination * Resolve the CIRAWFilterOption.ciInputEnableEDRModeKey vs. kCIInputEnableEDRModeKey API change issue * Adds Xcode 13 into the build matrix, fixes the way the destination is passed in * Build only x86_64 since arm64 runners are not yet available for GH actions. * Separate out tests into its own job * Some corrections to the test job * Ok, not going to bother with Xcode 13 after all. * Revert minimum macOS version back to 10.15 Co-authored-by: Markus Piipari --- .github/workflows/spm-build-test.yml | 42 +++++++++++++++++++--- Package.swift | 8 +++-- Sources/Carpaccio/CIImage+Extensions.swift | 12 +++++-- 3 files changed, 52 insertions(+), 10 deletions(-) diff --git a/.github/workflows/spm-build-test.yml b/.github/workflows/spm-build-test.yml index 8a2d301..cfbec02 100644 --- a/.github/workflows/spm-build-test.yml +++ b/.github/workflows/spm-build-test.yml @@ -8,14 +8,46 @@ on: jobs: build: - - runs-on: macos-11 - + strategy: + matrix: + destination: + - 'platform=iOS Simulator,OS=15.0,name=iPhone 13' + - 'platform=macOS,arch=x86_64' + # - 'platform=macOS,arch=arm64' # Uncomment once https://github.com/actions/virtual-environments/issues/2187 resolved + xcode: ['13.1'] + os: ['macos-11'] + runs-on: ${{ matrix.os }} steps: + - name: "Choose Xcode" + uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: ${{ matrix.xcode }} - uses: actions/checkout@v2 - name: Checkout LFS objects run: git lfs checkout - name: Build - run: swift build -v + run: xcodebuild build -scheme Carpaccio -destination '${{matrix.destination}}' + test: + strategy: + matrix: + destination: + - 'platform=macOS,arch=x86_64' + # Uncomment / merge back to the `build` job once `exifdump` is separated to its own Package.swift + # exifdump being a "tool" type target induces right now the following fail (with Xcode 13.1): + # "unable to resolve product type 'com.apple.product-type.tool' for platform 'iphonesimulator" + # - 'platform=iOS Simulator,OS=15.0,name=iPhone 13' + # Uncomment once https://github.com/actions/virtual-environments/issues/2187 resolved + # - 'platform=macOS,arch=arm64' + xcode: ['13.1'] + os: ['macos-11'] + runs-on: ${{ matrix.os }} + steps: + - name: "Choose Xcode" + uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: ${{ matrix.xcode }} + - uses: actions/checkout@v2 + - name: Checkout LFS objects + run: git lfs checkout - name: Run tests - run: swift test -v + run: xcodebuild test -scheme Carpaccio-Package -destination '${{matrix.destination}}' diff --git a/Package.swift b/Package.swift index 577b317..e95345b 100644 --- a/Package.swift +++ b/Package.swift @@ -1,12 +1,14 @@ -// swift-tools-version:5.4 +// swift-tools-version:5.5 // The swift-tools-version declares the minimum version of Swift required to build this package. import PackageDescription let package = Package( name: "Carpaccio", - platforms: [.macOS(.v10_15), - .iOS(.v14)], + platforms: [ + .macOS(.v10_15), + .iOS(.v14) + ], products: [ .library( name: "Carpaccio", diff --git a/Sources/Carpaccio/CIImage+Extensions.swift b/Sources/Carpaccio/CIImage+Extensions.swift index 7c2edfe..4bb0c8e 100644 --- a/Sources/Carpaccio/CIImage+Extensions.swift +++ b/Sources/Carpaccio/CIImage+Extensions.swift @@ -59,8 +59,16 @@ public extension CIImage { rawFilter.setValue(options.boostShadowAmount, forKey: CIRAWFilterOption.boostShadowAmount.rawValue) rawFilter.setValue(options.enableVendorLensCorrection, forKey: CIRAWFilterOption.enableVendorLensCorrection.rawValue) - // Preserve pixel values beyond 0.0 … 1.0, which wide colour images will have - rawFilter.setValue(true, forKey: CIRAWFilterOption.ciInputEnableEDRModeKey.rawValue) + // Preserve pixel values beyond 0.0 … 1.0 + if #available(macOS 12, *), #available(iOS 15, *) { + rawFilter.setValue(true, forKey: CIRAWFilterOption.ciInputEnableEDRModeKey.rawValue) + } else { + // For the life of me, I could not figure out, in a reasonable time, how to use the legacy SDK constant named + // kCIInputEnableEDRModeKey here, and get past Xcdode 13.1's compiler error saying that it has been renamed to + // CIRAWFilterOption.ciInputEnableEDRModeKey. Life's too short, so we will use a direct literal value, as extracted + // from the console. + rawFilter.setValue(true, forKey: "inputEnableEDRMode") + } guard let rawImage = rawFilter.outputImage else { throw ImageLoadingError.failedToDecode(URL: url, message: "Failed to decode image at \(url.path)")