Skip to content

Commit

Permalink
chore: update to Bazel 6.0.0rc1
Browse files Browse the repository at this point in the history
  • Loading branch information
gregmagolan committed Nov 1, 2022
1 parent e09ccc0 commit 67b4f2b
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 13 deletions.
5 changes: 3 additions & 2 deletions .bazelrc.common
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,6 @@ build:openbsd --nolegacy_external_runfiles
# See https://github.com/angular/angular/issues/27514.
build --incompatible_strict_action_env

# TODO: enable once this is supported in Bazel
build:rbe --experimental_allow_unresolved_symlinks
# Not yet supported with rules_ts
# See https://github.com/aspect-build/rules_ts/pull/202
build --noexperimental_allow_unresolved_symlinks
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
5.2.0
6.0.0rc1
# 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.
# This also defines which version is used on CI.
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ build:local --disk_cache=~/.cache/bazel

# Generic remote cache
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_upload_local_results
## Fixes builds hanging on CI that get the TCP connection closed without sending RST packets.
Expand Down
48 changes: 39 additions & 9 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,54 @@ on:
workflow_dispatch:

jobs:
# Dynamically generate a bit of JSON depending on whether our action has access to repository secrets.
# When running on a pull_request from a fork, the author is untrusted so the secret will be absent.
# Insanely complex for how simple this requirement is... inspired from
# matrix-prep-* steps dynamically generate a bit of JSON depending on whether our action has
# access to repository secrets. When running on a pull_request from a fork, the author is
# 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
matrix-prep:

matrix-prep-config:
# Prepares the 'config' axis of the test matrix
runs-on: ubuntu-latest
env:
ENGFLOW_PRIVATE_KEY: ${{ secrets.ENGFLOW_PRIVATE_KEY }}
steps:
- id: local
run: echo "config=local" >> $GITHUB_OUTPUT
- id: maybe-rbe
if: ${{ env.ENGFLOW_PRIVATE_KEY != '' }}
- id: rbe
run: echo "config=rbe" >> $GITHUB_OUTPUT
# Don't run RBE if there are no EngFlow creds which is the case on forks
if: ${{ env.ENGFLOW_PRIVATE_KEY != '' }}
outputs:
# Will look like '["local", "rbe"]'
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 "bazelversion=$(head -n 1 .bazelversion)" >> $GITHUB_OUTPUT
- id: bazel_5
run: echo "bazelversion=5.3.2" >> $GITHUB_OUTPUT
outputs:
# Will look like '["6.0.0rc1", "5.3.2"]'
bazelversions: ${{ toJSON(steps.*.outputs.bazelversion) }}

test:
# The type of runner that the job will run on
runs-on: ubuntu-latest
needs: matrix-prep

needs:
- matrix-prep-config
- matrix-prep-bazelversion

strategy:
fail-fast: false
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:
- '.'
# TODO: figure out and re-enable
Expand All @@ -60,6 +81,7 @@ jobs:
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3

# Cache build and external artifacts so that the next ci build is incremental.
# Because github action caches cannot be updated after a build, we need to
# store the contents of each build in a unique cache key, then fall back to loading
Expand All @@ -79,6 +101,11 @@ jobs:
"~/.cache/bazel-repo"
key: bazel-cache-${{ hashFiles('**/BUILD.bazel', '**/*.bzl', 'WORKSPACE') }}
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
if: ${{ matrix.config == 'rbe' }}
working-directory: ${{ matrix.folder }}
Expand All @@ -87,23 +114,26 @@ jobs:
chmod 0600 engflow.crt engflow.key
echo "$ENGFLOW_CLIENT_CRT" > engflow.crt
echo "$ENGFLOW_PRIVATE_KEY" > engflow.key
echo "USE_BAZEL_VERSION=aspect-build/6.0.0-aspect1" >> $GITHUB_ENV
env:
ENGFLOW_CLIENT_CRT: ${{ secrets.ENGFLOW_CLIENT_CRT }}
ENGFLOW_PRIVATE_KEY: ${{ secrets.ENGFLOW_PRIVATE_KEY }}

- name: bazel test //...
env:
# Bazelisk will download bazel to here, ensure it is cached between runs.
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 }} //...

# Some tests need buildozer to manipulate BUILD files.
- uses: actions/setup-go@v3
if: ${{ hashFiles(format('{0}/test.sh', matrix.folder)) != '' }}
with:
go-version: '1.17.0'

- run: go install github.com/bazelbuild/buildtools/buildozer@latest
if: ${{ hashFiles(format('{0}/test.sh', matrix.folder)) != '' }}

- name: run ./test.sh
working-directory: ${{ matrix.folder }}
# hashFiles returns an empty string if test.sh is absent
Expand Down

0 comments on commit 67b4f2b

Please sign in to comment.