From 1b3470861689e8aebe096d9c512dbc43d340823f Mon Sep 17 00:00:00 2001 From: Andrew Mao Date: Thu, 4 Jun 2026 15:09:35 -0700 Subject: [PATCH 1/2] caching added --- .github/actions/environment-setup/action.yml | 9 +++++++++ .github/workflows/main.yml | 5 +---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/actions/environment-setup/action.yml b/.github/actions/environment-setup/action.yml index ff9cdc160b..0046bbddf3 100644 --- a/.github/actions/environment-setup/action.yml +++ b/.github/actions/environment-setup/action.yml @@ -30,3 +30,12 @@ runs: if: runner.os == 'macOS' run: | "${GITHUB_WORKSPACE}"/environment_setup/setup_software_mac.sh + + - name: Cache Bazel disk cache + uses: actions/cache@v4 + with: + path: ~/.cache/thunderbots_bazel_disk_cache + key: bazel-cache-${{ runner.os }}-${{ github.sha }} + restore-keys: | + bazel-cache-${{ runner.os }}- + diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e557f2d2a5..ae18585ab5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -64,10 +64,7 @@ jobs: runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 - - - name: Environment Setup - run: | - "${GITHUB_WORKSPACE}"/environment_setup/setup_software.sh + - uses: ./.github/actions/environment-setup - name: Raspberry Pi Build run: | From 9c3048fc60e6dad3b33ff0e03cc47621fdc6e75e Mon Sep 17 00:00:00 2001 From: Andrew Mao Date: Fri, 5 Jun 2026 15:53:28 -0700 Subject: [PATCH 2/2] Update CI workflows with caching rules and manual invalidation --- .github/actions/environment-setup/action.yml | 3 +- .github/workflows/main.yml | 61 +++++++++++++++++++- 2 files changed, 62 insertions(+), 2 deletions(-) diff --git a/.github/actions/environment-setup/action.yml b/.github/actions/environment-setup/action.yml index 0046bbddf3..45b8a2e231 100644 --- a/.github/actions/environment-setup/action.yml +++ b/.github/actions/environment-setup/action.yml @@ -35,7 +35,8 @@ runs: uses: actions/cache@v4 with: path: ~/.cache/thunderbots_bazel_disk_cache - key: bazel-cache-${{ runner.os }}-${{ github.sha }} + key: bazel-cache-${{ runner.os }}-${{ github.job }}-${{ github.sha }} restore-keys: | + bazel-cache-${{ runner.os }}-${{ github.job }}- bazel-cache-${{ runner.os }}- diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ae18585ab5..084cd928a8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -5,13 +5,64 @@ on: branches: [ master ] pull_request: branches: [ master ] + schedule: + - cron: '0 8 * * *' # 12 AM PST / 8 AM UTC + workflow_dispatch: + inputs: + clear_cache: + description: 'Clear cache before building' + required: false + type: boolean + default: true + +permissions: + actions: write + contents: read concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number }} + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true jobs: + check-and-clear-cache: + runs-on: ubuntu-24.04 + outputs: + should_run: ${{ steps.check.outputs.should_run }} + steps: + - uses: actions/checkout@v4 + if: github.event_name == 'schedule' + with: + fetch-depth: 50 + - name: Check conditions and optionally clear cache + id: check + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + SHOULD_RUN=true + if [ "${{ github.event_name }}" == "schedule" ]; then + COMMITS=$(git log --oneline --since="24 hours ago") + if [ -z "$COMMITS" ]; then + echo "No commits in the last 24 hours. Skipping." + SHOULD_RUN=false + else + echo "Commits found in the last 24 hours. Clearing cache..." + gh extension install actions/gh-actions-cache || true + gh actions-cache delete --all --confirm || true + gh cache delete --all || true + fi + elif [ "${{ github.event_name }}" == "workflow_dispatch" ]; then + if [ "${{ github.event.inputs.clear_cache }}" == "true" ]; then + echo "Manual trigger with clear_cache. Clearing cache..." + gh extension install actions/gh-actions-cache || true + gh actions-cache delete --all --confirm || true + gh cache delete --all || true + fi + fi + echo "should_run=$SHOULD_RUN" >> $GITHUB_OUTPUT + multiplatform-build: + needs: check-and-clear-cache + if: needs.check-and-clear-cache.outputs.should_run == 'true' strategy: matrix: platform: [ ubuntu-24.04-arm ] @@ -41,6 +92,8 @@ jobs: software-tests: + needs: check-and-clear-cache + if: needs.check-and-clear-cache.outputs.should_run == 'true' name: Software Tests runs-on: ubuntu-24.04 steps: @@ -60,6 +113,8 @@ jobs: -//software:unix_full_system_tar_gen robot-tests: + needs: check-and-clear-cache + if: needs.check-and-clear-cache.outputs.should_run == 'true' name: Robot Software Tests runs-on: ubuntu-24.04 steps: @@ -73,6 +128,8 @@ jobs: simulated-gameplay-tests: + needs: check-and-clear-cache + if: needs.check-and-clear-cache.outputs.should_run == 'true' name: Simulated Gameplay Tests runs-on: ubuntu-24.04 steps: @@ -107,6 +164,8 @@ jobs: /tmp/tbots/yellow/test/*/proto_* autorefd-game: + needs: check-and-clear-cache + if: needs.check-and-clear-cache.outputs.should_run == 'true' name: AutoRef'd Game (3 Minutes) runs-on: ubuntu-24.04 steps: