Skip to content

[bazel,cov] Fix missing generated files due to coverage remote-cache #29567

Closed
sasdf wants to merge 3 commits into
lowRISC:earlgrey_1.0.0from
sasdf:mgTa978939f
Closed

[bazel,cov] Fix missing generated files due to coverage remote-cache #29567
sasdf wants to merge 3 commits into
lowRISC:earlgrey_1.0.0from
sasdf:mgTa978939f

Conversation

@sasdf
Copy link
Copy Markdown
Contributor

@sasdf sasdf commented Mar 25, 2026

The coverage report generation requires source files to be present locally. When using remote caching, some source files might not be present in the local workspace.

This change adds a utility script util/fetch-remote-cache.py that:

  1. Resolves the remote cache URL from Bazel configuration.
  2. Parses the Bazel action cache to map file paths to content hashes.
  3. Fetches missing files directly from the remote cache's CAS.

The collect-coverage-report.sh script is updated to invoke this utility before attempting to rsync source files into the report directory.

@sasdf sasdf force-pushed the mgTa978939f branch 3 times, most recently from 4f091b7 to ccf6d23 Compare March 25, 2026 10:23
@sasdf sasdf requested review from cfrantz and timothytrippel March 25, 2026 10:42
@sasdf sasdf marked this pull request as ready for review March 25, 2026 10:42
@sasdf sasdf requested a review from rswarbrick as a code owner March 25, 2026 10:42
Comment thread util/fetch-remote-bazel-cache.py
sasdf added 3 commits May 13, 2026 15:29
The coverage report generation requires source files to be present
locally. When using remote caching, some source files might not be
present in the local workspace.

This change adds a utility script `util/fetch-remote-cache.py` that:
1. Resolves the remote cache URL from Bazel configuration.
2. Parses the Bazel action cache to map file paths to content hashes.
3. Fetches missing files directly from the remote cache's CAS.

Change-Id: Ifedad80d526862c07616c2e9d6cec3169c7e3675
Signed-off-by: Yi-Hsuan Deng <yhdeng@google.com>
The coverage report generation requires source files to be present
locally. When using remote caching, some source files might not be
present in the local workspace.

The `collect-coverage-report.sh` script is updated to invoke this
utility before attempting to rsync source files into the report
directory.

Change-Id: I16e41e78c3ffd07f5926dffdd37f868fca4f1c92
Signed-off-by: Yi-Hsuan Deng <yhdeng@google.com>
This ensures that the output directories are empty before we start
collecting data, avoiding potential issues with stale data from previous
runs.

Change-Id: I8eaba03e802c1703183fc8c93e0f7c1d5e6463f4
Signed-off-by: Yi-Hsuan Deng <yhdeng@google.com>
@pamaury
Copy link
Copy Markdown
Contributor

pamaury commented May 14, 2026

I am not super familiar with the coverage handling in bazel, but it sounds a bit strange that some files would be downloaded by bazel. Is this a bazel bug/misfeature? Or is possibly because of some missing dependency tracking in the rules? It doesn't sound great to require to manually download from the remote cache.

@sasdf
Copy link
Copy Markdown
Contributor Author

sasdf commented May 14, 2026

By default, bazel only downloads the artifacts of top-level targets (i.e. targets specified in cmdline) from the remote cache, including test result / compiled libs... These artifacts does not includes generated sources used to during compilation in the dependencies. However, generating the coverage reports requires the source code.

This download behavior is configured by the --remote_download_outputs, which supports:

  • all: Download everything, too much network traffic.
  • toplevel
  • minimal: even less files than toplevel

@sasdf
Copy link
Copy Markdown
Contributor Author

sasdf commented May 18, 2026

Close this since we found a better solution using aspect:

@sasdf sasdf closed this May 18, 2026
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