This is an automated email from the ASF dual-hosted git repository.
chaokunyang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/fory.git
The following commit(s) were added to refs/heads/main by this push:
new 2d6d15447 chore(CI): Add caching for bazel in github workflows (#2888)
2d6d15447 is described below
commit 2d6d15447c754dd88524d27520192a426bd5cb3b
Author: Prakash Kumar Ramesh <[email protected]>
AuthorDate: Tue Nov 4 11:36:02 2025 -0500
chore(CI): Add caching for bazel in github workflows (#2888)
<!--
**Thanks for contributing to Apache Fory™.**
**If this is your first time opening a PR on fory, you can refer to
[CONTRIBUTING.md](https://github.com/apache/fory/blob/main/CONTRIBUTING.md).**
Contribution Checklist
- The **Apache Fory™** community has requirements on the naming of pr
titles. You can also find instructions in
[CONTRIBUTING.md](https://github.com/apache/fory/blob/main/CONTRIBUTING.md).
- Apache Fory™ has a strong focus on performance. If the PR you submit
will have an impact on performance, please benchmark it first and
provide the benchmark result here.
-->
## Why?
Due to lack of caching of bazel, every CI run takes too much time
with cache:
<img width="2613" height="1585" alt="image"
src="https://github.com/user-attachments/assets/bcc1b6f5-4512-4f92-9845-cb9df657cb74"
/>
without cache:
<img width="2282" height="564" alt="image"
src="https://github.com/user-attachments/assets/ec5740ff-f915-46fd-b58a-bf941576c316"
/>
<!-- Describe the purpose of this PR. -->
## What does this PR do?
This PR adds caching for bazel in github workflows
<!-- Describe the details of this PR. -->
## Related issues
closes #2880
<!--
Is there any related issue? If this PR closes them you say say
fix/closes:
- #xxxx0
- #xxxx1
- Fixes #xxxx2
-->
---
.github/workflows/build-containerized-release.yml | 26 +++++
.github/workflows/build-native-pr.yml | 29 ++++++
.github/workflows/build-native-release.yml | 29 ++++++
.github/workflows/ci.yml | 119 +++++++++++++++++++++-
4 files changed, 201 insertions(+), 2 deletions(-)
diff --git a/.github/workflows/build-containerized-release.yml
b/.github/workflows/build-containerized-release.yml
index c3d1d4afc..1b0cc0770 100644
--- a/.github/workflows/build-containerized-release.yml
+++ b/.github/workflows/build-containerized-release.yml
@@ -31,6 +31,32 @@ jobs:
- name: Bump version
# Pass the tag name from the push (e.g. "v0.12.1b1"); deploy.sh will
strip leading "v".
run: ./ci/deploy.sh bump_py_version "${{ github.ref_name }}"
+ - name: Set up Python 3.8
+ uses: actions/setup-python@v5
+ with:
+ python-version: 3.8
+ cache: 'pip'
+ - name: Cache Bazel binary
+ uses: actions/cache@v4
+ with:
+ path: |
+ ~/bin/bazel
+ ~/.local/bin/bazel
+ key: bazel-binary-${{ runner.os }}-${{ runner.arch }}-${{
hashFiles('.bazelversion') }}
+ restore-keys: |
+ bazel-binary-${{ runner.os }}-${{ runner.arch }}-
+ - name: Cache Bazel repository cache
+ uses: actions/cache@v4
+ with:
+ path: ~/.cache/bazel/_bazel_*/*/external
+ key: bazel-repo-${{ runner.os }}-${{ runner.arch }}-py38-${{
hashFiles('WORKSPACE', '.bazelrc', 'bazel/**') }}
+ restore-keys: |
+ bazel-repo-${{ runner.os }}-${{ runner.arch }}-py38-
+ - name: Cache Bazel build outputs
+ uses: actions/cache@v4
+ with:
+ path: ~/.cache/bazel
+ key: bazel-build-release-${{ runner.os }}-${{ runner.arch }}-${{
hashFiles('cpp/**', 'python/**/*.pyx', 'python/**/*.pxd', 'BUILD', 'WORKSPACE')
}}
- name: Install bazel
run: ./ci/run_ci.sh install_bazel
- name: Build and test wheels
diff --git a/.github/workflows/build-native-pr.yml
b/.github/workflows/build-native-pr.yml
index 9a5150235..11f5d308d 100644
--- a/.github/workflows/build-native-pr.yml
+++ b/.github/workflows/build-native-pr.yml
@@ -35,6 +35,35 @@ jobs:
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
+ cache: 'pip'
+ - name: Cache Bazel binary
+ uses: actions/cache@v4
+ with:
+ path: |
+ ~/bin/bazel
+ ~/.local/bin/bazel
+ C:\bazel\bazel.exe
+ key: bazel-binary-${{ runner.os }}-${{ runner.arch }}-${{
hashFiles('.bazelversion') }}
+ restore-keys: |
+ bazel-binary-${{ runner.os }}-${{ runner.arch }}-
+ - name: Cache Bazel repository cache
+ uses: actions/cache@v4
+ with:
+ path: |
+ ~/.cache/bazel/_bazel_*/*/external
+ ~/Library/Caches/bazel/_bazel_*/*/external
+ C:\users\runneradmin\_bazel_runneradmin\*/external
+ key: bazel-repo-${{ runner.os }}-${{ runner.arch }}-${{
matrix.python-version }}-${{ hashFiles('WORKSPACE', '.bazelrc', 'bazel/**') }}
+ restore-keys: |
+ bazel-repo-${{ runner.os }}-${{ runner.arch }}-${{
matrix.python-version }}-
+ - name: Cache Bazel build outputs
+ uses: actions/cache@v4
+ with:
+ path: |
+ ~/.cache/bazel
+ ~/Library/Caches/bazel
+ C:\users\runneradmin\_bazel_runneradmin
+ key: bazel-build-${{ runner.os }}-${{ runner.arch }}-${{
matrix.python-version }}-${{ hashFiles('cpp/**', 'python/**/*.pyx',
'python/**/*.pxd', 'BUILD', 'WORKSPACE') }}
- name: Install bazel
if: runner.os != 'Windows'
run: ./ci/run_ci.sh install_bazel
diff --git a/.github/workflows/build-native-release.yml
b/.github/workflows/build-native-release.yml
index 2ef8248c8..d5ba74d36 100644
--- a/.github/workflows/build-native-release.yml
+++ b/.github/workflows/build-native-release.yml
@@ -36,6 +36,35 @@ jobs:
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
+ cache: 'pip'
+ - name: Cache Bazel binary
+ uses: actions/cache@v4
+ with:
+ path: |
+ ~/bin/bazel
+ ~/.local/bin/bazel
+ C:\bazel\bazel.exe
+ key: bazel-binary-${{ runner.os }}-${{ runner.arch }}-${{
hashFiles('.bazelversion') }}
+ restore-keys: |
+ bazel-binary-${{ runner.os }}-${{ runner.arch }}-
+ - name: Cache Bazel repository cache
+ uses: actions/cache@v4
+ with:
+ path: |
+ ~/.cache/bazel/_bazel_*/*/external
+ ~/Library/Caches/bazel/_bazel_*/*/external
+ C:\users\runneradmin\_bazel_runneradmin\*/external
+ key: bazel-repo-${{ runner.os }}-${{ runner.arch }}-${{
matrix.python-version }}-${{ hashFiles('WORKSPACE', '.bazelrc', 'bazel/**') }}
+ restore-keys: |
+ bazel-repo-${{ runner.os }}-${{ runner.arch }}-${{
matrix.python-version }}-
+ - name: Cache Bazel build outputs
+ uses: actions/cache@v4
+ with:
+ path: |
+ ~/.cache/bazel
+ ~/Library/Caches/bazel
+ C:\users\runneradmin\_bazel_runneradmin
+ key: bazel-build-release-native-${{ runner.os }}-${{ runner.arch
}}-${{ matrix.python-version }}-${{ hashFiles('cpp/**', 'python/**/*.pyx',
'python/**/*.pxd', 'BUILD', 'WORKSPACE') }}
- name: Install bazel
if: runner.os != 'Windows'
run: ./ci/run_ci.sh install_bazel
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 7fa10156d..d7cece055 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -65,6 +65,28 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: 3.8
+ cache: 'pip'
+ - name: Cache Bazel binary
+ uses: actions/cache@v4
+ with:
+ path: |
+ ~/bin/bazel
+ ~/.local/bin/bazel
+ key: bazel-binary-${{ runner.os }}-${{ runner.arch }}-${{
hashFiles('.bazelversion') }}
+ restore-keys: |
+ bazel-binary-${{ runner.os }}-${{ runner.arch }}-
+ - name: Cache Bazel repository cache
+ uses: actions/cache@v4
+ with:
+ path: ~/.cache/bazel/_bazel_*/*/external
+ key: bazel-repo-${{ runner.os }}-${{ runner.arch }}-py38-${{
hashFiles('WORKSPACE', '.bazelrc', 'bazel/**') }}
+ restore-keys: |
+ bazel-repo-${{ runner.os }}-${{ runner.arch }}-py38-
+ - name: Cache Bazel build outputs
+ uses: actions/cache@v4
+ with:
+ path: ~/.cache/bazel
+ key: bazel-build-java-${{ runner.os }}-${{ runner.arch }}-${{
matrix.java-version }}-${{ hashFiles('cpp/**', 'python/**/*.pyx',
'python/**/*.pxd', 'BUILD', 'WORKSPACE') }}
- name: Install bazel
run: python ./ci/run_ci.py cpp --install-deps-only
- name: Install python dependencies
@@ -107,6 +129,28 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: 3.8
+ cache: 'pip'
+ - name: Cache Bazel binary
+ uses: actions/cache@v4
+ with:
+ path: |
+ ~/bin/bazel
+ ~/.local/bin/bazel
+ key: bazel-binary-${{ runner.os }}-${{ runner.arch }}-${{
hashFiles('.bazelversion') }}
+ restore-keys: |
+ bazel-binary-${{ runner.os }}-${{ runner.arch }}-
+ - name: Cache Bazel repository cache
+ uses: actions/cache@v4
+ with:
+ path: ~/.cache/bazel/_bazel_*/*/external
+ key: bazel-repo-${{ runner.os }}-${{ runner.arch }}-py38-${{
hashFiles('WORKSPACE', '.bazelrc', 'bazel/**') }}
+ restore-keys: |
+ bazel-repo-${{ runner.os }}-${{ runner.arch }}-py38-
+ - name: Cache Bazel build outputs
+ uses: actions/cache@v4
+ with:
+ path: ~/.cache/bazel
+ key: bazel-build-openj9-${{ runner.os }}-${{ runner.arch }}-${{
matrix.java-version }}-${{ hashFiles('cpp/**', 'python/**/*.pyx',
'python/**/*.pxd', 'BUILD', 'WORKSPACE') }}
- name: Install bazel
run: python ./ci/run_ci.py cpp --install-deps-only
- name: Install pyfory for xlang tests
@@ -324,6 +368,35 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: 3.11
+ cache: 'pip'
+ - name: Cache Bazel binary
+ uses: actions/cache@v4
+ with:
+ path: |
+ ~/bin/bazel
+ ~/.local/bin/bazel
+ C:\bazel\bazel.exe
+ key: bazel-binary-${{ runner.os }}-${{ runner.arch }}-${{
hashFiles('.bazelversion') }}
+ restore-keys: |
+ bazel-binary-${{ runner.os }}-${{ runner.arch }}-
+ - name: Cache Bazel repository cache
+ uses: actions/cache@v4
+ with:
+ path: |
+ ~/.cache/bazel/_bazel_*/*/external
+ ~/Library/Caches/bazel/_bazel_*/*/external
+ C:\users\runneradmin\_bazel_runneradmin\*/external
+ key: bazel-repo-${{ runner.os }}-${{ runner.arch }}-py311-${{
hashFiles('WORKSPACE', '.bazelrc', 'bazel/**') }}
+ restore-keys: |
+ bazel-repo-${{ runner.os }}-${{ runner.arch }}-py311-
+ - name: Cache Bazel build outputs
+ uses: actions/cache@v4
+ with:
+ path: |
+ ~/.cache/bazel
+ ~/Library/Caches/bazel
+ C:\users\runneradmin\_bazel_runneradmin
+ key: bazel-build-cpp-${{ runner.os }}-${{ runner.arch }}-${{
hashFiles('cpp/**', 'BUILD', 'WORKSPACE') }}
- name: Run C++ CI with Bazel
run: python ./ci/run_ci.py cpp
python:
@@ -339,15 +412,35 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
+ cache: 'pip'
- name: Cache Bazel binary
uses: actions/cache@v4
with:
path: |
~/bin/bazel
~/.local/bin/bazel
- key: bazel-${{ runner.os }}-${{ runner.arch }}-${{
hashFiles('.bazelversion') }}
+ C:\bazel\bazel.exe
+ key: bazel-binary-${{ runner.os }}-${{ runner.arch }}-${{
hashFiles('.bazelversion') }}
restore-keys: |
- bazel-${{ runner.os }}-${{ runner.arch }}-
+ bazel-binary-${{ runner.os }}-${{ runner.arch }}-
+ - name: Cache Bazel repository cache
+ uses: actions/cache@v4
+ with:
+ path: |
+ ~/.cache/bazel/_bazel_*/*/external
+ ~/Library/Caches/bazel/_bazel_*/*/external
+ C:\users\runneradmin\_bazel_runneradmin\*/external
+ key: bazel-repo-${{ runner.os }}-${{ runner.arch }}-${{
matrix.python-version }}-${{ hashFiles('WORKSPACE', '.bazelrc', 'bazel/**') }}
+ restore-keys: |
+ bazel-repo-${{ runner.os }}-${{ runner.arch }}-${{
matrix.python-version }}-
+ - name: Cache Bazel build outputs
+ uses: actions/cache@v4
+ with:
+ path: |
+ ~/.cache/bazel
+ ~/Library/Caches/bazel
+ C:\users\runneradmin\_bazel_runneradmin
+ key: bazel-build-python-${{ runner.os }}-${{ runner.arch }}-${{
matrix.python-version }}-${{ hashFiles('cpp/**', 'python/**/*.pyx',
'python/**/*.pxd', 'BUILD', 'WORKSPACE') }}
- name: Install bazel (Unix)
if: runner.os != 'Windows'
shell: bash
@@ -378,6 +471,28 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: 3.8
+ cache: 'pip'
+ - name: Cache Bazel binary
+ uses: actions/cache@v4
+ with:
+ path: |
+ ~/bin/bazel
+ ~/.local/bin/bazel
+ key: bazel-binary-${{ runner.os }}-${{ runner.arch }}-${{
hashFiles('.bazelversion') }}
+ restore-keys: |
+ bazel-binary-${{ runner.os }}-${{ runner.arch }}-
+ - name: Cache Bazel repository cache
+ uses: actions/cache@v4
+ with:
+ path: ~/.cache/bazel/_bazel_*/*/external
+ key: bazel-repo-${{ runner.os }}-${{ runner.arch }}-py38-${{
hashFiles('WORKSPACE', '.bazelrc', 'bazel/**') }}
+ restore-keys: |
+ bazel-repo-${{ runner.os }}-${{ runner.arch }}-py38-
+ - name: Cache Bazel build outputs
+ uses: actions/cache@v4
+ with:
+ path: ~/.cache/bazel
+ key: bazel-build-go-${{ runner.os }}-${{ runner.arch }}-${{
matrix.go-version }}-${{ hashFiles('cpp/**', 'python/**/*.pyx',
'python/**/*.pxd', 'BUILD', 'WORKSPACE') }}
- name: Install bazel
run: python ./ci/run_ci.py cpp --install-deps-only
- name: Install python dependencies
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]