From 92450b18a4be9128752920616382466128bad02b Mon Sep 17 00:00:00 2001 From: Adam Young Date: Tue, 5 Nov 2024 21:24:55 +0000 Subject: [PATCH 1/4] CONFIG: Update GH to use macOS 15 --- .github/workflows/ci.yml | 36 +++++++++++++++---------------- .github/workflows/codeql.yml | 4 ++-- .github/workflows/integration.yml | 4 ++-- .github/workflows/lint.yml | 4 ++-- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3a76c1fe..96c99681 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,12 +17,12 @@ concurrency: cancel-in-progress: true env: - DEVELOPER_DIR: /Applications/Xcode_16.app/Contents/Developer + DEVELOPER_DIR: /Applications/Xcode_16.1.app/Contents/Developer jobs: build-test: name: Build and Test - runs-on: macos-14 + runs-on: macos-15 steps: - name: Checkout uses: actions/checkout@v4 @@ -52,7 +52,7 @@ jobs: build-and-test-platforms: name: Build and Test (${{ matrix.name }}) - runs-on: macos-14 + runs-on: macos-15 continue-on-error: true strategy: matrix: @@ -63,8 +63,8 @@ jobs: destination: platform=watchOS Simulator,name=Apple Watch Series 10 (46mm),OS=11.0 - name: tvOS destination: platform=tvOS Simulator,name=Apple TV 4K (3rd generation),OS=18.0 - # - name: visionOS - # destination: platform=visionOS Simulator,name=Apple Vision Pro,OS=2.0 + - name: visionOS + destination: platform=visionOS Simulator,name=Apple Vision Pro,OS=2.0 steps: - name: Checkout uses: actions/checkout@v4 @@ -75,19 +75,19 @@ jobs: - name: Test run: set -o pipefail && NSUnbufferedIO=YES xcodebuild test-without-building -scheme TMDb -only-testing TMDbTests -destination '${{ matrix.destination }}' - # build-test-linux: - # name: Build and Test (Linux) - # runs-on: ubuntu-latest - # container: swiftlang/swift:nightly-6.0-jammy - # steps: - # - name: Checkout - # uses: actions/checkout@v4 + build-test-linux: + name: Build and Test (Linux) + runs-on: ubuntu-latest + container: swift:nightly-6.0.2-jammy + steps: + - name: Checkout + uses: actions/checkout@v4 - # - name: Build - # run: swift build --build-tests -Xswiftc -warnings-as-errors + - name: Build + run: swift build --build-tests -Xswiftc -warnings-as-errors - # - name: Test - # run: swift test --skip-build --filter TMDbTests + - name: Test + run: swift test --skip-build --filter TMDbTests - # - name: Build for Release - # run: swift build -c release -Xswiftc -warnings-as-errors + - name: Build for Release + run: swift build -c release -Xswiftc -warnings-as-errors diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index a1fe2ed5..5ef0536d 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -17,12 +17,12 @@ concurrency: cancel-in-progress: true env: - DEVELOPER_DIR: /Applications/Xcode_16.app/Contents/Developer + DEVELOPER_DIR: /Applications/Xcode_16.1.app/Contents/Developer jobs: analyze: name: Analyze - runs-on: macos-14 + runs-on: macos-15 timeout-minutes: 120 permissions: actions: read diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index ec4321b6..be5e453c 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -20,12 +20,12 @@ concurrency: cancel-in-progress: true env: - DEVELOPER_DIR: /Applications/Xcode_16.app/Contents/Developer + DEVELOPER_DIR: /Applications/Xcode_16.1.app/Contents/Developer jobs: integration-test: name: Integration Test - runs-on: macos-14 + runs-on: macos-15 steps: - name: Checkout uses: actions/checkout@v4 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 05ea6ed6..334e8c39 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -19,9 +19,9 @@ concurrency: jobs: swiftLint: name: SwiftLint - runs-on: macos-14 + runs-on: macos-15 env: - DEVELOPER_DIR: /Applications/Xcode_16.app/Contents/Developer + DEVELOPER_DIR: /Applications/Xcode_16.1.app/Contents/Developer steps: - name: Checkout uses: actions/checkout@v4 From 8c43271c1edc8003ac90ade17c51ccbb609c9c14 Mon Sep 17 00:00:00 2001 From: Adam Young Date: Tue, 5 Nov 2024 21:26:11 +0000 Subject: [PATCH 2/4] Update linux swift container --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 96c99681..60b81530 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -78,7 +78,7 @@ jobs: build-test-linux: name: Build and Test (Linux) runs-on: ubuntu-latest - container: swift:nightly-6.0.2-jammy + container: swift:6.0.2-jammy steps: - name: Checkout uses: actions/checkout@v4 From 75aec63a20ea72bbb8ea92826ab669915a5728f2 Mon Sep 17 00:00:00 2001 From: Adam Young Date: Tue, 5 Nov 2024 21:55:44 +0000 Subject: [PATCH 3/4] Fix tests for Linux --- Makefile | 2 +- Sources/TMDb/Networking/TMDbAPIClient.swift | 4 ++++ .../Adapters/URLSessionHTTPClientAdapterTests.swift | 4 ++++ Tests/TMDbTests/Domain/Models/MovieTests.swift | 2 +- Tests/TMDbTests/Domain/Models/ShowTests.swift | 2 +- .../Networking/HTTPClient/MockURLProtocol.swift | 4 ++++ Tests/TMDbTests/Networking/TMDbAPIClientTests.swift | 10 +++++++++- 7 files changed, 24 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 534c757a..64487bbc 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ WATCHOS_DESINTATION = 'platform=watchOS Simulator,name=Apple Watch Series 9 (45m TVOS_DESTINATION = 'platform=tvOS Simulator,name=Apple TV 4K (3rd generation),OS=18.0' VISIONOS_DESTINATION = 'platform=visionOS Simulator,name=Apple Vision Pro,OS=2.0' -SWIFT_CONTAINER_IMAGE = swiftlang/swift:nightly-6.0-jammy +SWIFT_CONTAINER_IMAGE = swift:6.0.2-jammy .PHONY: clean clean: diff --git a/Sources/TMDb/Networking/TMDbAPIClient.swift b/Sources/TMDb/Networking/TMDbAPIClient.swift index bda2ca15..6fa22ccc 100644 --- a/Sources/TMDb/Networking/TMDbAPIClient.swift +++ b/Sources/TMDb/Networking/TMDbAPIClient.swift @@ -19,6 +19,10 @@ import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif + final class TMDbAPIClient: APIClient, Sendable { private let apiKey: String diff --git a/Tests/TMDbTests/Adapters/URLSessionHTTPClientAdapterTests.swift b/Tests/TMDbTests/Adapters/URLSessionHTTPClientAdapterTests.swift index 20f9953e..ddd1c24c 100644 --- a/Tests/TMDbTests/Adapters/URLSessionHTTPClientAdapterTests.swift +++ b/Tests/TMDbTests/Adapters/URLSessionHTTPClientAdapterTests.swift @@ -17,6 +17,8 @@ // limitations under the License. // +#if !os(Linux) + import Foundation import Testing @testable import TMDb @@ -142,3 +144,5 @@ final class URLSessionHTTPClientAdapterTests { } } + +#endif diff --git a/Tests/TMDbTests/Domain/Models/MovieTests.swift b/Tests/TMDbTests/Domain/Models/MovieTests.swift index 8d1e3a1a..b574d59e 100644 --- a/Tests/TMDbTests/Domain/Models/MovieTests.swift +++ b/Tests/TMDbTests/Domain/Models/MovieTests.swift @@ -64,7 +64,7 @@ extension MovieTests { backdropPath: URL(string: "/fCayJrkfRaCRCTh8GqN30f8oyQF.jpg"), budget: 63_000_000, revenue: 100_853_753, - homepageURL: URL(string: ""), + homepageURL: nil, imdbID: "tt0137523", status: .released, productionCompanies: [ diff --git a/Tests/TMDbTests/Domain/Models/ShowTests.swift b/Tests/TMDbTests/Domain/Models/ShowTests.swift index 6191d2a4..9b2f1ff7 100644 --- a/Tests/TMDbTests/Domain/Models/ShowTests.swift +++ b/Tests/TMDbTests/Domain/Models/ShowTests.swift @@ -58,7 +58,7 @@ struct ShowTests { #expect(tvSeriesShow.date == expectedResult) } - @Test("JSON decoding of Movie", .tags(.decoding)) + @Test("JSON decoding of Show", .tags(.decoding)) func testDecodeReturnsMovie() throws { let result = try JSONDecoder.theMovieDatabase.decode(Show.self, fromResource: "show-movie") diff --git a/Tests/TMDbTests/Networking/HTTPClient/MockURLProtocol.swift b/Tests/TMDbTests/Networking/HTTPClient/MockURLProtocol.swift index ec3d96eb..38a42550 100644 --- a/Tests/TMDbTests/Networking/HTTPClient/MockURLProtocol.swift +++ b/Tests/TMDbTests/Networking/HTTPClient/MockURLProtocol.swift @@ -19,6 +19,10 @@ import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif + final class MockURLProtocol: URLProtocol, @unchecked Sendable { @MainActor static var data: Data? diff --git a/Tests/TMDbTests/Networking/TMDbAPIClientTests.swift b/Tests/TMDbTests/Networking/TMDbAPIClientTests.swift index 2288b7d7..0b006016 100644 --- a/Tests/TMDbTests/Networking/TMDbAPIClientTests.swift +++ b/Tests/TMDbTests/Networking/TMDbAPIClientTests.swift @@ -21,6 +21,10 @@ import Foundation import Testing @testable import TMDb +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif + @Suite(.tags(.networking)) struct TMDbAPIClientTests { @@ -59,7 +63,11 @@ struct TMDbAPIClientTests { error = err as? TMDbAPIError } - #expect(error == .invalidURL(path)) + #if canImport(FoundationNetworking) + #expect(error == .unknown) + #else + #expect(error == .invalidURL(path)) + #endif } @Test("perform has correct URL") From 6b3c23409e91f9de57a505ce1f09faf98f91b0b6 Mon Sep 17 00:00:00 2001 From: Adam Young Date: Tue, 5 Nov 2024 22:11:05 +0000 Subject: [PATCH 4/4] Fix lint error --- .../URLSessionHTTPClientAdapterTests.swift | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/Tests/TMDbTests/Adapters/URLSessionHTTPClientAdapterTests.swift b/Tests/TMDbTests/Adapters/URLSessionHTTPClientAdapterTests.swift index ddd1c24c..137cb77a 100644 --- a/Tests/TMDbTests/Adapters/URLSessionHTTPClientAdapterTests.swift +++ b/Tests/TMDbTests/Adapters/URLSessionHTTPClientAdapterTests.swift @@ -17,15 +17,26 @@ // limitations under the License. // -#if !os(Linux) - import Foundation import Testing @testable import TMDb +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif + +private let isLinux = { + #if os(Linux) + return true + #else + return false + #endif +}() + @Suite( .serialized, - .tags(.adapter) + .tags(.adapter), + .disabled(if: isLinux) ) final class URLSessionHTTPClientAdapterTests { @@ -144,5 +155,3 @@ final class URLSessionHTTPClientAdapterTests { } } - -#endif