From a528585a3ca792960772a6077f5172d0556370c0 Mon Sep 17 00:00:00 2001 From: Prashanth Swaminathan Date: Sun, 7 Jan 2024 17:15:44 -0800 Subject: [PATCH] Run Bazel build in Github Actions As some clients rely on the Bazel build, add a workflow to verify at least one Bazel target (linux-x86). Also, perform some minor cleanup to comments and target branches in our workflow files. --- .bazelversion | 1 - .github/workflows/build.yml | 1 - .github/workflows/build_bazel.yml | 21 +++++++++++++++++++++ scripts/local-bazel-build.sh | 18 ++++++++++++++++++ scripts/local-build.sh | 4 +++- 5 files changed, 42 insertions(+), 3 deletions(-) delete mode 100644 .bazelversion create mode 100644 .github/workflows/build_bazel.yml create mode 100755 scripts/local-bazel-build.sh diff --git a/.bazelversion b/.bazelversion deleted file mode 100644 index 0062ac97..00000000 --- a/.bazelversion +++ /dev/null @@ -1 +0,0 @@ -5.0.0 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 06bce128..1407dc22 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,7 +3,6 @@ on: pull_request: push: branches: - - master - main permissions: diff --git a/.github/workflows/build_bazel.yml b/.github/workflows/build_bazel.yml new file mode 100644 index 00000000..84594726 --- /dev/null +++ b/.github/workflows/build_bazel.yml @@ -0,0 +1,21 @@ +name: Build using Bazel +on: + pull_request: + push: + branches: + - main + +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} + cancel-in-progress: true +jobs: + bazel-linux-local: + runs-on: ubuntu-latest + timeout-minutes: 40 + steps: + - uses: actions/checkout@v2 + - name: Build + run: scripts/local-bazel-build.sh diff --git a/scripts/local-bazel-build.sh b/scripts/local-bazel-build.sh new file mode 100755 index 00000000..c2aeb322 --- /dev/null +++ b/scripts/local-bazel-build.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# Copyright 2024 Google LLC + +set -e + +BAZEL_ARGS=() + +# Bazel-level configuration +# +# If editing these flags, make sure `local-build.sh` flags are updated. +BAZEL_ARGS+=("-c=\"opt\"") +BAZEL_ARGS+=("-copt=\"fpic\"") + +# User-specified Bazel arguments go last to allow overridding defaults +BAZEL_ARGS+=($@) + +# Build all targets +bazel build :all diff --git a/scripts/local-build.sh b/scripts/local-build.sh index 426a13bb..2be99e7b 100755 --- a/scripts/local-build.sh +++ b/scripts/local-build.sh @@ -13,6 +13,8 @@ mkdir -p build/local CMAKE_ARGS=() # CMake-level configuration +# +# If editing these flags, make sure `local-build-bazel.sh` flags are updated. CMAKE_ARGS+=("-DCMAKE_BUILD_TYPE=Release") CMAKE_ARGS+=("-DCMAKE_POSITION_INDEPENDENT_CODE=ON") @@ -22,7 +24,7 @@ then CMAKE_ARGS+=("-GNinja") fi -# Use-specified CMake arguments go last to allow overridding defaults +# User-specified CMake arguments go last to allow overridding defaults CMAKE_ARGS+=($@) cd build/local && cmake ../.. \