Skip to content

[INJIMOB-3794] refactor: update test_executable finding logic#306

Open
KiruthikaJeyashankar wants to merge 1 commit intomosip:developfrom
tw-mosip:modify-swift-sonar-flow
Open

[INJIMOB-3794] refactor: update test_executable finding logic#306
KiruthikaJeyashankar wants to merge 1 commit intomosip:developfrom
tw-mosip:modify-swift-sonar-flow

Conversation

@KiruthikaJeyashankar
Copy link
Copy Markdown
Contributor

@KiruthikaJeyashankar KiruthikaJeyashankar commented Mar 6, 2026

  • Previous logic sometimes finds framework's test executable as its test executable which results in 0 test coverage
  • To avoid this issue of flakiness, test executable finding logic has been updated to find the library's scheme tests

Summary by CodeRabbit

  • Chores
    • Improved CI build configuration to use a centralized derived-data path variable.
    • Made test and coverage discovery in CI more reliable by using the centralized path, reducing hardcoded path issues and improving maintainability.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 6, 2026

Walkthrough

Adds a DERIVED_DATA variable to .github/workflows/swift-sonar-analysis.yml and replaces hardcoded .build/DerivedData references with $DERIVED_DATA in test bundle discovery, test executable lookup, and coverage path resolution.

Changes

Cohort / File(s) Summary
GitHub Actions workflow
.github/workflows/swift-sonar-analysis.yml
Introduce DERIVED_DATA='.build/DerivedData' and update TEST_BUNDLE, TEST_EXECUTABLE, and COVERAGE_PATH lookups to use $DERIVED_DATA instead of hardcoded .build/DerivedData. Adjust test executable discovery to search $DERIVED_DATA/Build/Products for .xctest and reconstruct executable path from the bundle name.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 Soft steps along the build tree’s way,
I found the path and named it, hip hooray!
DERIVED_DATA hops in — neat and spry,
No more hardcoded trails to pry.
A tiny change, but tidy as a tray.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: refactoring the test_executable finding logic to fix the issue where framework test executables were incorrectly identified as library test executables, resulting in zero test coverage.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@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: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/swift-sonar-analysis.yml:
- Around line 84-89: The script currently finds TEST_EXECUTABLE by scanning
Build/Products again which can pick the wrong test bundle; instead derive the
executable directly from the already-found TEST_BUNDLE to guarantee it matches
the scheme under test. Replace the second find and subsequent construction with
computing TEST_EXECUTABLE from TEST_BUNDLE (e.g. set
TEST_EXECUTABLE="$TEST_BUNDLE/$(basename "$TEST_BUNDLE" .xctest)" or the
bundle's Contents/MacOS/<basename> as appropriate), and keep COVERAGE_PATH
lookup as-is; update references to TEST_EXECUTABLE, TEST_BUNDLE, and
COVERAGE_PATH accordingly.
- Around line 87-88: The basename rewrite unconditionally runs even when
TEST_EXECUTABLE is empty, producing a bogus non-empty value; modify the workflow
so the second assignment that appends "/$(basename ...)" is performed only if
TEST_EXECUTABLE is non-empty—i.e., check [ -n "$TEST_EXECUTABLE" ] (or
equivalent) before performing the basename rewrite on TEST_EXECUTABLE to
preserve the later existence check; reference the TEST_EXECUTABLE variable and
the two lines that set it.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 41fba56e-bc55-4979-9d21-738f732a4f5a

📥 Commits

Reviewing files that changed from the base of the PR and between eb0ab2b and 98347d8.

📒 Files selected for processing (1)
  • .github/workflows/swift-sonar-analysis.yml

Comment thread .github/workflows/swift-sonar-analysis.yml
Comment thread .github/workflows/swift-sonar-analysis.yml Outdated
- Previous logic sometimes finds framework's test executable as its test executable which results in 0 test coverage
- To avoid this issue of flakiness, test executable finding logic has been updated to find the library's scheme tests

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>
Copy link
Copy Markdown

@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.

🧹 Nitpick comments (1)
.github/workflows/swift-sonar-analysis.yml (1)

84-84: Consider quoting $DERIVED_DATA for defensive shell scripting.

While the current value contains no spaces, quoting the variable prevents subtle bugs if the path changes in the future.

-              TEST_BUNDLE=$(find $DERIVED_DATA -type d -name "*.xctest" | head -n 1)
+              TEST_BUNDLE=$(find "$DERIVED_DATA" -type d -name "*.xctest" | head -n 1)
-                COVERAGE_PATH=$(find $DERIVED_DATA -name "Coverage.profdata" | head -n 1)
+                COVERAGE_PATH=$(find "$DERIVED_DATA" -name "Coverage.profdata" | head -n 1)

Also applies to: 91-91

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/swift-sonar-analysis.yml at line 84, The find invocations
that use the shell variable DERIVED_DATA (e.g., the TEST_BUNDLE assignment line
"TEST_BUNDLE=$(find $DERIVED_DATA -type d -name \"*.xctest\" | head -n 1)")
should quote the variable to guard against spaces or special characters; update
the usages of $DERIVED_DATA (including the similar usage around line 91) to use
"$DERIVED_DATA" so the find command receives the full path as a single argument.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In @.github/workflows/swift-sonar-analysis.yml:
- Line 84: The find invocations that use the shell variable DERIVED_DATA (e.g.,
the TEST_BUNDLE assignment line "TEST_BUNDLE=$(find $DERIVED_DATA -type d -name
\"*.xctest\" | head -n 1)") should quote the variable to guard against spaces or
special characters; update the usages of $DERIVED_DATA (including the similar
usage around line 91) to use "$DERIVED_DATA" so the find command receives the
full path as a single argument.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c20b6157-ad51-4e73-b481-28ceb33fecf7

📥 Commits

Reviewing files that changed from the base of the PR and between 98347d8 and f0d10cf.

📒 Files selected for processing (1)
  • .github/workflows/swift-sonar-analysis.yml

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.

2 participants