WordPress-iOS
WordPress-iOS copied to clipboard
Add `import`s required to compile Keystone for testing
Description
This PR adds a number of import statement that seem necessary to build Keystone for testing. Without them, on my machine, the build fails.
I landed on this PR via two different streams of work:
- The idea of renaming
WordPressUnitTests.xctestplantoKeystoneTests.xctestplanfor clarity (not yet open as a PR) - The work to remove the workspace (#24534) which required building and running tests for each framework target to identify issues in the migration
With both, I wanted to build Keystone for testing (Shift Cmd U), and got compilation failures. Many iterations later, all the required imports are in place.
The reason we never noticed despite having a CI step to run Keystone tests is that the scheme was not (never was? ๐ค ) configured to run tests
This has now been rectified.
Testing instructions
| 1 Message | |
|---|---|
| :book: | This PR is still a Draft: some checks will be skipped. |
Generated by :no_entry_sign: Danger
๐ฒ You can test the changes from this Pull Request in Jetpack by scanning the QR code below to install the corresponding build.
| App Name | Jetpack | |
| Configuration | Release-Alpha | |
| Build Number | 28006 | |
| Version | PR #24537 | |
| Bundle ID | com.jetpack.alpha | |
| Commit | e76609c4b2943ff8e2f75f4c51f3fd56e42fbe34 | |
| Installation URL | 1c4kd1c0obkvg |
๐ฒ You can test the changes from this Pull Request in WordPress by scanning the QR code below to install the corresponding build.
| App Name | WordPress | |
| Configuration | Release-Alpha | |
| Build Number | 28006 | |
| Version | PR #24537 | |
| Bundle ID | org.wordpress.alpha | |
| Commit | e76609c4b2943ff8e2f75f4c51f3fd56e42fbe34 | |
| Installation URL | 5hr3c9isg71rg |
Quality Gate passed
Issues
0 New issues
0 Accepted issues
Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code
Version 26.1 has now entered code-freeze, so the milestone of this PR has been updated to 26.2.
@claude review
Claude finished @wzieba's task โโ View job
Code Review for PR #24537
Tasks
- [x] Read repository guidelines (CLAUDE.md)
- [x] Examine PR diff and understand scope of changes
- [x] Review build configuration changes
- [x] Review import statement changes
- [x] Review removed preprocessor directives
- [x] Check for code quality issues
- [x] Check for potential security concerns
- [x] Check for performance implications
- [x] Provide comprehensive feedback
Summary
This PR successfully addresses the issue of building Keystone for testing by adding necessary imports and cleaning up the codebase. The changes are well-structured and follow good practices for modular Objective-C development.
Key Changes
- CI Infrastructure - Added reusable test script and proper Keystone test configuration
- Import Cleanup - Systematically addressed missing imports across ~100 files
- Removed Preprocessor Directives - Eliminated all
#ifdef KEYSTONEconditionals (270 deletions!) - Code Organization - Moved WordPressData-related extensions to their proper module
- Header Optimization - Used forward declarations instead of imports in ObjC headers
Detailed Review
โ Strengths
1. Build Configuration (.buildkite/ changes)
- The new
run-unit-tests-for-scheme.shscript is clean and reusable - Proper integration into the CI pipeline for both Keystone and WordPressData tests
- Good error handling with
set -euo pipefail
2. Import Strategy The evolution visible in commits shows thoughtful iteration:
- Started with angle bracket imports when modular imports had issues
- Discovered the issues were transitional
- Restored modular imports where appropriate
- Used forward declarations in headers (best practice)
3. Code Organization
Moving these files to Sources/WordPressData/Swift improves modularity:
RemotePost+Metadata.swiftRemotePostUpdateParameters+Helpers.swiftWordPressOrgRestApi+WordPress.swift
4. Preprocessor Cleanup
Removing all #ifdef KEYSTONE conditionals is excellent - these were technical debt that made the codebase harder to understand and maintain.
5. Swift Files
All Swift files that needed import WordPressData have been properly updated. The imports are clean and minimal.
๐ Observations & Questions
1. Objective-C Header Pattern
The final approach uses forward declarations (@class, @protocol) in .h files rather than imports. This is actually the recommended Objective-C pattern as it:
- Reduces compilation dependencies
- Improves build times
- Prevents circular dependencies
This is cleaner than either @import or #import in headers. Good decision!
2. Scheme Configuration
The PR description mentions fixing the Keystone scheme to actually run tests (shown in the screenshot with "error: Scheme Keystone is not currently configured for the test action"). However, I don't see the .xcscheme file changes in the PR. Could you confirm:
- Was
WordPress.xcodeproj/xcshareddata/xcschemes/Keystone.xcschememodified? - If so, is this change included in the commits?
3. Test Coverage Since this PR enables Keystone tests that weren't running before, have you:
- Verified all Keystone tests pass?
- Identified any tests that were broken but not noticed because they weren't running?
๐ Security
No security concerns identified. The changes are purely build configuration and import statements.
โก Performance
Positive impacts:
- Using forward declarations in headers will improve compilation times
- Removing unused
#ifdefconditionals reduces preprocessor overhead - Cleaner module boundaries should help with link-time optimization
๐งช Testing
The PR enables Keystone tests in CI, which is the main goal. However:
- Consider adding a comment in the CI config explaining what Keystone tests are and why they're separate
- The new
run-unit-tests-for-scheme.shscript could benefit from a header comment explaining its purpose
๐ Documentation
Minor suggestions:
- Add a brief comment at the top of
run-unit-tests-for-scheme.shexplaining what it does - Consider updating the PR description with the actual scheme file changes (if included)
๐ฏ Code Quality
Overall code quality is excellent. The changes are:
- Systematic and consistent
- Well-organized across multiple logical commits
- Follow Objective-C best practices
- Improve maintainability by removing conditionals
Minor Suggestions
-
Script Flexibility - Consider making device/OS version configurable in
run-unit-tests-for-scheme.sh(see inline comment) -
Commit History - The commit history tells a great story of iterative problem-solving. Consider preserving this rather than squashing, as it's educational for future readers.
-
File Moves - The moves to
Sources/WordPressData/Swiftare correct, but verify that any internal documentation or developer guides referencing these files are updated.
Recommendation
โ Approve with minor suggestions
This is solid work that fixes a real build issue and improves code organization. The iterative approach visible in the commits shows good problem-solving methodology. The main deliverable (Keystone builds and tests run) appears to be achieved.
The inline comments I've left are mostly positive observations and minor suggestions - none are blocking issues.
Great job on the cleanup! The removal of 270 lines of #ifdef KEYSTONE conditionals alone makes the codebase more maintainable. ๐
Note: I've left several inline comments on specific files with detailed feedback.
โ๏ธ just testing Claude Reviews
Hey, this is pretty cool! I'd probably try a different, more "standard" PR that has no infrastructure changes. I can volunteer any of my PRs, for example this one.
Good refactoring!
Let's cut the "Great addition!", "Good refactoring!" and other congratulatory stuff. Similarly, in the "Observations" sections, none seem to add value.
โ Approve with minor suggestions
It can't approve or disapprove โ just make suggestions.
Commit History - The commit history tells a great story of iterative problem-solving. Consider preserving this rather than squashing, as it's educational for future readers.
File Moves - The moves to Sources/WordPressData/Swift are correct, but verify that any internal documentation or developer guides referencing these files are updated.
I'd keep the minor suggestions out of it. Both of these don't make much sense in our context: the PRs are squashed and there are no "developer guides". It needs to focus on what it considers "critical" that you have to fix before merging โ any potentials regressions, defects, serious issues for code maintainability โ and it keep it as concise as possible.
Thanks for the comments on the solution @kean ! Please, feel free to edit the instructions yourself in https://github.com/wordpress-mobile/WordPress-iOS/blob/6e614e3f53a128c0440822ecdb72db54790336ac/.github/workflows/claude-review.yml#L27 . The current prompt is default from Claude Code repository. I think each team should align this to their own needs/likings/preferences.
free to edit the instructions yourself
Gotcha. Thanks!