Skip to content

Commit b698da8

Browse files
committed
feat(ci): refactor dependency fetching and update arguments for improved flexibility
1 parent 64835ab commit b698da8

File tree

2 files changed

+13
-26
lines changed

2 files changed

+13
-26
lines changed

.github/workflows/kvrocks.yaml

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -68,40 +68,25 @@ jobs:
6868
with:
6969
config: .github/config/licenserc.yml
7070

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-
9271
check-and-lint:
9372
name: Lint and check code
94-
needs: [precondition, check-typos, prepare-deps-cache]
73+
needs: [precondition, check-typos]
9574
if: ${{ needs.precondition.outputs.docs_only != 'true' }}
9675
runs-on: ubuntu-24.04
9776
steps:
9877
- uses: actions/checkout@v6
9978
- name: Restore Kvrocks dependency cache
79+
id: cache-kvrocks-deps
10080
uses: actions/cache@v5
10181
with:
10282
path: ${{ env.KVROCKS_DEPS_CACHE_DIR }}
10383
key: kvrocks-full-deps-${{ hashFiles('x.py', 'CMakeLists.txt', 'cmake/**/*.cmake') }}
10484
enableCrossOsArchive: true
85+
- name: Fetch Kvrocks dependencies
86+
if: ${{ steps.cache-kvrocks-deps.outputs.cache-hit != 'true' }}
87+
run: |
88+
./x.py fetch-deps ${{ env.KVROCKS_DEPS_CACHE_DIR }}
89+
./x.py fetch-deps ${{ env.KVROCKS_DEPS_CACHE_DIR }} -D ENABLE_LUAJIT=OFF
10590
- uses: actions/setup-go@v6
10691
with:
10792
go-version-file: 'tests/gocase/go.mod'
@@ -135,7 +120,7 @@ jobs:
135120

136121
build-and-test:
137122
name: Build and test
138-
needs: [precondition, check-typos, prepare-deps-cache]
123+
needs: [precondition, check-typos]
139124
if: ${{ needs.precondition.outputs.docs_only != 'true' }}
140125
strategy:
141126
fail-fast: false
@@ -528,7 +513,7 @@ jobs:
528513
529514
build-and-test-in-container:
530515
name: Build and test in container
531-
needs: [precondition, check-typos, prepare-deps-cache]
516+
needs: [precondition, check-typos]
532517
if: ${{ needs.precondition.outputs.docs_only != 'true' }}
533518
strategy:
534519
fail-fast: false

x.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,10 @@ def build(dir: str, jobs: Optional[int] = None, ninja: bool = False, unittest: b
162162
run(cmake, *options, verbose=True, cwd=dir)
163163

164164

165-
def fetch_deps(dir: str) -> None:
165+
def fetch_deps(dir: str, D: List[str] = []) -> None:
166166
dir = os.path.abspath(dir)
167167
with TemporaryDirectory(prefix="kvrocks-fetch-deps-") as build_dir:
168-
build(build_dir, dep_dir=dir, skip_build=True)
168+
build(build_dir, D=D, dep_dir=dir, skip_build=True)
169169

170170

171171
def get_source_files(dir: Path) -> List[str]:
@@ -418,6 +418,8 @@ def test_go(dir: str, cli_path: str, rest: List[str]) -> None:
418418
)
419419
parser_fetch_deps.add_argument('dir', metavar='DEP_DIR', nargs='?', default='build-deps',
420420
help="directory to store fetched archives of dependencies")
421+
parser_fetch_deps.add_argument('-D', action='append', metavar='key=value',
422+
help='extra CMake definitions used to determine fetched dependencies')
421423
parser_fetch_deps.set_defaults(func=fetch_deps)
422424

423425
parser_package = subparsers.add_parser(

0 commit comments

Comments
 (0)