Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Local cache mutation build error in Swift 6 #417

Merged
merged 7 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
298 changes: 107 additions & 191 deletions .github/workflows/ci-tests-xcode-beta.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
name: "CI Tests (Xcode 16.0 Beta)"

on:
workflow_dispatch
pull_request:
types: [opened, synchronize, reopened]

env:
XCODE_VERSION: "16.0-beta"
Expand Down Expand Up @@ -84,124 +85,111 @@ jobs:
run: |
cd ${{ matrix.package }} && swift build

build-and-unit-test:
runs-on: macos-latest
needs: [tuist-generation, changes]
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
include:
# macOS_current
- destination: platform=macOS,arch=x86_64
scheme: ApolloTests
test-plan: Apollo-CITestPlan
name: Apollo Unit Tests - macOS
run-js-tests: false
should-run: ${{ needs.changes.outputs.ios }}
# Codegen CLI Test
- destination: platform=macOS,arch=x86_64
scheme: CodegenCLITests
test-plan: CodegenCLITestPlan
name: Codegen CLI Unit Tests - macOS
run-js-tests: false
should-run: ${{ needs.changes.outputs.codegen }}
# CodegenLib Test
- destination: platform=macOS,arch=x86_64
scheme: ApolloCodegenTests
test-plan: Apollo-Codegen-CITestPlan
name: Codegen Lib Unit Tests - macOS
run-js-tests: true
should-run: ${{ needs.changes.outputs.codegen }}
# ApolloPagination Tests
- destination: platform=macOS,arch=x86_64
scheme: ApolloPaginationTests
test-plan: Apollo-PaginationTestPlan
name: ApolloPagination Unit Tests - macOS
run-js-tests: false
should-run: ${{ needs.changes.outputs.pagination }}
name: ${{ matrix.name }}
steps:
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: ${{ env.XCODE_VERSION }}
- name: Checkout Repo
uses: actions/checkout@v3
- name: Retrieve Build Cache
uses: actions/cache@v3
with:
path: |
./ApolloDev.xcodeproj
./ApolloDev.xcworkspace
./Derived/*
key: ${{ github.run_id }}-dependencies
fail-on-cache-miss: true
# Caching for apollo-ios and apollo-ios-codegen SPM dependencies
# - uses: actions/cache@v3
# with:
# path: ./DerivedData/SourcePackages
# key: ${{ runner.os }}-spm-${{ hashFiles('./apollo-ios/Package.resolved') }}-${{ hashFiles('./apollo-ios-codegen/Package.resolved') }}
# - name: Run Tuist Generation
# uses: tuist/tuist-action@0.13.0
# with:
# command: 'generate'
# arguments: ''
- name: Build and Test
if: ${{ matrix.should-run == true || matrix.should-run == 'true' }}
id: build-and-test
uses: ./.github/actions/build-and-run-unit-tests
with:
destination: ${{ matrix.destination }}
scheme: ${{ matrix.scheme }}
test-plan: ${{ matrix.test-plan }}
- name: Run-JS-Tests
if: ${{ matrix.run-js-tests == true }}
shell: bash
working-directory: apollo-ios-codegen/Sources/GraphQLCompiler/JavaScript/
run: |
npm install && npm test
- name: Save xcodebuild logs
if: ${{ steps.build-and-test.outcome != 'skipped' }}
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.name }}-logs
path: |
DerivedData/Logs/Build
- name: Save crash logs
if: ${{ steps.build-and-test.outcome != 'skipped' }}
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.name }}-crashes
path: |
~/Library/Logs/DiagnosticReports
- name: Zip Result Bundle
if: ${{ steps.build-and-test.outcome != 'skipped' }}
shell: bash
working-directory: TestResults
run: |
zip -r ResultBundle.zip ResultBundle.xcresult
- name: Save test results
if: ${{ steps.build-and-test.outcome != 'skipped' }}
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.name }}-results
path: |
TestResults/ResultBundle.zip
# build-and-unit-test:
# runs-on: macos-latest
# needs: [tuist-generation, changes]
# timeout-minutes: 20
# strategy:
# fail-fast: false
# matrix:
# include:
# # macOS_current
# - destination: platform=macOS,arch=x86_64
# scheme: ApolloTests
# test-plan: Apollo-CITestPlan
# name: Apollo Unit Tests - macOS
# run-js-tests: false
# should-run: ${{ needs.changes.outputs.ios }}
# # Codegen CLI Test
# - destination: platform=macOS,arch=x86_64
# scheme: CodegenCLITests
# test-plan: CodegenCLITestPlan
# name: Codegen CLI Unit Tests - macOS
# run-js-tests: false
# should-run: ${{ needs.changes.outputs.codegen }}
# # CodegenLib Test
# - destination: platform=macOS,arch=x86_64
# scheme: ApolloCodegenTests
# test-plan: Apollo-Codegen-CITestPlan
# name: Codegen Lib Unit Tests - macOS
# run-js-tests: true
# should-run: ${{ needs.changes.outputs.codegen }}
# # ApolloPagination Tests
# - destination: platform=macOS,arch=x86_64
# scheme: ApolloPaginationTests
# test-plan: Apollo-PaginationTestPlan
# name: ApolloPagination Unit Tests - macOS
# run-js-tests: false
# should-run: ${{ needs.changes.outputs.pagination }}
# name: ${{ matrix.name }}
# steps:
# - uses: maxim-lobanov/setup-xcode@v1
# with:
# xcode-version: ${{ env.XCODE_VERSION }}
# - name: Checkout Repo
# uses: actions/checkout@v3
# - name: Retrieve Build Cache
# uses: actions/cache@v3
# with:
# path: |
# ./ApolloDev.xcodeproj
# ./ApolloDev.xcworkspace
# ./Derived/*
# key: ${{ github.run_id }}-dependencies
# fail-on-cache-miss: true
# # Caching for apollo-ios and apollo-ios-codegen SPM dependencies
# # - uses: actions/cache@v3
# # with:
# # path: ./DerivedData/SourcePackages
# # key: ${{ runner.os }}-spm-${{ hashFiles('./apollo-ios/Package.resolved') }}-${{ hashFiles('./apollo-ios-codegen/Package.resolved') }}
# # - name: Run Tuist Generation
# # uses: tuist/tuist-action@0.13.0
# # with:
# # command: 'generate'
# # arguments: ''
# - name: Build and Test
# if: ${{ matrix.should-run == true || matrix.should-run == 'true' }}
# id: build-and-test
# uses: ./.github/actions/build-and-run-unit-tests
# with:
# destination: ${{ matrix.destination }}
# scheme: ${{ matrix.scheme }}
# test-plan: ${{ matrix.test-plan }}
# - name: Run-JS-Tests
# if: ${{ matrix.run-js-tests == true }}
# shell: bash
# working-directory: apollo-ios-codegen/Sources/GraphQLCompiler/JavaScript/
# run: |
# npm install && npm test
# - name: Save xcodebuild logs
# if: ${{ steps.build-and-test.outcome != 'skipped' }}
# uses: actions/upload-artifact@v3
# with:
# name: ${{ matrix.name }}-logs
# path: |
# DerivedData/Logs/Build
# - name: Save crash logs
# if: ${{ steps.build-and-test.outcome != 'skipped' }}
# uses: actions/upload-artifact@v3
# with:
# name: ${{ matrix.name }}-crashes
# path: |
# ~/Library/Logs/DiagnosticReports
# - name: Zip Result Bundle
# if: ${{ steps.build-and-test.outcome != 'skipped' }}
# shell: bash
# working-directory: TestResults
# run: |
# zip -r ResultBundle.zip ResultBundle.xcresult
# - name: Save test results
# if: ${{ steps.build-and-test.outcome != 'skipped' }}
# uses: actions/upload-artifact@v3
# with:
# name: ${{ matrix.name }}-results
# path: |
# TestResults/ResultBundle.zip

run-codegen-test-configurations:
runs-on: macos-latest
timeout-minutes: 20
name: Codegen Test Configurations - macOS
steps:
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: ${{ env.XCODE_VERSION }}
- name: Checkout Repo
uses: actions/checkout@v3
- name: Test Codegen Configurations
shell: bash
run: |
./scripts/run-test-codegen-configurations.sh -t
# CodegenTestConfigurations removed because source is not compatible with Sendable yet.

verify-frontend-bundle-latest:
runs-on: macos-latest
Expand Down Expand Up @@ -259,76 +247,4 @@ jobs:
id: run-cocoapods-integration-tests
uses: ./.github/actions/run-cocoapods-integration-tests

run-integration-tests:
runs-on: macos-13
needs: [tuist-generation, changes]
if: ${{ needs.changes.outputs.ios == 'true' }}
timeout-minutes: 20
name: Apollo Integration Tests - macOS
steps:
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: 15.2
- name: Checkout Repo
uses: actions/checkout@v3
- name: Setup Node 12.22.10
uses: actions/setup-node@v3
with:
node-version: 12.22.10
- name: Setup Upload Server
shell: bash
run: |
sudo chmod -R +rwx SimpleUploadServer
cd SimpleUploadServer && npm install && npm start &
- name: Setup Node 18.15.0
uses: actions/setup-node@v3
with:
node-version: 18.15.0
- name: Setup Subscription Server
shell: bash
run: |
sh ./scripts/install-apollo-server-docs-example-server.sh
cd ../docs-examples/apollo-server/v3/subscriptions-graphql-ws && npm start &
- name: Setup Star Wars Server
shell: bash
run: |
sh ./scripts/install-or-update-starwars-server.sh
cd ../starwars-server && npm start &
- name: Retrieve Build Cache
uses: actions/cache@v3
with:
path: |
./ApolloDev.xcodeproj
./ApolloDev.xcworkspace
./Derived/*
key: ${{ github.run_id }}-dependencies
fail-on-cache-miss: true
- name: Build and Test
uses: ./.github/actions/build-and-run-unit-tests
with:
destination: platform=macOS,arch=x86_64
scheme: ApolloServerIntegrationTests
test-plan: Apollo-IntegrationTestPlan
- name: Save xcodebuild logs
uses: actions/upload-artifact@v3
with:
name: macOS-Integration-logs
path: |
DerivedData/Logs/Build
- name: Save crash logs
uses: actions/upload-artifact@v3
with:
name: macOS-Integration-crashes
path: |
~/Library/Logs/DiagnosticReports
- name: Zip Result Bundle
shell: bash
working-directory: TestResults
run: |
zip -r ResultBundle.zip ResultBundle.xcresult
- name: Save test results
uses: actions/upload-artifact@v3
with:
name: macOS-Integration-results
path: |
TestResults/ResultBundle.zip
# IntegrationTests removed because source is not compatible with Sendable yet.
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,6 @@ class SelectionSetTemplate_LocalCacheMutationTests: XCTestCase {
public var animalDetails: AnimalDetails {
get { _toFragment() }
_modify { var f = animalDetails; yield &f; __data = f.__data }
@available(*, unavailable, message: "mutate properties of the fragment instead.")
set { preconditionFailure() }
}
"""

Expand Down Expand Up @@ -381,8 +379,6 @@ class SelectionSetTemplate_LocalCacheMutationTests: XCTestCase {
public var animalDetails: AnimalDetails? {
get { _toFragment() }
_modify { var f = animalDetails; yield &f; if let newData = f?.__data { __data = newData } }
@available(*, unavailable, message: "mutate properties of the fragment instead.")
set { preconditionFailure() }
}
"""

Expand Down
2 changes: 1 addition & 1 deletion Tests/ApolloCodegenTests/TestHelpers/IRMatchers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ extension Nimble.Matcher {
func mappingActualTo<U>(
_ actualMapper: @escaping ((U?) throws -> T?)
) -> Nimble.Matcher<U> {
Nimble.Matcher<U>.define { (actual: Expression<U>) in
Nimble.Matcher<U>.define { (actual: Nimble.Expression<U>) in
let newActual = actual.cast(actualMapper)
return try self.satisfies(newActual)
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/ApolloInternalTestHelpers/XCTestCase+Helpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ extension StoreLoading where Self: XCTestCase {
operation: Operation,
file: StaticString = #filePath,
line: UInt = #line,
resultHandler: @escaping AsyncResultObserver<GraphQLResult<Operation.Data>, Error>.ResultHandler
resultHandler: @escaping AsyncResultObserver<GraphQLResult<Operation.Data>, any Error>.ResultHandler
) {
let resultObserver = makeResultObserver(for: operation, file: file, line: line)

Expand Down
4 changes: 0 additions & 4 deletions Tests/ApolloTests/Cache/ReadWriteFromStoreTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1051,8 +1051,6 @@ class ReadWriteFromStoreTests: XCTestCase, CacheDependentTesting, StoreLoading {
var givenFragment: GivenFragment {
get { _toFragment() }
_modify { var f = givenFragment; yield &f; __data = f.__data }
@available(*, unavailable, message: "mutate properties of the fragment instead.")
set { preconditionFailure() }
}
}
}
Expand Down Expand Up @@ -1204,8 +1202,6 @@ class ReadWriteFromStoreTests: XCTestCase, CacheDependentTesting, StoreLoading {
var givenFragment: GivenFragment? {
get { _toFragment() }
_modify { var f = givenFragment; yield &f; if let newData = f?.__data { __data = newData } }
@available(*, unavailable, message: "mutate properties of the fragment instead.")
set { preconditionFailure() }
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions Tests/CodegenCLITests/Matchers/ErrorMatchers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Nimble

public func throwUserValidationError(
_ expectedError: ValidationError
) -> Nimble.Matcher<ParsableCommand> {
) -> Nimble.Matcher<any ParsableCommand> {
return Matcher { actualExpression in
var actualError: (any Error)?
do {
Expand Down Expand Up @@ -41,7 +41,7 @@ public func throwUserValidationError(
}
}

public func throwUnknownOptionError() -> Nimble.Matcher<ParsableCommand> {
public func throwUnknownOptionError() -> Nimble.Matcher<any ParsableCommand> {
return Matcher { actualExpression in
var actualError: (any Error)?
do {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -559,8 +559,6 @@ struct SelectionSetTemplate {
"if let newData = f?.__data { __data = newData }",
else: "__data = f.__data"
) }
@available(*, unavailable, message: "mutate properties of the fragment instead.")
set { preconditionFailure() }
}
""",
else: " _toFragment() }"
Expand Down
Loading
Loading