This is an automated email from the ASF dual-hosted git repository.
jihuayu pushed a commit to branch unstable
in repository https://gitbox.apache.org/repos/asf/kvrocks.git
The following commit(s) were added to refs/heads/unstable by this push:
new d942f530a feat(ci): add caching for CMake FetchContent in CI workflow
(#3448)
d942f530a is described below
commit d942f530af1bdbf442dd0ae063bb77c1965ff510
Author: 纪华裕 <[email protected]>
AuthorDate: Wed Apr 15 15:38:09 2026 +0800
feat(ci): add caching for CMake FetchContent in CI workflow (#3448)
Due to the current instability of GitHub services, dependency download
failures occur frequently during CI runs. I add FetchContent caching to
prevent these network issues from failing the CI.
---
.github/workflows/kvrocks.yaml | 39 +++++++++++++++++++++++++++++++++------
x.py | 6 ++++--
2 files changed, 37 insertions(+), 8 deletions(-)
diff --git a/.github/workflows/kvrocks.yaml b/.github/workflows/kvrocks.yaml
index f9c0228e6..fda6d3c20 100644
--- a/.github/workflows/kvrocks.yaml
+++ b/.github/workflows/kvrocks.yaml
@@ -32,6 +32,9 @@ concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{
github.event.number || github.run_id }}
cancel-in-progress: true
+env:
+ KVROCKS_DEPS_CACHE_DIR: build-deps
+
jobs:
precondition:
name: Precondition
@@ -72,6 +75,18 @@ jobs:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v6
+ - name: Restore Kvrocks dependency cache
+ id: cache-kvrocks-deps
+ uses: actions/cache@v5
+ with:
+ path: ${{ env.KVROCKS_DEPS_CACHE_DIR }}
+ key: kvrocks-full-deps-${{ hashFiles('x.py', 'CMakeLists.txt',
'cmake/**/*.cmake') }}
+ enableCrossOsArchive: true
+ - name: Fetch Kvrocks dependencies
+ if: ${{ steps.cache-kvrocks-deps.outputs.cache-hit != 'true' }}
+ run: |
+ ./x.py fetch-deps ${{ env.KVROCKS_DEPS_CACHE_DIR }}
+ ./x.py fetch-deps ${{ env.KVROCKS_DEPS_CACHE_DIR }} -D
ENABLE_LUAJIT=OFF
- uses: actions/setup-go@v6
with:
go-version-file: 'tests/gocase/go.mod'
@@ -87,7 +102,7 @@ jobs:
run: ./x.py check format --clang-format-path clang-format-18
- name: Check with clang-tidy
run: |
- ./x.py build --skip-build
+ ./x.py build --skip-build --dep-dir ${{ env.KVROCKS_DEPS_CACHE_DIR }}
./x.py check tidy -j $(nproc) --clang-tidy-path clang-tidy-18
--run-clang-tidy-path run-clang-tidy-18
- name: Lint with golangci-lint
run: ./x.py check golangci-lint
@@ -317,6 +332,12 @@ jobs:
- uses: actions/checkout@v6
with:
fetch-depth: 0
+ - name: Restore Kvrocks dependency cache
+ uses: actions/cache@v5
+ with:
+ path: ${{ env.KVROCKS_DEPS_CACHE_DIR }}
+ key: kvrocks-full-deps-${{ hashFiles('x.py', 'CMakeLists.txt',
'cmake/**/*.cmake') }}
+ enableCrossOsArchive: true
- uses: actions/setup-python@v6
if: ${{ !matrix.arm_linux }}
with:
@@ -339,19 +360,19 @@ jobs:
run: |
./x.py build -j$NPROC --unittest --compiler ${{ matrix.compiler }}
${{ matrix.without_jemalloc }} \
${{ matrix.without_luajit }} ${{ matrix.with_ninja }} ${{
matrix.with_sanitizer }} ${{ matrix.with_openssl }} \
- ${{ matrix.new_encoding }} ${{ env.CMAKE_EXTRA_DEFS }}
+ ${{ matrix.new_encoding }} ${{ env.CMAKE_EXTRA_DEFS }} --dep-dir
${{ env.KVROCKS_DEPS_CACHE_DIR }}
- name: Build Kvrocks (SonarCloud)
if: ${{ matrix.sonarcloud }}
run: |
- build-wrapper-linux-x86-64 --out-dir ${{ env.SONARCLOUD_OUTPUT_DIR
}} ./x.py build -j$NPROC --compiler ${{ matrix.compiler }} --skip-build
+ build-wrapper-linux-x86-64 --out-dir ${{ env.SONARCLOUD_OUTPUT_DIR
}} ./x.py build -j$NPROC --compiler ${{ matrix.compiler }} --skip-build
--dep-dir ${{ env.KVROCKS_DEPS_CACHE_DIR }}
cp -r build _build
- build-wrapper-linux-x86-64 --out-dir ${{ env.SONARCLOUD_OUTPUT_DIR
}} ./x.py build -j$NPROC --unittest --compiler ${{ matrix.compiler }} ${{
matrix.sonarcloud }}
+ build-wrapper-linux-x86-64 --out-dir ${{ env.SONARCLOUD_OUTPUT_DIR
}} ./x.py build -j$NPROC --unittest --compiler ${{ matrix.compiler }} ${{
matrix.sonarcloud }} --dep-dir ${{ env.KVROCKS_DEPS_CACHE_DIR }}
- name: Build Kvrocks (RISC-V)
if: ${{ matrix.riscv_toolchain }}
run: |
- ./x.py build -j$NPROC --unittest --toolchain ${{
matrix.toolchain_file }}
+ ./x.py build -j$NPROC --unittest --toolchain ${{
matrix.toolchain_file }} --dep-dir ${{ env.KVROCKS_DEPS_CACHE_DIR }}
- name: Setup Coredump
if: ${{ startsWith(matrix.os, 'ubuntu') }}
@@ -618,6 +639,12 @@ jobs:
pushd redis-6.2.14 && USE_JEMALLOC=no make -j$NPROC redis-server &&
mv src/redis-server $HOME/local/bin/ && popd
- uses: actions/checkout@v6
+ - name: Restore Kvrocks dependency cache
+ uses: actions/cache@v5
+ with:
+ path: ${{ env.KVROCKS_DEPS_CACHE_DIR }}
+ key: kvrocks-full-deps-${{ hashFiles('x.py', 'CMakeLists.txt',
'cmake/**/*.cmake') }}
+ enableCrossOsArchive: true
- uses: actions/setup-go@v6
if: ${{ !startsWith(matrix.image, 'opensuse') }}
with:
@@ -626,7 +653,7 @@ jobs:
- name: Build Kvrocks
run: |
- ./x.py build -j$NPROC --unittest --compiler ${{ matrix.compiler }}
${{ matrix.disable_jemalloc }}
+ ./x.py build -j$NPROC --unittest --compiler ${{ matrix.compiler }}
${{ matrix.disable_jemalloc }} --dep-dir ${{ env.KVROCKS_DEPS_CACHE_DIR }}
- name: Run Unit Test
run: |
diff --git a/x.py b/x.py
index ee28fea38..d5e9dfa9b 100755
--- a/x.py
+++ b/x.py
@@ -162,10 +162,10 @@ def build(dir: str, jobs: Optional[int] = None, ninja:
bool = False, unittest: b
run(cmake, *options, verbose=True, cwd=dir)
-def fetch_deps(dir: str) -> None:
+def fetch_deps(dir: str, D: List[str] = []) -> None:
dir = os.path.abspath(dir)
with TemporaryDirectory(prefix="kvrocks-fetch-deps-") as build_dir:
- build(build_dir, dep_dir=dir, skip_build=True)
+ build(build_dir, D=D, dep_dir=dir, skip_build=True)
def get_source_files(dir: Path) -> List[str]:
@@ -418,6 +418,8 @@ if __name__ == '__main__':
)
parser_fetch_deps.add_argument('dir', metavar='DEP_DIR', nargs='?',
default='build-deps',
help="directory to store fetched archives of
dependencies")
+ parser_fetch_deps.add_argument('-D', action='append', metavar='key=value',
+ help='extra CMake definitions used to determine
fetched dependencies')
parser_fetch_deps.set_defaults(func=fetch_deps)
parser_package = subparsers.add_parser(