Skip to content

Commit 4e12145

Browse files
authored
Add workflow to build and cache spicebench on trunk merges (#44)
* Add workflow to build and cache spicebench on trunk merges Pre-builds spicebench after each merge to trunk so that run_spicebench.yml gets cache hits and avoids redundant builds. * Extract build-spicebench into a reusable composite action Moves the spicebench build and cache logic into .github/actions/build-spicebench and reuses it in both cache_spicebench.yml and run_spicebench.yml.
1 parent 0b74811 commit 4e12145

3 files changed

Lines changed: 63 additions & 30 deletions

File tree

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: "Build spicebench"
2+
description: "Builds spicebench and caches the binary. Restores from cache if available."
3+
4+
inputs:
5+
lookup-only:
6+
description: "Only check if the cache exists, don't restore the binary"
7+
required: false
8+
default: "false"
9+
10+
runs:
11+
using: "composite"
12+
steps:
13+
- name: Restore spicebench cache
14+
id: cache-spicebench
15+
uses: actions/cache/restore@v4
16+
with:
17+
path: ~/.spice/bin/spicebench
18+
key: spicebench-${{ runner.os }}-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml', '**/*.rs') }}
19+
restore-keys: |
20+
spicebench-${{ runner.os }}-
21+
lookup-only: ${{ inputs.lookup-only }}
22+
23+
- name: Setup Rust toolchain
24+
if: steps.cache-spicebench.outputs.cache-hit != 'true'
25+
uses: actions-rust-lang/setup-rust-toolchain@v1
26+
with:
27+
toolchain: 1.91
28+
cache: true
29+
30+
- name: Build spicebench
31+
id: build-spicebench
32+
if: steps.cache-spicebench.outputs.cache-hit != 'true'
33+
shell: bash
34+
run: |
35+
mkdir -p ~/.spice/bin
36+
cargo build -p spicebench
37+
install -m 755 target/debug/spicebench ~/.spice/bin/spicebench
38+
39+
- name: Save spicebench cache
40+
if: steps.build-spicebench.outcome == 'success'
41+
uses: actions/cache/save@v4
42+
with:
43+
path: ~/.spice/bin/spicebench
44+
key: spicebench-${{ runner.os }}-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml', '**/*.rs') }}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Cache spicebench
2+
3+
on:
4+
push:
5+
branches:
6+
- trunk
7+
8+
jobs:
9+
build-and-cache:
10+
name: Build and cache spicebench
11+
runs-on: ubuntu-latest
12+
timeout-minutes: 30
13+
steps:
14+
- uses: actions/checkout@v6
15+
16+
- uses: ./.github/actions/build-spicebench
17+
with:
18+
lookup-only: "true"

.github/workflows/run_spicebench.yml

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -89,36 +89,7 @@ jobs:
8989
- name: pull spidapter image
9090
run: docker pull ghcr.io/spiceai/spidapter:latest
9191

92-
- name: Restore spicebench cache
93-
id: cache-spicebench
94-
uses: actions/cache/restore@v4
95-
with:
96-
path: ~/.spice/bin/spicebench
97-
key: spicebench-${{ runner.os }}-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml', '**/*.rs') }}
98-
restore-keys: |
99-
spicebench-${{ runner.os }}-
100-
101-
- name: Setup Rust toolchain
102-
if: steps.cache-spicebench.outputs.cache-hit != 'true'
103-
uses: actions-rust-lang/setup-rust-toolchain@v1
104-
with:
105-
toolchain: 1.91
106-
cache: true
107-
108-
- name: Build spicebench
109-
id: build-spicebench
110-
if: steps.cache-spicebench.outputs.cache-hit != 'true'
111-
run: |
112-
mkdir -p ~/.spice/bin
113-
cargo build -p spicebench
114-
install -m 755 target/debug/spicebench ~/.spice/bin/spicebench
115-
116-
- name: Save spicebench cache
117-
if: steps.build-spicebench.outcome == 'success'
118-
uses: actions/cache/save@v4
119-
with:
120-
path: ~/.spice/bin/spicebench
121-
key: spicebench-${{ runner.os }}-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml', '**/*.rs') }}
92+
- uses: ./.github/actions/build-spicebench
12293

12394
- name: Install ADBC FlightSQL driver
12495
run: |

0 commit comments

Comments
 (0)