Skip to content

feat: extend the BuildAction to allow setting the architecture #261

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mbentin-cko
Copy link

@mbentin-cko mbentin-cko commented Aug 1, 2025

Add a parameter in the BuildAction to be able to set the architecture strategy for the scheme.

Summary by CodeRabbit

  • New Features

    • Added a new option to specify build architectures for build actions, allowing selection between matching the run destination, universal, or using target settings.
  • Tests

    • Introduced tests to ensure the new build architectures option supports correct encoding and decoding.

@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. enhancement New feature or request labels Aug 1, 2025
@mbentin-cko
Copy link
Author

@coderabbitai review

Copy link

coderabbitai bot commented Aug 5, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link

coderabbitai bot commented Aug 5, 2025

Walkthrough

A new nested enum Architectures was introduced inside the BuildAction extension, supporting three cases and conforming to multiple protocols. The BuildAction struct was updated to include an overrideArchitectures property and an updated initializer. A new test verifies the codability of the Architectures enum.

Changes

Cohort / File(s) Change Summary
Architectures Enum Addition
Sources/XcodeGraph/Models/BuildAction+Architectures.swift
Added nested Architectures enum to BuildAction extension with three cases and protocol conformances.
BuildAction Struct Update
Sources/XcodeGraph/Models/BuildAction.swift
Added overrideArchitectures property and updated initializer in BuildAction to support the new enum.
Architectures Enum Test
Tests/XcodeGraphTests/Models/BuildAction.ArchitecturesTests.swift
Introduced a test class to verify Codable conformance of the Architectures enum.

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant BuildAction

  Caller->>BuildAction: Initialize BuildAction(targets, ..., overrideArchitectures)
  BuildAction-->>Caller: BuildAction instance with overrideArchitectures property
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

In the garden of code, new enums bloom bright,
Architectures nested, a coder’s delight.
BuildActions now stronger, with settings to choose,
And tests hop along, ensuring no bruise.
🐇✨
With each little change, our project takes flight!

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

🪧 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.
    • Explain this complex logic.
    • 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 explain this code block.
  • 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 explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests 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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
Sources/XcodeGraph/Models/BuildAction+Architectures.swift (1)

1-7: Well-designed enum with appropriate protocol conformance.

The Architectures enum is cleanly implemented with descriptive case names and proper protocol conformance. The extension pattern keeps the code organized.

Consider adding documentation comments to improve API discoverability:

extension BuildAction {
+    /// Architecture configuration options for build actions
    public enum Architectures: Equatable, Codable, Sendable {
+        /// Match the architecture of the run destination
        case matchRunDestination
+        /// Build for all supported architectures
        case universal
+        /// Use the target's architecture settings
        case useTargetSettings
    }
}
Sources/XcodeGraph/Models/BuildAction.swift (1)

38-46: Update DEBUG test helper to include new parameter.

The test helper method doesn't include the new overrideArchitectures parameter, which could lead to inconsistent behavior between production and test code.

extension BuildAction {
    public static func test(
        // swiftlint:disable:next force_try
        targets: [TargetReference] = [TargetReference(projectPath: try! AbsolutePath(validating: "/Project"), name: "App")],
        preActions: [ExecutionAction] = [],
-        postActions: [ExecutionAction] = []
+        postActions: [ExecutionAction] = [],
+        overrideArchitectures: Architectures = .useTargetSettings
    ) -> BuildAction {
-        BuildAction(targets: targets, preActions: preActions, postActions: postActions)
+        BuildAction(targets: targets, preActions: preActions, postActions: postActions, overrideArchitectures: overrideArchitectures)
    }
}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7922bd0 and 51e6bf7.

📒 Files selected for processing (3)
  • Sources/XcodeGraph/Models/BuildAction+Architectures.swift (1 hunks)
  • Sources/XcodeGraph/Models/BuildAction.swift (2 hunks)
  • Tests/XcodeGraphTests/Models/BuildAction.ArchitecturesTests.swift (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
Tests/XcodeGraphTests/Models/BuildAction.ArchitecturesTests.swift (1)
Tests/XcodeGraphTests/Extensions/XCTestCase+Extras.swift (1)
  • XCTAssertCodable (4-14)
🔇 Additional comments (2)
Sources/XcodeGraph/Models/BuildAction.swift (2)

13-13: LGTM! Property addition follows existing patterns.

The new overrideArchitectures property is correctly implemented and maintains consistency with other properties in the struct.


23-25: LGTM! Initializer update maintains backward compatibility.

The initializer correctly includes the new parameter with an appropriate default value that preserves existing behavior.

Also applies to: 32-32

Comment on lines +6 to +14
final class BuildActionArchitecturesTests: XCTestCase {
func test_codable() {
// Given
let subject = BuildAction.Architectures.universal

// Then
XCTAssertCodable(subject)
}
}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Expand test coverage for all enum cases.

The test correctly verifies Codable conformance but only covers the .universal case. Consider testing all cases to ensure comprehensive coverage.

final class BuildActionArchitecturesTests: XCTestCase {
    func test_codable() {
-        // Given
-        let subject = BuildAction.Architectures.universal
-
-        // Then
-        XCTAssertCodable(subject)
+        // Test all cases for Codable conformance
+        XCTAssertCodable(BuildAction.Architectures.matchRunDestination)
+        XCTAssertCodable(BuildAction.Architectures.universal)
+        XCTAssertCodable(BuildAction.Architectures.useTargetSettings)
+    }
+    
+    func test_equatable() {
+        XCTAssertEqual(BuildAction.Architectures.universal, BuildAction.Architectures.universal)
+        XCTAssertNotEqual(BuildAction.Architectures.universal, BuildAction.Architectures.matchRunDestination)
+        XCTAssertNotEqual(BuildAction.Architectures.universal, BuildAction.Architectures.useTargetSettings)
    }
}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
final class BuildActionArchitecturesTests: XCTestCase {
func test_codable() {
// Given
let subject = BuildAction.Architectures.universal
// Then
XCTAssertCodable(subject)
}
}
final class BuildActionArchitecturesTests: XCTestCase {
func test_codable() {
// Test all cases for Codable conformance
XCTAssertCodable(BuildAction.Architectures.matchRunDestination)
XCTAssertCodable(BuildAction.Architectures.universal)
XCTAssertCodable(BuildAction.Architectures.useTargetSettings)
}
func test_equatable() {
XCTAssertEqual(BuildAction.Architectures.universal, BuildAction.Architectures.universal)
XCTAssertNotEqual(BuildAction.Architectures.universal, BuildAction.Architectures.matchRunDestination)
XCTAssertNotEqual(BuildAction.Architectures.universal, BuildAction.Architectures.useTargetSettings)
}
}
🤖 Prompt for AI Agents
In Tests/XcodeGraphTests/Models/BuildAction.ArchitecturesTests.swift between
lines 6 and 14, the Codable test only covers the .universal case of the
BuildAction.Architectures enum. To fix this, expand the test to iterate over all
enum cases and verify Codable conformance for each one, ensuring comprehensive
test coverage of all possible values.

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.

Hey 👋

First of all, sorry for taking longer to review this PR.

I believe we will also need a PR in tuist/tuist. It would be great to prepare that before merging this one as that would help us do a better review here.

@mbentin-cko
Copy link
Author

Hi @fortmarek,
no worries for the delay!
I was wondering if you would suggest to follow the nitpick suggestions of coderabbitai?

I will start to work on the tuist PR then.

@mbentin-cko mbentin-cko changed the title feat: Extend the BuildAction to allow setting the architecture feat: extend the BuildAction to allow setting the architecture Aug 13, 2025
Comment on lines +2 to +6
public enum Architectures: Equatable, Codable, Sendable {
case matchRunDestination
case universal
case useTargetSettings
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's not add types in extensions to keep ease symbol resolution to the compiler.

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Aug 14, 2025
@pepicrft
Copy link
Contributor

@mbentin-cko you can ignore those. I'd focus on adding the tuist/tuist counterpart.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request lgtm This PR has been approved by a maintainer size:S This PR changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants