chore: upgrade to Bazel 6.0.0rc1 but continue to also test Bazel 5.3.2 on CI (#266)

This commit is contained in:
Greg Magolan 2022-10-26 15:05:27 -07:00 committed by GitHub
parent 35623e23fe
commit 93c43e908e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 64 additions and 19 deletions

View File

@ -1,4 +1,4 @@
5.3.2 6.0.0rc1
# The first line of this file is used by Bazelisk and Bazel to be sure # The first line of this file is used by Bazelisk and Bazel to be sure
# the right version of Bazel is used to build and test this repo. # the right version of Bazel is used to build and test this repo.
# This also defines which version is used on CI. # This also defines which version is used on CI.

View File

@ -10,7 +10,7 @@ build:local --disk_cache=~/.cache/bazel
# Generic remote cache # Generic remote cache
build --remote_local_fallback build --remote_local_fallback
build --remote_download_toplevel # build --remote_download_toplevel # BREAKS BUILD in Bazel 6.0.0rc1
build --remote_timeout=3600 build --remote_timeout=3600
build --remote_upload_local_results build --remote_upload_local_results
## Fixes builds hanging on CI that get the TCP connection closed without sending RST packets. ## Fixes builds hanging on CI that get the TCP connection closed without sending RST packets.

View File

@ -12,46 +12,75 @@ on:
workflow_dispatch: workflow_dispatch:
jobs: jobs:
# Dynamically generate a bit of JSON depending on whether our action has access to repository secrets. # matrix-prep-* steps dynamically generate a bit of JSON depending on whether our action has
# When running on a pull_request from a fork, the author is untrusted so the secret will be absent. # access to repository secrets. When running on a pull_request from a fork, the author is
# Insanely complex for how simple this requirement is... inspired from # untrusted so the secret will be absent. Insanely complex for how simple this requirement is...
# inspired from
# https://stackoverflow.com/questions/65384420/how-to-make-a-github-action-matrix-element-conditional # https://stackoverflow.com/questions/65384420/how-to-make-a-github-action-matrix-element-conditional
matrix-prep:
matrix-prep-config:
# Prepares the 'config' axis of the test matrix
runs-on: ubuntu-latest runs-on: ubuntu-latest
env: env:
ENGFLOW_PRIVATE_KEY: ${{ secrets.ENGFLOW_PRIVATE_KEY }} ENGFLOW_PRIVATE_KEY: ${{ secrets.ENGFLOW_PRIVATE_KEY }}
steps: steps:
- id: local - id: local
run: echo "::set-output name=config::local" run: echo "::set-output name=config::local"
- id: maybe-rbe - id: rbe
if: ${{ env.ENGFLOW_PRIVATE_KEY != '' }}
run: echo "::set-output name=config::rbe" run: echo "::set-output name=config::rbe"
# Don't run RBE if there are no EngFlow creds which is the case on forks
if: ${{ env.ENGFLOW_PRIVATE_KEY != '' }}
outputs: outputs:
# Will look like '["local", "rbe"]' # Will look like '["local", "rbe"]'
configs: ${{ toJSON(steps.*.outputs.config) }} configs: ${{ toJSON(steps.*.outputs.config) }}
matrix-prep-bazelversion:
# Prepares the 'bazelversion' axis of the test matrix
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- id: bazel_6
run: echo "::set-output name=bazelversion::$(head -n 1 .bazelversion)"
- id: bazel_5
run: echo "::set-output name=bazelversion::5.3.2"
outputs:
# Will look like '["6.0.0rc1", "5.3.2"]'
bazelversions: ${{ toJSON(steps.*.outputs.bazelversion) }}
test: test:
# The type of runner that the job will run on # The type of runner that the job will run on
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: matrix-prep
needs:
- matrix-prep-config
- matrix-prep-bazelversion
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
config: ${{ fromJSON(needs.matrix-prep.outputs.configs) }} config: ${{ fromJSON(needs.matrix-prep-config.outputs.configs) }}
bazelversion: ${{ fromJSON(needs.matrix-prep-bazelversion.outputs.bazelversions) }}
folder: folder:
- "." - "."
- "e2e/bzlmod" - "e2e/bzlmod"
- "e2e/copy_to_directory" - "e2e/copy_to_directory"
exclude: exclude:
# bzlmod broken at 5.3.0 which the RBE bazel fork is bazed on # bzlmod broken at 5.3.2 which the RBE:
# ```
# ERROR: /home/runner/work/bazel-lib/bazel-lib/e2e/bzlmod/BUILD.bazel:37:10: While resolving
# toolchains for target //:test: com.google.devtools.build.lib.packages.BuildFileNotFoundException:
# no such package '@aspect_bazel_lib//platforms': The repository '@aspect_bazel_lib' could not be
# resolved: Repository '@aspect_bazel_lib' is not defined
# ```
- config: rbe - config: rbe
bazelversion: 5.3.2
folder: e2e/bzlmod folder: e2e/bzlmod
# Steps represent a sequence of tasks that will be executed as part of the job # Steps represent a sequence of tasks that will be executed as part of the job
steps: steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Mount bazel caches - name: Mount bazel caches
uses: actions/cache@v3 uses: actions/cache@v3
with: with:
@ -60,6 +89,11 @@ jobs:
~/.cache/bazel-repo ~/.cache/bazel-repo
key: bazel-cache-${{ hashFiles('**/BUILD.bazel', '**/*.bzl', 'WORKSPACE') }} key: bazel-cache-${{ hashFiles('**/BUILD.bazel', '**/*.bzl', 'WORKSPACE') }}
restore-keys: bazel-cache- restore-keys: bazel-cache-
- name: Configure Bazel version
working-directory: ${{ matrix.folder }}
run: echo "USE_BAZEL_VERSION=${{ matrix.bazelversion }}" >> $GITHUB_ENV
- name: Write engflow credentials - name: Write engflow credentials
if: ${{ matrix.config == 'rbe' }} if: ${{ matrix.config == 'rbe' }}
working-directory: ${{ matrix.folder }} working-directory: ${{ matrix.folder }}
@ -71,12 +105,18 @@ jobs:
env: env:
ENGFLOW_CLIENT_CRT: ${{ secrets.ENGFLOW_CLIENT_CRT }} ENGFLOW_CLIENT_CRT: ${{ secrets.ENGFLOW_CLIENT_CRT }}
ENGFLOW_PRIVATE_KEY: ${{ secrets.ENGFLOW_PRIVATE_KEY }} ENGFLOW_PRIVATE_KEY: ${{ secrets.ENGFLOW_PRIVATE_KEY }}
- name: bazel test //... - name: bazel test //...
working-directory: ${{ matrix.folder }}
# NB: we need to write the bazel version from the matrix to .bazelversion since
# the //:bazel_version_test uses it and it needs to match the Bazel version being run
run: |
echo "${{ matrix.bazelversion }}" > .bazelversion
bazel --bazelrc=$GITHUB_WORKSPACE/.github/workflows/ci.bazelrc --bazelrc=.bazelrc test --config=${{ matrix.config }} //...
env: env:
# Bazelisk will download bazel to here # Bazelisk will download bazel to here
XDG_CACHE_HOME: ~/.cache/bazel-repo XDG_CACHE_HOME: ~/.cache/bazel-repo
working-directory: ${{ matrix.folder }}
run: bazel --bazelrc=$GITHUB_WORKSPACE/.github/workflows/ci.bazelrc --bazelrc=.bazelrc test --config=${{ matrix.config }} //...
- name: integration tests - name: integration tests
if: ${{ matrix.folder == '.' }} if: ${{ matrix.folder == '.' }}
# Find all shell scripts within e2e, echo the filename, execute, fail on error # Find all shell scripts within e2e, echo the filename, execute, fail on error

View File

@ -7,7 +7,6 @@ You'll see a aspect_bazel_lib.ext.yq_toolchains repo, but no downloaded yq binar
""" """
load("@aspect_bazel_lib//lib:jq.bzl", "jq") load("@aspect_bazel_lib//lib:jq.bzl", "jq")
load("@aspect_bazel_lib//lib:docs.bzl", "stardoc_with_diff_test")
load("@aspect_bazel_lib//lib:diff_test.bzl", "diff_test") load("@aspect_bazel_lib//lib:diff_test.bzl", "diff_test")
load("@bazel_skylib//:bzl_library.bzl", "bzl_library") load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
@ -21,10 +20,12 @@ bzl_library(
# https://github.com/bazelbuild/stardoc/issues/117 # https://github.com/bazelbuild/stardoc/issues/117
# This happens to work because we don't reference any external repos # This happens to work because we don't reference any external repos
# from defs.bzl. # from defs.bzl.
stardoc_with_diff_test( # TODO: re-enable this once it works
name = "docs", # load("@aspect_bazel_lib//lib:docs.bzl", "stardoc_with_diff_test")
bzl_library_target = "//:defs", # stardoc_with_diff_test(
) # name = "docs",
# bzl_library_target = "//:defs",
# )
# Validate that JQ works and resolves its toolchain # Validate that JQ works and resolves its toolchain
jq( jq(

View File

@ -4,9 +4,10 @@ module(
version = "0.0.0", version = "0.0.0",
) )
bazel_dep(name = "aspect_bazel_lib", version = "0.9.8")
bazel_dep(name = "bazel_skylib", version = "1.1.1") bazel_dep(name = "bazel_skylib", version = "1.1.1")
bazel_dep(name = "aspect_bazel_lib", version = "0.0.0")
local_path_override( local_path_override(
module_name = "aspect_bazel_lib", module_name = "aspect_bazel_lib",
path = "../..", path = "../..",

View File

@ -36,5 +36,8 @@ host = struct(
host_repo = repository_rule( host_repo = repository_rule(
implementation = _host_repo_impl, implementation = _host_repo_impl,
# always invalidate this repository since so that the bazel_version is
# always updated on every invocation of bazel
local = True,
doc = "Exposes information about the host platform", doc = "Exposes information about the host platform",
) )