Skip to content

[Tooling] Test fastlane trainer refactoring for Swift Testing support #15241

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

Closed
wants to merge 8 commits into from

Conversation

AliSoftware
Copy link
Contributor

@AliSoftware AliSoftware commented Feb 22, 2025

Important

Do not merge

This is to test some work I'm doing on fastlane to make trainer support parsing .xcresult bundles that reports test results of tests implemented with Swift Testing (since as of today it seems that trainer only supports test results from XCTests?)

@dangermattic
Copy link
Collaborator

dangermattic commented Feb 22, 2025

1 Message
📖 This PR is still a Draft: some checks will be skipped.

Generated by 🚫 Danger

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Feb 22, 2025

WooCommerce iOS📲 You can test the changes from this Pull Request in WooCommerce iOS by scanning the QR code below to install the corresponding build.

App NameWooCommerce iOS WooCommerce iOS
Build Numberpr15241-fb6abda
Version21.7
Bundle IDcom.automattic.alpha.woocommerce
Commitfb6abda
App Center BuildWooCommerce - Prototype Builds #13306
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

@AliSoftware AliSoftware force-pushed the trainer-swift-testing branch from 1b106ef to 41e9322 Compare February 24, 2025 05:02
@AliSoftware
Copy link
Contributor Author

AliSoftware commented Feb 24, 2025

cc @mokagio so you dont rush updating all the repos with the trainer workaround we've been trying on WCiOS, given said workaround is likely to not work after all, and might have just returned us to the status quo.

In other words, the workaround might still hide the same failures, especially from tests written in Swift Testing; and the first iteration of the hack looked like it fixed it bc it made the CI go red… but that was misleading (as it was reporting retries)… then the second iteration of the workaround probably returned us to the same behavior as before the hack, since run_tests already uses the Trainer's class implementation internally to report test failure or success, so reading the hash it returns is the same as reading trainer's returned hash already.

Instead, this PR is adopting the implementation of my refactoring of fastlane's trainer to use the new way of parsing the .xcresult files, using the modern Xcode 16+ version of xcresulttool, to support Swift Testing, instead of relying on --legacy like run_tests and trainer are currently doing). This will hopefully be a safer solution by ensuring it detects SwiftTesting failures reported in the .xcresult file and not just XCTest failures. It seems to work with a demo project I've crafted as well as with WCiOS (though I'd love to do more testing on it to account for all possible edge cases people could encounter).

@AliSoftware
Copy link
Contributor Author

AliSoftware commented Feb 24, 2025

Note that:

  • This PR was cut from a version of trunk before the workaround was applied, so it does not rely on it
  • The "Unit Tests" job is expected to fail, and report 2 failures:
    • one from test_it_returns_days_if_the_dates_are_between_two_and_seven_days_apart() in AgeTests, an XCTest, run 3 times and failed on each of its retries
    • one from itemsInCartLabel(_:_:) in CartViewHelperTests, which is a @Test(arguments:…) parametrized SwiftTesting test, and is expected to fail (with 3 retries) in only 1 of the 4 different arguments being tested
  • Since the run-unit-tests.sh script uses annotate_test_failures, those 2 errors are expected to be reported in Buildkite Annotation1. Though since annotate_test_failures was not implemented with SwiftTesting arguments feature in mind, it will consider the test to be flaky (because it failed 1 run but passed the other 3, and it didn't distinguish tests with different argument properties2).
  • Buildkite Test Analytics will still only see 1 failure out of the 2 tests, because Buildkite's TestCollector Swift package only supports XCTest but not SwiftTesting
image

Footnotes

  1. That made me remember why we used trainer in the first place after all, it was probably for this annotation

  2. That makes me think that maybe I should include the name of the arguments in parentheses in the test name when I make trainer generate the XML, so most tools reading the JUnit file (be it our annotate_test_failures or Buildkite's TestEngine if we upload the XML to it instead of using their TestCollector package) would consider them different test cases…

Distinguishing test cases with ≠ args
@AliSoftware
Copy link
Contributor Author

AliSoftware commented Feb 24, 2025

Update: I made the fix in trainer to generate different <testcase name=…> for test case runs that took different arguments, and now they're treated properly by annotate_test_failure (and so should they by other tools like TestAnalytics too)

image

@AliSoftware
Copy link
Contributor Author

Created the PR in fastlane to propose my refactoring of trainer supporting SwiftTesting for review: fastlane/fastlane#29463

Copy link

coderabbitai bot commented Mar 13, 2025

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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.

3 participants