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

feat: Add handling for Swift Testing Only Parallelization #871

Merged

Conversation

kelvinharron
Copy link
Contributor

Related to this Tuist issue

Short description 📝

This PR introduces XcodeProj Parallelization handling for the new Swift Testing option. This will enable us to expose the option to Tuist TestingOptions allowing users to specify the option they need, as the default handling in Xcode 16 for Parallelization is going to benefit the few users who have adopted Swift Testing.

I also removed two dead links from the References section as I was going through the reading material.

Solution 📦

From changing the values manually in a real project, I gathered:

Parallelization off in Xcode ->"parallelizable" : false,
Parallelization on in Xcode ->"parallelizable" : true,
Parallelization Swift Testing Only in Xcode -> no value.

With guidance from @fortmarek , I updated the handling of the attributes to cover each individual case.

I've set it as draft as I need guidance on how to prove this handling outside of unit tests. Please let me know what I could be missing and how to verify the output. Thanks.

Implementation 👩‍💻👨‍💻

  • Introduce enums to cover the three unique cases
  • Add handling for each case from.
  • Update tests to handle each case.

Copy link
Member

@fortmarek fortmarek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the PR! Some minor comments, but overall looks good 🤞

Sources/XcodeProj/Scheme/XCScheme+TestableReference.swift Outdated Show resolved Hide resolved
Sources/XcodeProj/Scheme/XCScheme+TestableReference.swift Outdated Show resolved Hide resolved
Tests/XcodeProjTests/Scheme/XCSchemeTests.swift Outdated Show resolved Hide resolved
@kelvinharron kelvinharron marked this pull request as ready for review October 19, 2024 01:20
Copy link
Member

@fortmarek fortmarek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small nits, after those are resolved, we can merge this 🤞

Sources/XcodeProj/Scheme/XCScheme+Parallelizable.swift Outdated Show resolved Hide resolved
Tests/XcodeProjTests/Scheme/XCSchemeTests.swift Outdated Show resolved Hide resolved
Copy link
Member

@fortmarek fortmarek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Before we merge, can you open a draft PR that updates XcodeGraph in tuist/tuist with this branch, so we can test things E2E there?

@fortmarek
Copy link
Member

@kelvinharron we can merge this one once the CI is green ✅

Copy link
Collaborator

@kwridan kwridan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @kelvinharron

@@ -6,7 +6,7 @@ public extension XCScheme {
// MARK: - Attributes

public var skipped: Bool
public var parallelizable: Bool
public var parallelizable: Parallelizable
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may constitute as breaking change :/

Options:

  • Introduce a new type parallelizableValue: Parallelizable (or some better name 😅) and keep parallelizable: Bool as a Bool + mark deprecated - it can translate the to and from underlying enum property
  • Ensure a major version is released of XcodeProj

Interesting ideas but may not be sufficient:

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's worth investigating using the ExpressibleByBooleanLiteral to make the migration easier. Technically speaking, it won't be sufficient, so let's make a new major version of XcodeProj. I think for this library, having major versions more often than let's say for the Tuist CLI is fine.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if we do something like

@available(...) -> Deprecate with a warn
public var parallelizable: Bool { ... } // as-is

public var parallelization: TestParallelization { ... }

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 this gets it a bit closer to the nomenclature in the Xcode UI

Screenshot 2024-11-28 at 08 09 46

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @kelvinharron - what do you think about this ?
If you want an extra hand I'm happy to finalize this PR so we can land it into XcodeProj. LMK!
Thanks :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback @kwridan, keep me right on the most recent changes as it feels a little loose with two properties. This PR extends more so than replaces now, so we're handling both mapping functions from attributes and inits as before, with the introduction of TestParallelization option.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The var parallelizable can be a computed property over the enum swiftTestingOnly (which is the default case today, right?)

@available(...) -> Deprecate with a warn
public var parallelizable: Bool { 
    get { parallelization == .swiftTestingOnly }
    set { parallelization = newValue ? swiftTestingOnly : .none }
}

public var parallelization: TestParallelization { ... }

that way it's just a backward-compatiblemirror. WDYT?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm onboard with that 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ace @freak4pc. I've updated and added some tests to reason about the computed var behaviour. Please take a look and let me know if that's expected.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kwridan @fortmarek let me know if you have any additional feedback and I can close this out. I think we're encountering some failures on CI with these changes I can look at.

Copy link

@freak4pc freak4pc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! I don't have merge / write access but took a quick peek anyways :)

@freak4pc
Copy link

freak4pc commented Dec 1, 2024

Anything preventing us from moving forward? Would love to have swift-testing at our disposal :D
@kwridan @fortmarek

Copy link
Member

@fortmarek fortmarek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good! I'd wait with the merge until the Tuist PR counterpart is approved as well: tuist/tuist#6898

self.skippedTests = skippedTests
}

@available(*, deprecated, message: "Use init with Parallelization argument instead")
public init(skipped: Bool,
parallelizable: Bool = false,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove the default value, so the deprecation warning is triggered only when parallelizable is specified.

@kelvinharron
Copy link
Contributor Author

This looks good! I'd wait with the merge until the Tuist PR counterpart is approved as well: tuist/tuist#6898

Thanks Marek. I still haven't found a way to reliably prove out the tests for that PR meaning its a non starter. @freak4pc care to look at the PR and see if you have any ideas? Some more context on Slack here.

@kwridan
Copy link
Collaborator

kwridan commented Dec 3, 2024

@all-contributors add @kelvinharron for code

Copy link
Contributor

@kwridan

I've put up a pull request to add @kelvinharron! 🎉

@fortmarek
Copy link
Member

Thanks Marek. I still haven't found a way to reliably prove out the tests for that PR meaning its a non starter. @freak4pc care to look at the PR and see if you have any ideas?

I don't have extra ideas apart from what I posted. Feel free to simplify the acceptance test if needed.

However, I think we can merge this one without having a Tuist acceptance test in place once the CI is ✅

@pepicrft pepicrft changed the title Add handling for Swift Testing Only Parallelization feat: Add handling for Swift Testing Only Parallelization Dec 3, 2024
@pepicrft pepicrft force-pushed the add-swifttesting-parallelizable-handling branch from 411947a to 0926e9d Compare December 3, 2024 16:45
@pepicrft pepicrft merged commit b907392 into tuist:main Dec 3, 2024
5 of 6 checks passed
@pepicrft
Copy link
Contributor

pepicrft commented Dec 3, 2024

@kelvinharron your changes are now part of XcodeProj 8.25.0

@kelvinharron
Copy link
Contributor Author

@kelvinharron your changes are now part of XcodeProj 8.25.0

Fantastic. Thank you for tidying this up and for everyone's feedback. My next change will be measured in days, not weeks and months 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants