Skip to content

Commit 3f4125b

Browse files
committed
Cache bazel setup runs
1 parent 17d8315 commit 3f4125b

1 file changed

Lines changed: 27 additions & 9 deletions

File tree

.github/workflows/workflow.yml

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ on:
1111
# Cancel previous workflows on the PR when there are multiple fast commits.
1212
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#concurrency
1313
concurrency:
14-
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
14+
group: ${{ github.workflow }}-${{ github.head_ref || GITHUB_REF }}
1515
cancel-in-progress: true
1616

1717
jobs:
@@ -21,24 +21,32 @@ jobs:
2121
steps:
2222
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
2323
- run: echo "🐧 Job is running on a ${{ runner.os }} server!"
24-
- run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
24+
- run: echo "🔎 The name of your branch is ${{ GITHUB_REF }} and your repository is ${{ github.repository }}."
2525
- name: Check out repository code
2626
uses: actions/checkout@v6
2727
- name: Setup Bazel
2828
uses: bazel-contrib/setup-bazel@0.18.0
29+
with:
30+
# Avoid downloading Bazel every time.
31+
bazelisk-cache: true
32+
# Store build cache per workflow.
33+
disk-cache: ${{ github.workflow }}
34+
# Share repository cache between workflows.
35+
repository-cache: true
2936
- name: Unwanted Dependencies
3037
run: .github/workflows/unwanted_deps.sh
3138
- name: Cross Artifact Duplicate Classes Check
3239
run: .github/workflows/cross_artifact_dependencies_check.sh
33-
- run: echo "🍏 This job's status is ${{ job.status }}."
34-
40+
- run: echo "🍏 This job's status is ${{ JOB_STATUS }}."
41+
env:
42+
JOB_STATUS: ${{ job.status }}
3543
Bazel-Tests:
3644
runs-on: ubuntu-latest
3745
timeout-minutes: 30
3846
steps:
3947
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
4048
- run: echo "🐧 Job is running on a ${{ runner.os }} server!"
41-
- run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
49+
- run: echo "🔎 The name of your branch is ${{ GITHUB_REF }} and your repository is ${{ github.repository }}."
4250
- name: Check out repository code
4351
uses: actions/checkout@v6
4452
- name: Setup Bazel
@@ -58,8 +66,9 @@ jobs:
5866
# Exclude codelab exercises as they are intentionally made to fail
5967
# Exclude maven conformance tests. They are only executed when there's version change.
6068
run: bazelisk test ... --deleted_packages=//codelab/src/test/codelab --test_output=errors --test_tag_filters=-conformance_maven --build_tag_filters=-conformance_maven
61-
- run: echo "🍏 This job's status is ${{ job.status }}."
62-
69+
- run: echo "🍏 This job's status is ${{ JOB_STATUS }}."
70+
env:
71+
JOB_STATUS: ${{ job.status }}
6372

6473
# -- Start of Maven Conformance Tests (Ran only when there's version changes) --
6574
Maven-Conformance:
@@ -68,7 +77,7 @@ jobs:
6877
steps:
6978
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
7079
- run: echo "🐧 Job is running on a ${{ runner.os }} server!"
71-
- run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
80+
- run: echo "🔎 The name of your branch is ${{ GITHUB_REF }} and your repository is ${{ github.repository }}."
7281
- name: Check out repository code
7382
uses: actions/checkout@v6
7483
- name: Get changed files
@@ -79,6 +88,13 @@ jobs:
7988
- name: Setup Bazel
8089
if: steps.changed_file.outputs.any_changed == 'true'
8190
uses: bazel-contrib/setup-bazel@0.18.0
91+
with:
92+
# Avoid downloading Bazel every time.
93+
bazelisk-cache: true
94+
# Store build cache per workflow.
95+
disk-cache: ${{ github.workflow }}
96+
# Share repository cache between workflows.
97+
repository-cache: true
8298
- name: Verify Version Consistency
8399
if: steps.changed_file.outputs.any_changed == 'true'
84100
run: |
@@ -103,4 +119,6 @@ jobs:
103119
- name: Run Conformance Maven Test on Version Change
104120
if: steps.changed_file.outputs.any_changed == 'true'
105121
run: bazelisk test //conformance/src/test/java/dev/cel/conformance:conformance_maven --test_output=errors
106-
- run: echo "🍏 This job's status is ${{ job.status }}."
122+
- run: echo "🍏 This job's status is ${{ JOB_STATUS }}."
123+
env:
124+
JOB_STATUS: ${{ job.status }}

0 commit comments

Comments
 (0)