[ci] Add Bazel caching (#8006)

This commit is contained in:
Gold856
2025-07-04 00:15:18 -04:00
committed by GitHub
parent 26771e38fb
commit c3b327d57b
5 changed files with 62 additions and 52 deletions

View File

@@ -0,0 +1,29 @@
name: "Setup Artifactory Bazel caching"
description: "Sets up the Artifactory Bazel cache to be readonly / writing based on the presence of environment variables"
inputs:
username:
description: "Artifactory API username"
token:
description: "Artifactory API token"
runs:
using: "composite"
steps:
- name: Setup without key
env:
API_KEY: ${{ inputs.token }}
if: ${{ env.API_KEY == '' }}
shell: bash
run: |
echo "No API key secret detected, will setup readonly cache"
echo "build:ci --config=artifactory_readonly" > bazel_auth.rc
- name: Set with key
env:
API_KEY: ${{ inputs.token }}
if: ${{ env.API_KEY != '' }}
shell: bash
run: |
echo "API Key detected!"
echo "build:base_remote --remote_cache=https://${{ inputs.username }}:${{ inputs.token }}@frcmaven.wpi.edu/artifactory/wpilib-generic-cache-bazel-local" > bazel_auth.rc

View File

@@ -1,27 +0,0 @@
name: 'Setup BuildBuddy acache'
description: 'Sets up the build buddy cache to be readonly / writing based on the presence of environment variables'
inputs:
token:
description: 'Build Buddy API token'
runs:
using: "composite"
steps:
- name: Setup without key
env:
API_KEY: ${{ inputs.token }}
if: ${{ env.API_KEY == '' }}
shell: bash
run: |
echo "No API key secret detected, will setup readonly cache"
echo "build:ci --config=build_buddy_readonly" > bazel_auth.rc
- name: Set with key
env:
API_KEY: ${{ inputs.token }}
if: ${{ env.API_KEY != '' }}
shell: bash
run: |
echo "API Key detected!"
echo "build:build_buddy --remote_header=x-buildbuddy-api-key=${{ env.API_KEY }}" > bazel_auth.rc

View File

@@ -5,7 +5,8 @@
"items.find": {
"$or":[
{ "repo": "wpilib-generic-gradlecache" },
{ "repo": "wpilib-generic-cache-cmake" }
{ "repo": "wpilib-generic-cache-cmake" },
{ "repo": "wpilib-generic-cache-bazel" }
],
"$or":[
{

View File

@@ -26,10 +26,11 @@ jobs:
java-version: 17
architecture: x64
- id: Setup_build_buddy
uses: ./.github/actions/setup-build-buddy
- name: Setup Artifactory
uses: ./.github/actions/setup-artifactory-bazel
with:
token: ${{ secrets.BUILDBUDDY_API_KEY }}
username: ${{ secrets.ARTIFACTORY_USERNAME }}
token: ${{ secrets.ARTIFACTORY_PASSWORD }}
- name: bazel ${{ matrix.action }}
run: bazel --output_user_root=C:\\bazelroot ${{ matrix.action }} -k ... --config=ci ${{ matrix.config }} --verbose_failures
@@ -42,10 +43,11 @@ jobs:
- uses: actions/checkout@v4
with: { fetch-depth: 0 }
- id: Setup_build_buddy
uses: ./.github/actions/setup-build-buddy
- name: Setup Artifactory
uses: ./.github/actions/setup-artifactory-bazel
with:
token: ${{ secrets.BUILDBUDDY_API_KEY }}
username: ${{ secrets.ARTIFACTORY_USERNAME }}
token: ${{ secrets.ARTIFACTORY_PASSWORD }}
- name: bazel test (release)
run: bazel test -k ... --config=ci -c opt --config=macos --nojava_header_compilation --verbose_failures
@@ -63,12 +65,12 @@ jobs:
steps:
- uses: actions/checkout@v4
with: { fetch-depth: 0 }
- uses: bazelbuild/setup-bazelisk@v3
- id: Setup_build_buddy
uses: ./.github/actions/setup-build-buddy
- name: Setup Artifactory
uses: ./.github/actions/setup-artifactory-bazel
with:
token: ${{ secrets.BUILDBUDDY_API_KEY }}
username: ${{ secrets.ARTIFACTORY_USERNAME }}
token: ${{ secrets.ARTIFACTORY_PASSWORD }}
- name: bazel ${{ matrix.action }} (release)
run: bazel ${{ matrix.action }} ... --config=ci -c opt ${{ matrix.config }} -k --verbose_failures