bazelbuild / setup-bazelisk

Set up your GitHub Actions workflow with a specific version of Bazelisk

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Include OS version in cache key examples & docs

echeran opened this issue · comments

We've been having issues with the action failing after our Github Actions VM runner OS version was migrated to the next version (ubuntu-20.04 to ubuntu-22.04). Our PR unicode-org/icu#2272 to fix the problem indicates that the Bazel cache was causing the problem.

That makes sense because we have a cache key of bazel as indicated in the root Readme example, but understandably, the version of the OS affects the tools used to compile, and thus affects the cached binary files. A lot of other tools used in Github Actions that allow for caching put the OS version inside their cache key to make the cache different per OS version.

Could you update your examples and docs to do something similar? Instead of bazel, use ${{ runner.os }}-bazel? Thanks.

Hello @echeran ,

Thank you for the issue.

Theoretically, the correct way of using Bazel is by having "hermetic" builds (see https://bazel.build/basics/hermeticity).
This means that if everything is configured correctly, the version of the OS should not affect the output (I'm ignoring differences in host platform - as those will invalidate Bazel's cache anyways).

I see and understand the problem in your case, as you're using host's CC compiler (as is the default with the CC rules in Bazel), I believe that this is the outlier and not the norm.
I don't want to change the documentation that might make Go, Python, Java and other language builds slower (uncached) due to the defaults of CC.

I think in your case you can change the build code to be more hermetic (bring a hermetic CC toolchain), or you can add the bazel sync --configure (instead of bazelisk clean --expunge) to your pipeline.

I'm closing this Issue, please reopen if you have further notes.