Skip to content

Commit

Permalink
FEATURE: Swift Strict Concurrency support (#170)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamayoung authored Apr 3, 2024
1 parent dca0aff commit 17d8ace
Show file tree
Hide file tree
Showing 130 changed files with 501 additions and 386 deletions.
27 changes: 13 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ concurrency:
cancel-in-progress: true

env:
DEVELOPER_DIR: /Applications/Xcode_15.2.app/Contents/Developer
BUILD_JOB_COUNT: 4
DEVELOPER_DIR: /Applications/Xcode_15.3.app/Contents/Developer

jobs:
build-test:
Expand All @@ -29,10 +28,10 @@ jobs:
uses: actions/checkout@v4

- name: Build
run: swift build --build-tests --jobs ${{ env.BUILD_JOB_COUNT }} -Xswiftc -warnings-as-errors
run: swift build --build-tests -Xswiftc -warnings-as-errors -Xswiftc -strict-concurrency=complete

- name: Test
run: swift test --filter TMDbTests --enable-code-coverage
run: swift test --filter TMDbTests --enable-code-coverage -Xswiftc -strict-concurrency=complete

- name: Prepare Code Coverage
run: |
Expand All @@ -49,7 +48,7 @@ jobs:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

- name: Build for Release
run: swift build -c release --jobs ${{ env.BUILD_JOB_COUNT }} -Xswiftc -warnings-as-errors
run: swift build -c release -Xswiftc -warnings-as-errors -Xswiftc -strict-concurrency=complete

build-and-test-platforms:
name: Build and Test (${{ matrix.name }})
Expand All @@ -59,22 +58,22 @@ jobs:
matrix:
include:
- name: iOS
destination: platform=iOS Simulator,name=iPhone 15,OS=17.2
destination: platform=iOS Simulator,name=iPhone 15,OS=17.4
- name: watchOS
destination: platform=watchOS Simulator,name=Apple Watch Series 9 (45mm),OS=10.2
destination: platform=watchOS Simulator,name=Apple Watch Series 9 (45mm),OS=10.4
- name: tvOS
destination: platform=tvOS Simulator,name=Apple TV 4K (3rd generation),OS=17.2
destination: platform=tvOS Simulator,name=Apple TV 4K (3rd generation),OS=17.4
- name: visionOS
destination: platform=visionOS Simulator,name=Apple Vision Pro,OS=1.0
destination: platform=visionOS Simulator,name=Apple Vision Pro,OS=1.1
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Build
run: set -o pipefail && NSUnbufferedIO=YES xcodebuild build-for-testing -scheme TMDb -only-testing TMDbTests -destination '${{ matrix.destination }}' -parallelizeTargets 2>&1 | xcbeautify
run: set -o pipefail && NSUnbufferedIO=YES xcodebuild build-for-testing -scheme TMDb -only-testing TMDbTests -destination '${{ matrix.destination }}' | xcbeautify

- name: Test
run: set -o pipefail && NSUnbufferedIO=YES xcodebuild test-without-building -scheme TMDb -only-testing TMDbTests -destination '${{ matrix.destination }}' -parallel-testing-enabled YES 2>&1 | xcbeautify
run: set -o pipefail && NSUnbufferedIO=YES xcodebuild test-without-building -scheme TMDb -only-testing TMDbTests -destination '${{ matrix.destination }}' | xcbeautify

build-test-linux:
name: Build and Test (Linux)
Expand All @@ -85,10 +84,10 @@ jobs:
uses: actions/checkout@v4

- name: Build
run: swift build --build-tests --jobs ${{ env.BUILD_JOB_COUNT }} -Xswiftc -warnings-as-errors
run: swift build --build-tests -Xswiftc -warnings-as-errors

- name: Test
run: swift test --skip-build --parallel --filter TMDbTests
run: swift test --skip-build --filter TMDbTests

- name: Build for Release
run: swift build -c release --jobs ${{ env.BUILD_JOB_COUNT }} -Xswiftc -warnings-as-errors
run: swift build -c release -Xswiftc -warnings-as-errors
7 changes: 3 additions & 4 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,15 @@ on:
- main
schedule:
# Every Sunday at 12am
- cron: '0 0 * * 0'
- cron: '0 0 * * 0'
workflow_dispatch:

concurrency:
group: "codeql-${{ github.head_ref || github.run_id }}"
cancel-in-progress: true

env:
DEVELOPER_DIR: /Applications/Xcode_15.2.app/Contents/Developer
BUILD_JOB_COUNT: 4
DEVELOPER_DIR: /Applications/Xcode_15.3.app/Contents/Developer

jobs:
analyze:
Expand All @@ -40,7 +39,7 @@ jobs:
config-file: ./.github/codeql/codeql-config.yml

- name: Build
run: swift build --build-tests --jobs ${{ env.BUILD_JOB_COUNT }}
run: swift build --build-tests

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,15 @@ on:
- "**/*.swift"
schedule:
# Every Sunday at 12am
- cron: '0 0 * * 0'
- cron: '0 0 * * 0'
workflow_dispatch:

concurrency:
group: "integration-${{ github.head_ref || github.run_id }}"
cancel-in-progress: true

env:
DEVELOPER_DIR: /Applications/Xcode_15.2.app/Contents/Developer
BUILD_JOB_COUNT: 4
DEVELOPER_DIR: /Applications/Xcode_15.3.app/Contents/Developer

jobs:
integration-test:
Expand All @@ -32,7 +31,7 @@ jobs:
uses: actions/checkout@v4

- name: Build
run: swift build --build-tests --jobs ${{ env.BUILD_JOB_COUNT }}
run: swift build --build-tests

- name: Test
run: swift test --skip-build --filter TMDbIntegrationTests
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ xcuserdata/
*.xctestplan
docs/
info.lcov
default.profraw
41 changes: 20 additions & 21 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ TARGET = TMDb
TEST_TARGET = TMDbTests
INTEGRATION_TEST_TARGET = TMDbIntegrationTests

IOS_DESTINATION = 'platform=iOS Simulator,name=iPhone 15,OS=17.2'
WATCHOS_DESINTATION = 'platform=watchOS Simulator,name=Apple Watch Series 9 (45mm),OS=10.2'
TVOS_DESTINATION = 'platform=tvOS Simulator,name=Apple TV 4K (3rd generation),OS=17.2'
IOS_DESTINATION = 'platform=iOS Simulator,name=iPhone 15,OS=17.4'
WATCHOS_DESINTATION = 'platform=watchOS Simulator,name=Apple Watch Series 9 (45mm),OS=10.4'
TVOS_DESTINATION = 'platform=tvOS Simulator,name=Apple TV 4K (3rd generation),OS=17.4'
VISIONOS_DESTINATION = 'platform=visionOS Simulator,name=Apple Vision Pro,OS=1.1'
BUILD_JOB_COUNT = 4

SWIFT_CONTAINER_IMAGE = swift:5.9.2-jammy

Expand All @@ -32,19 +31,19 @@ lint-markdown:

.PHONY: build
build:
swift build --jobs 4 -Xswiftc -warnings-as-errors
swift build -Xswiftc -warnings-as-errors -Xswiftc -strict-concurrency=complete

.PHONY: build-linux
build-linux:
docker run --rm -v "$${PWD}:/workspace" -w /workspace $(SWIFT_CONTAINER_IMAGE) /bin/bash -cl "swift build --jobs $(BUILD_JOB_COUNT) -Xswiftc -warnings-as-errors"
docker run --rm -v "$${PWD}:/workspace" -w /workspace $(SWIFT_CONTAINER_IMAGE) /bin/bash -cl "swift build -Xswiftc -warnings-as-errors -Xswiftc -strict-concurrency=complete"

.PHONY: build-release
build-release:
swift build -c release --jobs 4 -Xswiftc -warnings-as-errors
swift build -c release -Xswiftc -warnings-as-errors -Xswiftc -strict-concurrency=complete

.PHONY: build-linux-release
build-linux-release:
docker run --rm -v "$${PWD}:/workspace" -w /workspace $(SWIFT_CONTAINER_IMAGE) /bin/bash -cl "swift build -c release --jobs $(BUILD_JOB_COUNT) -Xswiftc -warnings-as-errors"
docker run --rm -v "$${PWD}:/workspace" -w /workspace $(SWIFT_CONTAINER_IMAGE) /bin/bash -cl "swift build -c release -Xswiftc -warnings-as-errors -Xswiftc -strict-concurrency=complete"

.PHONY: build-docs
build-docs:
Expand All @@ -66,37 +65,37 @@ generate-docs:

.PHONY: test
test:
swift build --build-tests --jobs $(BUILD_JOB_COUNT) -Xswiftc -warnings-as-errors
swift test --skip-build --parallel --filter $(TEST_TARGET)
swift build --build-tests -Xswiftc -warnings-as-errors -Xswiftc -strict-concurrency=complete
swift test --skip-build --filter $(TEST_TARGET) -Xswiftc -strict-concurrency=complete

.PHONY: test-ios
test-ios:
set -o pipefail && NSUnbufferedIO=YES xcodebuild clean build-for-testing -scheme $(TARGET) -only-testing $(TEST_TARGET) -destination $(IOS_DESTINATION) -parallelizeTargets 2>&1 | xcbeautify
set -o pipefail && NSUnbufferedIO=YES xcodebuild test-without-building -scheme $(TARGET) -only-testing $(TEST_TARGET) -destination $(IOS_DESTINATION) -parallel-testing-enabled YES 2>&1 | xcbeautify
set -o pipefail && NSUnbufferedIO=YES xcodebuild clean build-for-testing -scheme $(TARGET) -only-testing $(TEST_TARGET) -destination $(IOS_DESTINATION) | xcbeautify
set -o pipefail && NSUnbufferedIO=YES xcodebuild test-without-building -scheme $(TARGET) -only-testing $(TEST_TARGET) -destination $(IOS_DESTINATION) | xcbeautify

.PHONY: test-watchos
test-watchos:
set -o pipefail && NSUnbufferedIO=YES xcodebuild build-for-testing -scheme $(TARGET) -only-testing $(TEST_TARGET) -destination $(WATCHOS_DESINTATION) -parallelizeTargets 2>&1 | xcbeautify
set -o pipefail && NSUnbufferedIO=YES xcodebuild test-without-building -scheme $(TARGET) -only-testing $(TEST_TARGET) -destination $(WATCHOS_DESINTATION) -parallel-testing-enabled YES 2>&1 | xcbeautify
set -o pipefail && NSUnbufferedIO=YES xcodebuild build-for-testing -scheme $(TARGET) -only-testing $(TEST_TARGET) -destination $(WATCHOS_DESINTATION) | xcbeautify
set -o pipefail && NSUnbufferedIO=YES xcodebuild test-without-building -scheme $(TARGET) -only-testing $(TEST_TARGET) -destination $(WATCHOS_DESINTATION) | xcbeautify

.PHONY: test-tvos
test-tvos:
set -o pipefail && NSUnbufferedIO=YES xcodebuild build-for-testing -scheme $(TARGET) -only-testing $(TEST_TARGET) -destination $(TVOS_DESTINATION) -parallelizeTargets 2>&1 | xcbeautify
set -o pipefail && NSUnbufferedIO=YES xcodebuild test-without-building -scheme $(TARGET) -only-testing $(TEST_TARGET) -destination $(TVOS_DESTINATION) -parallel-testing-enabled YES 2>&1 | xcbeautify
set -o pipefail && NSUnbufferedIO=YES xcodebuild build-for-testing -scheme $(TARGET) -only-testing $(TEST_TARGET) -destination $(TVOS_DESTINATION) | xcbeautify
set -o pipefail && NSUnbufferedIO=YES xcodebuild test-without-building -scheme $(TARGET) -only-testing $(TEST_TARGET) -destination $(TVOS_DESTINATION) | xcbeautify

.PHONY: test-visionos
test-visionos:
set -o pipefail && NSUnbufferedIO=YES xcodebuild build-for-testing -scheme $(TARGET) -only-testing $(TEST_TARGET) -destination $(VISIONOS_DESTINATION) -parallelizeTargets 2>&1 | xcbeautify
set -o pipefail && NSUnbufferedIO=YES xcodebuild test-without-building -scheme $(TARGET) -only-testing $(TEST_TARGET) -destination $(VISIONOS_DESTINATION) -parallel-testing-enabled YES 2>&1 | xcbeautify
set -o pipefail && NSUnbufferedIO=YES xcodebuild build-for-testing -scheme $(TARGET) -only-testing $(TEST_TARGET) -destination $(VISIONOS_DESTINATION) | xcbeautify
set -o pipefail && NSUnbufferedIO=YES xcodebuild test-without-building -scheme $(TARGET) -only-testing $(TEST_TARGET) -destination $(VISIONOS_DESTINATION) | xcbeautify

.PHONY: test-linux
test-linux:
docker run --rm -v "$${PWD}:/workspace" -w /workspace $(SWIFT_CONTAINER_IMAGE) /bin/bash -cl "swift build --build-tests --jobs $(BUILD_JOB_COUNT) -Xswiftc -warnings-as-errors && swift test --skip-build --filter $(TEST_TARGET)"
docker run --rm -v "$${PWD}:/workspace" -w /workspace $(SWIFT_CONTAINER_IMAGE) /bin/bash -cl "swift build --build-tests -Xswiftc -warnings-as-errors && swift test --skip-build --filter $(TEST_TARGET)"

.PHONY: integration-test
integration-test: .check-env-vars
swift build --build-tests --jobs $(BUILD_JOB_COUNT)
swift test --skip-build --filter $(INTEGRATION_TEST_TARGET)
swift build --build-tests -Xswiftc -strict-concurrency=complete
swift test --skip-build --filter $(INTEGRATION_TEST_TARGET) -Xswiftc -strict-concurrency=complete

.PHONY: ci
ci: .check-env-vars lint lint-markdown test test-ios test-watchos test-tvos test-visionos test-linux integration-test build-release build-docs
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ Add the TMDb package as a dependency to your `Package.swift` file, and add it
as a dependency to your target.

```swift
// swift-tools-version:5.9
// swift-tools-version:5.10

import PackageDescription

let package = Package(
name: "MyProject",

dependencies: [
.package(url: "https://github.com/adamayoung/TMDb.git", from: "11.0.0")
.package(url: "https://github.com/adamayoung/TMDb.git", from: "12.0.0")
],

targets: [
Expand Down
2 changes: 1 addition & 1 deletion Sources/TMDb/Models/APIConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import Foundation
/// the actual API responses as light as possible. It is recommended you cache this data within your application and
/// check for updates every few days.
///
public struct APIConfiguration: Codable, Equatable, Hashable {
public struct APIConfiguration: Codable, Equatable, Hashable, Sendable {

///
/// Images configuration.
Expand Down
6 changes: 3 additions & 3 deletions Sources/TMDb/Models/AccountAvatar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import Foundation
///
/// A model representing a TMDb user's avatar.
///
public struct AccountAvatar: Codable, Equatable, Hashable {
public struct AccountAvatar: Codable, Equatable, Hashable, Sendable {

///
/// Gravatar avatar.
Expand Down Expand Up @@ -56,7 +56,7 @@ public extension AccountAvatar {
///
/// A model representing a TMDb user's Gravatar avatar.
///
struct Gravatar: Codable, Equatable, Hashable {
struct Gravatar: Codable, Equatable, Hashable, Sendable {

///
/// Gravatar hash.
Expand All @@ -80,7 +80,7 @@ public extension AccountAvatar {
///
/// A model representing a TMDb user's TMDb avatar.
///
struct TMDb: Codable, Equatable, Hashable {
struct TMDb: Codable, Equatable, Hashable, Sendable {

///
/// Path of the avatar image.
Expand Down
2 changes: 1 addition & 1 deletion Sources/TMDb/Models/AccountDetails.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import Foundation
///
/// A model representing a TMDb user's account details.
///
public struct AccountDetails: Identifiable, Codable, Equatable, Hashable {
public struct AccountDetails: Identifiable, Codable, Equatable, Hashable, Sendable {

///
/// User identifier.
Expand Down
2 changes: 1 addition & 1 deletion Sources/TMDb/Models/CastMember.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import Foundation
///
/// A model representing a cast member.
///
public struct CastMember: Identifiable, Codable, Equatable, Hashable {
public struct CastMember: Identifiable, Codable, Equatable, Hashable, Sendable {

///
/// Cast member's identifier.
Expand Down
2 changes: 1 addition & 1 deletion Sources/TMDb/Models/Certification.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import Foundation
///
/// A model representing an officially supported certification.
///
public struct Certification: Identifiable, Codable, Equatable, Hashable {
public struct Certification: Identifiable, Codable, Equatable, Hashable, Sendable {

///
/// Certification's identifier (same as ``code``).
Expand Down
2 changes: 1 addition & 1 deletion Sources/TMDb/Models/Certifications.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import Foundation

struct Certifications: Codable, Equatable, Hashable {
struct Certifications: Codable, Equatable, Hashable, Sendable {

let certifications: [String: [Certification]]

Expand Down
4 changes: 2 additions & 2 deletions Sources/TMDb/Models/Company.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import Foundation
///
/// A model representing a production company.
///
public struct Company: Identifiable, Codable, Equatable, Hashable {
public struct Company: Identifiable, Codable, Equatable, Hashable, Sendable {

///
/// Company identifier.
Expand Down Expand Up @@ -106,7 +106,7 @@ public extension Company {
///
/// A model representing a parent company.
///
struct Parent: Identifiable, Codable, Equatable, Hashable {
struct Parent: Identifiable, Codable, Equatable, Hashable, Sendable {

///
/// Company identifier.
Expand Down
2 changes: 1 addition & 1 deletion Sources/TMDb/Models/Country.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import Foundation
///
/// A model representing a country.
///
public struct Country: Identifiable, Codable, Equatable, Hashable {
public struct Country: Identifiable, Codable, Equatable, Hashable, Sendable {

///
/// Country's identifier (same as `countryCode`).
Expand Down
2 changes: 1 addition & 1 deletion Sources/TMDb/Models/Credential.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import Foundation
///
/// A model representing a user's TMDb username and password.
///
public struct Credential {
public struct Credential: Sendable {

///
/// User's username.
Expand Down
2 changes: 1 addition & 1 deletion Sources/TMDb/Models/CrewMember.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import Foundation
///
/// A model representing a crew member..
///
public struct CrewMember: Identifiable, Codable, Equatable, Hashable {
public struct CrewMember: Identifiable, Codable, Equatable, Hashable, Sendable {

///
/// Crew member's identifier.
Expand Down
2 changes: 1 addition & 1 deletion Sources/TMDb/Models/Department.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import Foundation
///
/// A model representing a department and jobs.
///
public struct Department: Identifiable, Codable, Equatable, Hashable {
public struct Department: Identifiable, Codable, Equatable, Hashable, Sendable {

///
/// Departments's identifier (same as `name`).
Expand Down
2 changes: 1 addition & 1 deletion Sources/TMDb/Models/ExternalLink.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import Foundation
///
/// e.g. to a Movie's IMDb page.
///
public protocol ExternalLink: Equatable, Hashable {
public protocol ExternalLink: Equatable, Hashable, Sendable {

///
/// The external site's item identifier.
Expand Down
2 changes: 1 addition & 1 deletion Sources/TMDb/Models/Gender.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import Foundation
///
/// A model representing the gender of a person.
///
public enum Gender: Int, Codable, Equatable, Hashable {
public enum Gender: Int, Codable, Equatable, Hashable, Sendable {

///
/// An unknown gender.
Expand Down
2 changes: 1 addition & 1 deletion Sources/TMDb/Models/Genre.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import Foundation
///
/// A model representing a genre.
///
public struct Genre: Identifiable, Codable, Equatable, Hashable {
public struct Genre: Identifiable, Codable, Equatable, Hashable, Sendable {

///
/// Genre Identifier.
Expand Down
Loading

0 comments on commit 17d8ace

Please sign in to comment.