Skip to content

coverage: apple post action merges xcodebuild raw profiles - #14509

Draft
TrapsterDK wants to merge 4 commits into
mainfrom
cloud/14350
Draft

TrapsterDK wants to merge 4 commits into
mainfrom
cloud/14350

Conversation

@TrapsterDK

@TrapsterDK TrapsterDK commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

Pull Request

Linked Issue

Closes #14350

Changes

  • macOS evidence run 44870960039 (ledger_app_test/test.log) shows that xcodebuild writes no Coverage.profdata for rules_apple to copy. It leaves the test host's raw profile at TEST_TMPDIR/test_tmp_dir.*/<simulator>/<uuid>-<pid>.profraw, and TEST_BINARIES_FOR_LLVM_COV is set.
  • tools/coverage/collect/src/apple_post.rs: when Coverage.profdata is missing, the post action now merges every .profraw under TEST_TMPDIR and exports LCOV from that. If there is no profdata and no profraw, it still writes an empty report and says so.
  • Raw profiles merge with xcrun llvm-profdata. Evidence run 44912255171 showed Xcode's runtime writes raw profile version 10, and the pinned llvm-profdata, which expects version 11, rejects it. Coverage.profdata still merges with the pinned tool, and llvm-cov export still uses the pinned llvm-cov.
  • apple/private/ios/app.bzl: the app's Rust library now builds through no_coverage_transition. Evidence run 44926835784 failed with malformed instrumentation profile data: number of counters is zero. An instrumented Rust staticlib carries rustc's own profile runtime and counters next to Xcode's, so the mixed raw profile cannot be read. Swift sources keep their coverage, and Rust code gets coverage from its own tests.
  • Unit tests for raw_profiles, merge_program and the updated message.

Verification

Tested: //tools/coverage/collect:collect_native_test passed (linux_x86_64) at bf6ca27. At eea0a6c, bazel test //apple/tests:all passed on linux_x86_64 (79 pass, 11 macOS-only skipped). tools/dx check --apply on apple_post.rs and apple/private/ios/app.bzl reported no findings.

Evidence (macos_arm64, coverage //apple/tests/fixtures/swift_app/...): a run on eea0a6c is requested below. Draft until it reports non-empty LCOV for LedgerKit.swift.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Xut2hwAeheE4jLsoV6UTxj

Copy link
Copy Markdown
Collaborator Author

/evidence platforms=["macos_arm64"] task=coverage scope=//apple/tests/fixtures/swift_app/...


Generated by Claude Code

@github-actions

Copy link
Copy Markdown
Contributor

Evidence started on cloud/14350: https://github.com/devhusdk/rules_dx/actions/runs/44912255171

@TrapsterDK
TrapsterDK marked this pull request as ready for review November 21, 2026 14:07
@TrapsterDK TrapsterDK added the train Tested; land via merge train label Nov 21, 2026 — with Claude

Copy link
Copy Markdown
Collaborator Author

The analysis failure isn't from this PR. It is the dx_crates lockfile digest check (Current Digest("7440405e…") != Expected Digest("56870eb4…")). On plain main 8c9c770, bazel mod show_repo --lockfile_mode=error --repo_env=CARGO_BAZEL_DIGEST_CHECK=1 @crates @dx_quality_crates @dx_thrift_crates fails with the same two digests. This PR only changes tools/coverage/collect/src/apple_post.rs and touches no Cargo, lock or MODULE file. The fix needs a crate repin on main.


Generated by Claude Code

@TrapsterDK TrapsterDK removed the train Tested; land via merge train label Nov 21, 2026 — with Claude
@TrapsterDK
TrapsterDK marked this pull request as draft November 21, 2026 15:30

Copy link
Copy Markdown
Collaborator Author

/evidence platforms=["macos_arm64"] task=coverage scope=//apple/tests/fixtures/swift_app/...


Generated by Claude Code

@github-actions

Copy link
Copy Markdown
Contributor

Evidence started on cloud/14350: https://github.com/devhusdk/rules_dx/actions/runs/44926835784

Copy link
Copy Markdown
Collaborator Author

The affected tests (linux_x86_64, shard 1) failure isn't from this PR. It is //tools/testing:module_extension_srcs_test, which reports lua/private/lua_LICENSE.txt (referenced by lua/private/BUILD.bazel) missing from that package's module_srcs. The test fails the same way on plain main 8c9c770. This PR only changes tools/coverage/collect/src/apple_post.rs.


Generated by Claude Code

Copy link
Copy Markdown
Collaborator Author

Evidence run 44926835784 (macos_arm64, bf6ca27): xcrun llvm-profdata now accepts the format version of the raw profile, but rejects the profile itself:

.../test_tmp_dir.TXvSdY/<sim>/<uuid>-9557.profraw: malformed instrumentation profile data: number of counters is zero
error: no profile can be merged

My best guess is that ledger_app links Xcode's clang profile runtime (raw version 10) while the Rust objects come from rustc's newer LLVM with a different counter layout, so no single llvm-profdata can read the mixed file. Not confirmed. ledger_app_test now fails in coverage instead of passing with an empty report, so this PR stays draft without train.


Generated by Claude Code

Copy link
Copy Markdown
Collaborator Author

The affected tests (linux_x86_64, shard 0) failures aren't from this PR. //core/modules:consumer_deps_test (every_nested_lock_has_the_root_registry_deps) and //core/modules:versions_contract (every_bazel_dep_has_a_floor_comment_and_is_newest) fail the same way on plain main 8c9c770. I can't run the apple and dart consumer tests here, since nested Bazel rejects the proxy CA. They depend on the module and lock state, not on apple_post.rs. This PR only changes tools/coverage/collect/src/apple_post.rs.


Generated by Claude Code

Copy link
Copy Markdown
Collaborator Author

/evidence platforms=["macos_arm64"] task=coverage scope=//apple/tests/fixtures/swift_app/...


Generated by Claude Code

@github-actions

Copy link
Copy Markdown
Contributor

Evidence started on cloud/14350: https://github.com/devhusdk/rules_dx/actions/runs/45012057904

Copy link
Copy Markdown
Collaborator Author

Evidence run 45012057904 (eea0a6c): all 6 tests pass, and ledger_app_test/coverage.dat is now non-empty (5.6 KB). It covers LedgerKit.swift LH 22 of LF 24, main/LedgerAppDelegate.swift 24 of 26, and LedgerAppTests.swift 47 of 47. The run is still red because of dx's own summary, not the report:

dx: no executable lines in the owned sources of package macos_arm64 (coverage_below_minimum)
dx: coverage sources macos_arm64: 0 raw, 0 excluded, 0 eligible, 0 covered lines; 0 eligible, 4 support, 0 excluded, 1 unsupported files

So the source classification doesn't count the fixture's Swift files as eligible. That's the remaining step.


Generated by Claude Code

Copy link
Copy Markdown
Collaborator Author

The new failures in affected tests (linux_x86_64, shard 1) on eea0a6c also come from main. //tools/ci:starlark_docs_test (every_rule_aspect_and_attr_has_doc) and //tools/docs/languages:languages_test both fail on plain main 8c9c770. The other failures in that shard (versions_contract, consumer_deps_test, apple and dart consumer tests) are the ones noted above. eea0a6c only changes apple/private/ios/app.bzl.


Generated by Claude Code

claude and others added 4 commits November 23, 2026 12:54
…14350)

xcodebuild 16 leaves the test host's .profraw under
TEST_TMPDIR/<simulator>/ and writes no Coverage.profdata, so rules_apple
copies nothing and the report came out empty. When Coverage.profdata is
missing, the post action now merges every .profraw under TEST_TMPDIR.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Xut2hwAeheE4jLsoV6UTxj
…art of #14350)

macOS evidence showed Xcode's clang runtime writes raw profile version 10,
which the pinned llvm-profdata (version 11) rejects. Raw profiles now merge
through `xcrun llvm-profdata`; Coverage.profdata still uses the pinned tool.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Xut2hwAeheE4jLsoV6UTxj
Under coverage, an instrumented Rust staticlib carries rustc's own
profile runtime and counters next to Xcode's, and the app's raw profile
fails to merge (number of counters is zero). Swift sources keep their
coverage; Rust code gets coverage from its own tests.

Part of #14350.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Xut2hyWgXAuKZTkQf9BoEE
Evidence run 45012057904 wrote a non-empty coverage.dat for LedgerKit.swift,
but the accounting classified .swift as unsupported, so the cell had no
eligible lines and failed coverage_below_minimum.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Xut2hxcqqAoDeuSr83mscS
@TrapsterDK

Copy link
Copy Markdown
Collaborator Author

Rebased onto main (5bf6454). 6c1c543 fixes what was left after run 45012057904. That run's report was non-empty, but cli/lcov had no .swift in COVERED_LANGUAGES. So LedgerKit.swift counted as unsupported, the cell had 0 eligible lines, and dx failed with coverage_below_minimum. Swift now counts with // line comments.

Local (linux_x86_64): bazel test //cli/lcov:all //tools/coverage/collect:all //cli/exec_test_reports:all: 4 pass. //apple/tests:all: 79 pass, 10 skipped. dx check //cli/lcov:all reports only main's clippy::string_add in the untouched ignores_tests.rs.

Evidence dispatched (macos_arm64, task=coverage, //apple/tests/fixtures/swift_app/...): https://github.com/devhusdk/rules_dx/actions/runs/45170989636

🤖 Generated with Claude Code

Copy link
Copy Markdown
Collaborator Author

Evidence run 45170989636 (6c1c543): 6/6 tests pass and LedgerKit.swift now counts (1 eligible file, 0 unsupported). The only remaining failure is the threshold:

dx: coverage 91.30% (21/23 lines) below minimum 100% in package macos_arm64 (coverage_below_minimum)

The uncovered lines are LedgerKit.swift:10 (continue on a blank line) and :14 (return nil on a malformed line) in Ledger.init?(text:). A test in LedgerAppTests.swift that parses text with a blank line, plus one that parses a line without an amount, should cover both.


Generated by Claude Code

This branch has not been deployed

No deployments
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.

apple: coverage of //apple/tests/fixtures/swift_app writes an empty coverage.dat (no profile or no instrumented objects)

2 participants