Skip to content

Commit

Permalink
ci: cache bazel only on the master branch to reduce the total cache s…
Browse files Browse the repository at this point in the history
…ize (#1135)
  • Loading branch information
homuler committed Jan 28, 2024
1 parent b9e0c49 commit 87b8fdd
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
12 changes: 11 additions & 1 deletion .github/workflows/linux-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ on:
inputs:
ref:
type: string
is_master:
type: boolean
default: false
secrets:
UNITY_EMAIL:
required: true
Expand Down Expand Up @@ -39,7 +42,7 @@ jobs:
# Setup build tools
- name: Mount bazel cache
if: steps.cache-libs.outputs.cache-hit != 'true'
uses: actions/cache@v3
uses: actions/cache/restore@v3
with:
path: "~/.cache/bazel"
key: bazel-ubuntu-20.04-v1-${{ hashFiles('WORKSPACE') }}-${{ hashFiles('cache_key.txt') }}
Expand Down Expand Up @@ -89,6 +92,13 @@ jobs:
path: artifacts.tar
retention-days: 1

- name: Cache bazel
if: inputs.is_master == 'true' && steps.cache-libs.outputs.cache-hit != 'true'
uses: actions/cache/save@v3
with:
path: ~/.cache/bazel
key: bazel-ubuntu-20.04-v1-${{ hashFiles('WORKSPACE') }}-${{ hashFiles('cache_key.txt') }}

test:
runs-on: ${{ matrix.os }}
needs: build
Expand Down
12 changes: 11 additions & 1 deletion .github/workflows/macos-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ on:
inputs:
ref:
type: string
is_master:
type: boolean
default: false
secrets:
UNITY_EMAIL:
required: true
Expand Down Expand Up @@ -39,7 +42,7 @@ jobs:
# Setup build tools
- name: Mount bazel cache
if: steps.cache-libs.outputs.cache-hit != 'true'
uses: actions/cache@v3
uses: actions/cache/restore@v3
with:
path: /private/var/tmp/_bazel_runner
key: bazel-macos-11-v1-${{ hashFiles('WORKSPACE') }}-${{ hashFiles('cache_key.txt') }}
Expand Down Expand Up @@ -76,6 +79,13 @@ jobs:
path: artifacts.tar
retention-days: 1

- name: Cache bazel
if: inputs.is_master == 'true' && steps.cache-libs.outputs.cache-hit != 'true'
uses: actions/cache/save@v3
with:
path: /private/var/tmp/_bazel_runner
key: bazel-macos-11-v1-${{ hashFiles('WORKSPACE') }}-${{ hashFiles('cache_key.txt') }}

test:
runs-on: ${{ matrix.os }}
needs: build
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
needs: check-test-trigger
with:
ref: ${{ github.event.pull_request.head.sha }}
is_master: ${{ github.ref_name == 'master' }}
secrets:
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
Expand All @@ -31,6 +32,7 @@ jobs:
needs: check-test-trigger
with:
ref: ${{ github.event.pull_request.head.sha }}
is_master: ${{ github.ref_name == 'master' }}
secrets:
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
Expand Down

0 comments on commit 87b8fdd

Please sign in to comment.