@@ -32,6 +32,9 @@ concurrency:
3232 group : ${{ github.workflow }}-${{ github.event_name }}-${{ github.event.number || github.run_id }}
3333 cancel-in-progress : true
3434
35+ env :
36+ KVROCKS_DEPS_CACHE_DIR : build-deps
37+
3538jobs :
3639 precondition :
3740 name : Precondition
@@ -65,22 +68,40 @@ jobs:
6568 with :
6669 config : .github/config/licenserc.yml
6770
71+ prepare-deps-cache :
72+ name : Prepare dependency cache
73+ needs : [precondition]
74+ if : ${{ needs.precondition.outputs.docs_only != 'true' }}
75+ runs-on : ubuntu-22.04
76+ steps :
77+ - uses : actions/checkout@v6
78+ - name : Cache Kvrocks dependencies
79+ id : cache-kvrocks-deps
80+ uses : actions/cache@v5
81+ with :
82+ path : ${{ env.KVROCKS_DEPS_CACHE_DIR }}
83+ key : kvrocks-full-deps-${{ hashFiles('x.py', 'CMakeLists.txt', 'cmake/**/*.cmake') }}
84+ enableCrossOsArchive : true
85+ - name : Warm Kvrocks dependency cache
86+ if : ${{ steps.cache-kvrocks-deps.outputs.cache-hit != 'true' }}
87+ run : |
88+ ./x.py build .github/ci-cache-default --skip-build --dep-dir ${{ env.KVROCKS_DEPS_CACHE_DIR }}
89+ ./x.py build .github/ci-cache-lua --skip-build --dep-dir ${{ env.KVROCKS_DEPS_CACHE_DIR }} -D ENABLE_LUAJIT=OFF
90+ rm -rf .github/ci-cache-default .github/ci-cache-lua
91+
6892 check-and-lint :
6993 name : Lint and check code
70- needs : [precondition, check-typos]
94+ needs : [precondition, check-typos, prepare-deps-cache ]
7195 if : ${{ needs.precondition.outputs.docs_only != 'true' }}
7296 runs-on : ubuntu-24.04
73- env :
74- DEPS_FETCH_DIR : build-deps
75- CMAKE_JEMALLOC_VARIANT : with-jemalloc
76- CMAKE_LUA_VARIANT : with-luajit
7797 steps :
7898 - uses : actions/checkout@v6
79- - name : Cache CMake dependency archives
99+ - name : Restore Kvrocks dependency cache
80100 uses : actions/cache@v5
81101 with :
82- path : ${{ env.DEPS_FETCH_DIR }}
83- key : ${{ format('cmake-fetch-archives-v1-{0}-{1}-{2}-{3}', 'ubuntu-24.04', env.CMAKE_JEMALLOC_VARIANT, env.CMAKE_LUA_VARIANT, hashFiles('CMakeLists.txt', 'cmake/**/*')) }}
102+ path : ${{ env.KVROCKS_DEPS_CACHE_DIR }}
103+ key : kvrocks-full-deps-${{ hashFiles('x.py', 'CMakeLists.txt', 'cmake/**/*.cmake') }}
104+ enableCrossOsArchive : true
84105 - uses : actions/setup-go@v6
85106 with :
86107 go-version-file : ' tests/gocase/go.mod'
96117 run : ./x.py check format --clang-format-path clang-format-18
97118 - name : Check with clang-tidy
98119 run : |
99- ./x.py build --skip-build --dep-dir "$DEPS_FETCH_DIR"
120+ ./x.py build --skip-build --dep-dir ${{ env.KVROCKS_DEPS_CACHE_DIR }}
100121 ./x.py check tidy -j $(nproc) --clang-tidy-path clang-tidy-18 --run-clang-tidy-path run-clang-tidy-18
101122 - name : Lint with golangci-lint
102123 run : ./x.py check golangci-lint
@@ -114,7 +135,7 @@ jobs:
114135
115136 build-and-test :
116137 name : Build and test
117- needs : [precondition, check-typos]
138+ needs : [precondition, check-typos, prepare-deps-cache ]
118139 if : ${{ needs.precondition.outputs.docs_only != 'true' }}
119140 strategy :
120141 fail-fast : false
@@ -245,9 +266,6 @@ jobs:
245266
246267 runs-on : ${{ matrix.os }}
247268 env :
248- DEPS_FETCH_DIR : build-deps
249- CMAKE_JEMALLOC_VARIANT : ${{ startsWith(matrix.os, 'macos') && 'without-jemalloc' || matrix.without_jemalloc && 'without-jemalloc' || 'with-jemalloc' }}
250- CMAKE_LUA_VARIANT : ${{ matrix.without_luajit && 'without-luajit' || 'with-luajit' }}
251269 SONARCLOUD_OUTPUT_DIR : sonarcloud-data
252270 FORCE_JAVASCRIPT_ACTIONS_TO_NODE20 : true
253271 RISCV_PATH : " /opt/riscv"
@@ -329,11 +347,12 @@ jobs:
329347 - uses : actions/checkout@v6
330348 with :
331349 fetch-depth : 0
332- - name : Cache CMake dependency archives
350+ - name : Restore Kvrocks dependency cache
333351 uses : actions/cache@v5
334352 with :
335- path : ${{ env.DEPS_FETCH_DIR }}
336- key : ${{ format('cmake-fetch-archives-v1-{0}-{1}-{2}-{3}', matrix.os, env.CMAKE_JEMALLOC_VARIANT, env.CMAKE_LUA_VARIANT, hashFiles('CMakeLists.txt', 'cmake/**/*')) }}
353+ path : ${{ env.KVROCKS_DEPS_CACHE_DIR }}
354+ key : kvrocks-full-deps-${{ hashFiles('x.py', 'CMakeLists.txt', 'cmake/**/*.cmake') }}
355+ enableCrossOsArchive : true
337356 - uses : actions/setup-python@v6
338357 if : ${{ !matrix.arm_linux }}
339358 with :
@@ -356,19 +375,19 @@ jobs:
356375 run : |
357376 ./x.py build -j$NPROC --unittest --compiler ${{ matrix.compiler }} ${{ matrix.without_jemalloc }} \
358377 ${{ matrix.without_luajit }} ${{ matrix.with_ninja }} ${{ matrix.with_sanitizer }} ${{ matrix.with_openssl }} \
359- ${{ matrix.new_encoding }} ${{ env.CMAKE_EXTRA_DEFS }} --dep-dir "$DEPS_FETCH_DIR"
378+ ${{ matrix.new_encoding }} ${{ env.CMAKE_EXTRA_DEFS }} --dep-dir ${{ env.KVROCKS_DEPS_CACHE_DIR }}
360379
361380 - name : Build Kvrocks (SonarCloud)
362381 if : ${{ matrix.sonarcloud }}
363382 run : |
364- build-wrapper-linux-x86-64 --out-dir ${{ env.SONARCLOUD_OUTPUT_DIR }} ./x.py build -j$NPROC --compiler ${{ matrix.compiler }} --skip-build --dep-dir "$DEPS_FETCH_DIR"
383+ 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 }}
365384 cp -r build _build
366- build-wrapper-linux-x86-64 --out-dir ${{ env.SONARCLOUD_OUTPUT_DIR }} ./x.py build -j$NPROC --unittest --compiler ${{ matrix.compiler }} ${{ matrix.sonarcloud }} --dep-dir "$DEPS_FETCH_DIR"
385+ 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 }}
367386
368387 - name : Build Kvrocks (RISC-V)
369388 if : ${{ matrix.riscv_toolchain }}
370389 run : |
371- ./x.py build -j$NPROC --unittest --toolchain ${{ matrix.toolchain_file }} --dep-dir "$DEPS_FETCH_DIR"
390+ ./x.py build -j$NPROC --unittest --toolchain ${{ matrix.toolchain_file }} --dep-dir ${{ env.KVROCKS_DEPS_CACHE_DIR }}
372391
373392 - name : Setup Coredump
374393 if : ${{ startsWith(matrix.os, 'ubuntu') }}
@@ -509,7 +528,7 @@ jobs:
509528
510529 build-and-test-in-container :
511530 name : Build and test in container
512- needs : [precondition, check-typos]
531+ needs : [precondition, check-typos, prepare-deps-cache ]
513532 if : ${{ needs.precondition.outputs.docs_only != 'true' }}
514533 strategy :
515534 fail-fast : false
@@ -536,10 +555,6 @@ jobs:
536555 disable_jemalloc : -DDISABLE_JEMALLOC=ON
537556
538557 runs-on : ubuntu-22.04
539- env :
540- DEPS_FETCH_DIR : build-deps
541- CMAKE_JEMALLOC_VARIANT : ${{ matrix.disable_jemalloc && 'without-jemalloc' || 'with-jemalloc' }}
542- CMAKE_LUA_VARIANT : with-luajit
543558 container :
544559 image : ${{ matrix.image }}
545560 volumes :
@@ -639,11 +654,12 @@ jobs:
639654 pushd redis-6.2.14 && USE_JEMALLOC=no make -j$NPROC redis-server && mv src/redis-server $HOME/local/bin/ && popd
640655
641656 - uses : actions/checkout@v6
642- - name : Cache CMake dependency archives
657+ - name : Restore Kvrocks dependency cache
643658 uses : actions/cache@v5
644659 with :
645- path : ${{ env.DEPS_FETCH_DIR }}
646- key : ${{ format('cmake-fetch-archives-v1-{0}-{1}-{2}-{3}', matrix.image, env.CMAKE_JEMALLOC_VARIANT, env.CMAKE_LUA_VARIANT, hashFiles('CMakeLists.txt', 'cmake/**/*')) }}
660+ path : ${{ env.KVROCKS_DEPS_CACHE_DIR }}
661+ key : kvrocks-full-deps-${{ hashFiles('x.py', 'CMakeLists.txt', 'cmake/**/*.cmake') }}
662+ enableCrossOsArchive : true
647663 - uses : actions/setup-go@v6
648664 if : ${{ !startsWith(matrix.image, 'opensuse') }}
649665 with :
@@ -652,7 +668,7 @@ jobs:
652668
653669 - name : Build Kvrocks
654670 run : |
655- ./x.py build -j$NPROC --unittest --compiler ${{ matrix.compiler }} ${{ matrix.disable_jemalloc }} --dep-dir "$DEPS_FETCH_DIR"
671+ ./x.py build -j$NPROC --unittest --compiler ${{ matrix.compiler }} ${{ matrix.disable_jemalloc }} --dep-dir ${{ env.KVROCKS_DEPS_CACHE_DIR }}
656672
657673 - name : Run Unit Test
658674 run : |
0 commit comments