mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
When the bazel remote cache was switched from buildbuddy to a self hosted server in #8342, I asked that the buildbuddy hooks be remain so that I could still use their caching service for local builds. The downside of this was that my forks builds aren't leveraging buildbuddy, so if I'm fiddling with something heavy like a wpimath robotpy thing, my CI builds never update a cache and never are warm when I push fixups. This PR combines the `setup-bazel-remote` and `setup-build-buddy` actions which set up the bazel remote cache. Rather than having two different version, the correct one will be choosen in the following order: 1. Use wpi's server with write access if the `bazel_remote` information is set (This basically would only happen on main branch in `wpilibsuite/allwpilib` since secrets aren't accessible from builds originating in forks) 2. Use buildbuddy if the key it is present (This would work for my fork builds) 3. Fall back to the readonly version of wpi's server As seen [here](https://github.com/bzlmodRio/allwpilib/actions/runs/25777428163/job/75712863120#step:7:28) the build in my fork will run with buildbuddy, and my PR's build here should fall back to readonly mode.
229 lines
8.2 KiB
YAML
229 lines
8.2 KiB
YAML
name: Bazel
|
|
|
|
on: [pull_request, push]
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
build:
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- { name: "Linux System Core", classifier: "linuxsystemcore", os: ubuntu-24.04, action: "build" }
|
|
- { name: "Linux System Core Debug", classifier: "linuxsystemcoredebug", os: ubuntu-24.04, action: "build" }
|
|
- { name: "Linux System Core Static", classifier: "linuxsystemcorestatic", os: ubuntu-24.04, action: "build" }
|
|
- { name: "Linux System Core Static Debug", classifier: "linuxsystemcorestaticdebug", os: ubuntu-24.04, action: "build" }
|
|
- { name: "Linux x86-64", classifier: "linuxx86-64,headers,sources", os: ubuntu-24.04, action: "test" }
|
|
- { name: "Linux x86-64 Debug", classifier: "linuxx86-64debug", os: ubuntu-24.04, action: "test" }
|
|
- { name: "Linux x86-64 Static", classifier: "linuxx86-64static", os: ubuntu-24.04, action: "test" }
|
|
- { name: "Linux x86-64 Static Debug", classifier: "linuxx86-64staticdebug", os: ubuntu-24.04, action: "test" }
|
|
|
|
- { name: "macOS", classifier: "osxuniversal,osxuniversaldebug,headers,sources,osxuniversalstatic,osxuniversalstaticdebug,linuxsystemcore,linuxsystemcoredebug,linuxsystemcorestatic,linuxsystemcorestaticdebug", os: macOS-15, action: "test" }
|
|
|
|
- { name: "Windows x86-64", classifier: "windowsx86-64,windowsx86-64static,headers,sources", os: windows-2022, action: "test" }
|
|
- { name: "Windows x86-64 Debug", classifier: "windowsx86-64debug,windowsx86-64staticdebug", os: windows-2022, action: "test" }
|
|
|
|
- { name: "Windows ARM64", classifier: "windowsarm64,windowsarm64static", os: windows-2022, action: "build" }
|
|
- { name: "Windows ARM64 Debug", classifier: "windowsarm64debug,windowsarm64staticdebug", os: windows-2022, action: "build" }
|
|
|
|
- { name: "Windows System Core", classifier: "linuxsystemcore,linuxsystemcorestatic", os: windows-2022, action: "build" }
|
|
- { name: "Windows System Core Debug", classifier: "linuxsystemcoredebug,linuxsystemcorestaticdebug", os: windows-2022, action: "build" }
|
|
|
|
name: "${{ matrix.action == 'test' && 'Test' || 'Build' }} ${{ matrix.name }}"
|
|
runs-on: ${{ matrix.os }}
|
|
steps:
|
|
- name: Check disk free space pre-cleanup
|
|
run: df -h
|
|
|
|
- name: Free disk space (Linux)
|
|
if: runner.os == 'Linux'
|
|
uses: jlumbroso/free-disk-space@main
|
|
with:
|
|
tool-cache: false
|
|
android: true
|
|
dotnet: true
|
|
haskell: true
|
|
large-packages: false
|
|
docker-images: false
|
|
swap-storage: false
|
|
|
|
- name: Free disk space (macOS)
|
|
if: runner.os == 'macOS'
|
|
# CodeQL: 5G
|
|
# go: 748M
|
|
# Android: 12G
|
|
run: |
|
|
rm -rf /Users/runner/hostedtoolcache/CodeQL
|
|
rm -rf /Users/runner/hostedtoolcache/go
|
|
rm -rf /Users/runner/Library/Android
|
|
|
|
- name: Check disk free space post-cleanup
|
|
run: df -h
|
|
|
|
- uses: actions/checkout@v6
|
|
with: { fetch-depth: 0 }
|
|
|
|
- id: Setup_bazel_cache
|
|
uses: ./.github/actions/setup-bazel-cache
|
|
with:
|
|
bazel_remote_username: ${{ secrets.BAZEL_CACHE_USERNAME }}
|
|
bazel_remote_password: ${{ secrets.BAZEL_CACHE_PASSWORD }}
|
|
buildbuddy_token: ${{ secrets.BUILDBUDDY_API_KEY }}
|
|
|
|
- name: Install apt dependencies
|
|
if: runner.os == 'Linux'
|
|
run: sudo apt-get update && sudo apt-get install -y libgl1-mesa-dev libx11-dev libxcursor-dev libxi-dev libxinerama-dev libxrandr-dev avahi-daemon
|
|
|
|
- if: runner.os == 'Linux'
|
|
uses: bazel-contrib/setup-bazel@0.15.0
|
|
with:
|
|
bazelisk-cache: true
|
|
repository-cache: true
|
|
bazelisk-version: 1.x
|
|
|
|
- name: bazel ${{ matrix.action }}
|
|
run: |
|
|
ACTION='${{ matrix.action }}'
|
|
if [ "${ACTION}" = "build" ]; then
|
|
TARGETS=:publish
|
|
else
|
|
TARGETS=...
|
|
fi
|
|
if [ "${{ runner.os }}" = "Windows" ]; then
|
|
bazel --output_user_root=C:\\bazelroot ${ACTION} ${TARGETS} --config=ci -c opt --repo_env=WPI_PUBLISH_CLASSIFIER_FILTER='${{ matrix.classifier }}'
|
|
else
|
|
bazel ${ACTION} ${TARGETS} --config=ci -c opt --repo_env=WPI_PUBLISH_CLASSIFIER_FILTER='${{ matrix.classifier }}'
|
|
fi
|
|
shell: bash
|
|
|
|
- name: Check disk free space
|
|
if: always()
|
|
run: df -h
|
|
|
|
buildifier:
|
|
name: "buildifier"
|
|
runs-on: ubuntu-24.04
|
|
steps:
|
|
- name: Set up Go 1.15.x
|
|
uses: actions/setup-go@v6
|
|
with:
|
|
cache: false
|
|
go-version: 1.15.x
|
|
id: go
|
|
|
|
- name: Install Buildifier
|
|
run: |
|
|
cd $(mktemp -d)
|
|
GO111MODULE=on go get github.com/bazelbuild/buildtools/buildifier@6.0.0
|
|
|
|
- uses: actions/checkout@v6
|
|
with: { fetch-depth: 0 }
|
|
|
|
- name: Run buildifier
|
|
run: buildifier -warnings all --lint=fix -r .
|
|
|
|
- name: Check Output
|
|
run: git --no-pager diff --exit-code HEAD
|
|
|
|
- name: Generate diff
|
|
run: git diff HEAD > ${{ matrix.platform }}-bazel-lint-fixes.patch
|
|
if: ${{ failure() }}
|
|
|
|
- uses: actions/upload-artifact@v7
|
|
with:
|
|
archive: false
|
|
path: "*-bazel-lint-fixes.patch"
|
|
if: ${{ failure() }}
|
|
|
|
mod-lock:
|
|
runs-on: ubuntu-24.04
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
|
|
- name: Check lockfile
|
|
run: bazel mod deps --lockfile_mode=error
|
|
|
|
- run: bazel mod deps --lockfile_mode=update
|
|
if: ${{ failure() }}
|
|
|
|
- name: Generate diff
|
|
run: git diff HEAD > bazel-mod-lock-fixes.patch
|
|
if: ${{ failure() }}
|
|
|
|
- uses: actions/upload-artifact@v7
|
|
with:
|
|
archive: false
|
|
path: "bazel-mod-lock-fixes.patch"
|
|
if: ${{ failure() }}
|
|
|
|
non_robotpy_pregeneration:
|
|
name: "Non-RobotPy Pregen"
|
|
runs-on: ubuntu-24.04
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
with: { fetch-depth: 0 }
|
|
|
|
- id: Setup_bazel_cache
|
|
uses: ./.github/actions/setup-bazel-cache
|
|
with:
|
|
bazel_remote_username: ${{ secrets.BAZEL_CACHE_USERNAME }}
|
|
bazel_remote_password: ${{ secrets.BAZEL_CACHE_PASSWORD }}
|
|
buildbuddy_token: ${{ secrets.BUILDBUDDY_API_KEY }}
|
|
|
|
- name: Run Non-RobotPy pregeneration
|
|
run: bazel run --config=ci //:write_pregenerated_files
|
|
|
|
- name: Check Output
|
|
run: git --no-pager diff --exit-code HEAD
|
|
|
|
- name: Generate diff
|
|
run: git diff HEAD > non-robotpy-pregeneration.patch
|
|
if: ${{ failure() }}
|
|
|
|
- uses: actions/upload-artifact@v6
|
|
with:
|
|
name: non-robotpy-pregeneration-fixes
|
|
path: non-robotpy-pregeneration.patch
|
|
if: ${{ failure() }}
|
|
|
|
robotpy_pregeneration:
|
|
name: "Robotpy Pregeneration"
|
|
runs-on: ubuntu-24.04
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
with: { fetch-depth: 0 }
|
|
|
|
- id: Setup_bazel_cache
|
|
uses: ./.github/actions/setup-bazel-cache
|
|
with:
|
|
bazel_remote_username: ${{ secrets.BAZEL_CACHE_USERNAME }}
|
|
bazel_remote_password: ${{ secrets.BAZEL_CACHE_PASSWORD }}
|
|
buildbuddy_token: ${{ secrets.BUILDBUDDY_API_KEY }}
|
|
|
|
# You should ensure the headers are correct before trying to pregen files
|
|
- name: Test Scan Headers
|
|
run: bazel test --config=ci //... -k --test_tag_filters=robotpy_scan_headers --build_tests_only
|
|
shell: bash
|
|
|
|
- name: Run yaml file generation
|
|
run: bazel run --config=ci //:write_robotpy_update_yaml_files
|
|
|
|
- name: Run build file generation
|
|
run: bazel run --config=ci //:write_robotpy_generated_pybind_files
|
|
|
|
- name: Check Output
|
|
run: git --no-pager diff --exit-code HEAD
|
|
|
|
- name: Generate diff
|
|
run: git diff HEAD > robotpy-pregeneration.patch
|
|
if: ${{ failure() }}
|
|
|
|
- uses: actions/upload-artifact@v6
|
|
with:
|
|
name: robotpy-pregeneration-fixes
|
|
path: robotpy-pregeneration.patch
|
|
if: ${{ failure() }}
|