Skip to content

Fix non-deterministic properties.jar causing (remote) cache misses fo…#475

Open
oliviernotteghem wants to merge 1 commit intobazelbuild:mainfrom
oliviernotteghem:local_test_remote_caching
Open

Fix non-deterministic properties.jar causing (remote) cache misses fo…#475
oliviernotteghem wants to merge 1 commit intobazelbuild:mainfrom
oliviernotteghem:local_test_remote_caching

Conversation

@oliviernotteghem
Copy link
Copy Markdown

@oliviernotteghem oliviernotteghem commented Apr 1, 2026

…r Robolectric tests

Robolectric tests in android_local_test rules produce a properties.jar archive containing test_config.properties. This jar is an input to the TestRunner action, so its SHA-256 hash is part of the remote cache key.

On CI, TestRunner consistently missed the remote cache even when nothing had changed.

In rules/android_local_test/impl.bzl, the _zip_file helper stages the file before zipping:

  cp $base/{f} {dir_name}
  zip -jt -X -q $base/{out_zip} {dir_name}/$(basename {f})

Because cp is used without -p, it resets the file's mtime to the current time. The zip tool embeds this timestamp into the archive. Note that zip -X does not reset mtime (which is the problem here).

As a result, two CI agents produce properties.jar files with identical content but different timestamps → different SHA-256 → cache miss.

Use cp -p to preserve the original mtime of file, which is deterministic (because file is created by starlark ctx.actions.expand_template method)

This makes the zip output deterministic across agents and stabilizes the TestRunner cache key.

…r Robolectric tests

Robolectric tests in android_local_test rules produce a properties.jar archive containing test_config.properties. This jar is an input to the TestRunner action, so its SHA-256 hash is part of the remote cache key.

On CI, TestRunner consistently missed the remote cache even when nothing had changed.

In rules/android_local_test/impl.bzl, the _zip_file helper stages the file before zipping:

  cp $base/{f} {dir_name}
  zip -jt -X -q $base/{out_zip} {dir_name}/$(basename {f})

Because cp is used without -p, it resets the file's mtime to the current time. The zip tool embeds this timestamp into the archive.

As a result, two CI agents produce properties.jar files with identical content but different timestamps → different SHA-256 → cache miss.

Use `cp -p` to preserve the original mtime.

This makes the zip output deterministic across agents and stabilizes the TestRunner cache key.
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.

1 participant