Skip to content

Commit 4df2b7b

Browse files
committed
feat(ci): unify caching strategy across all build workflows
Implement consistent caching strategy across smol, SEA, and WASM builds: **Unified Strategy:** - Native C++ (smol): ccache + build directory cache - WASM C++ (Yoga, ONNX): build directory cache only - Non-C++ (AI, SEA): output cache only **Changes:** Smol build: - Move cache key generation before ccache setup (needs hash first) - Add build directory cache for CMake state and Node.js source - Update ccache key to include content hash - Preserves: ccache (object files) + build state (CMake) Yoga build: - Rename "Restore yoga build cache" → "Restore yoga output cache" - Add build directory cache for CMake state and Yoga source - Consistent with ONNX pattern ONNX build: - Already implemented (reference pattern) **Benefits:** - Consistent pattern across all C++ builds - Better failure recovery (preserve intermediate state) - Smol: Faster incremental builds with CMake cache - Yoga: Faster rebuilds (though already fast at 2-3 min) - ONNX: Already benefits from build cache (saves 30+ min on failures) **Cache Layers:** 1. Build tools (Python, Ninja, Emscripten) 2. Source code (.node-source/, .yoga-source/, .onnx-source/) 3. Intermediate build (CMake cache, compiled objects) 4. Compilation cache (ccache, native only) 5. Final output (dist/ artifacts)
1 parent a5adfd6 commit 4df2b7b

File tree

2 files changed

+30
-8
lines changed

2 files changed

+30
-8
lines changed

.github/workflows/build-smol.yml

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,20 +81,31 @@ jobs:
8181
- name: Install dependencies
8282
run: pnpm install --frozen-lockfile
8383

84-
- name: Setup ccache (Linux/macOS)
85-
if: matrix.os != 'windows'
86-
uses: hendrikmuhs/ccache-action@ed74d11c0b343532753ecead8a951bb09bb34bc9 # v1.2.14
87-
with:
88-
key: build-${{ matrix.platform }}-${{ matrix.arch }}
89-
max-size: 2G
90-
9184
- name: Generate smol build cache key
9285
id: smol-cache-key
9386
shell: bash
9487
run: |
9588
HASH=$(find patches packages/node-smol-builder/patches packages/node-smol-builder/additions scripts -type f \( -name "*.patch" -o -name "*.mjs" -o -name "*.h" -o -name "*.c" -o -name "*.cc" \) | sort | xargs sha256sum | sha256sum | cut -d' ' -f1)
9689
echo "hash=$HASH" >> $GITHUB_OUTPUT
9790
91+
- name: Setup ccache (Linux/macOS)
92+
if: matrix.os != 'windows'
93+
uses: hendrikmuhs/ccache-action@ed74d11c0b343532753ecead8a951bb09bb34bc9 # v1.2.14
94+
with:
95+
key: build-${{ matrix.platform }}-${{ matrix.arch }}-${{ steps.smol-cache-key.outputs.hash }}
96+
max-size: 2G
97+
98+
- name: Restore smol build cache
99+
id: smol-build-cache
100+
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
101+
with:
102+
path: |
103+
packages/node-smol-builder/build
104+
packages/node-smol-builder/.node-source
105+
key: node-smol-build-${{ matrix.platform }}-${{ matrix.arch }}-${{ steps.smol-cache-key.outputs.hash }}
106+
restore-keys: |
107+
node-smol-build-${{ matrix.platform }}-${{ matrix.arch }}-
108+
98109
- name: Restore smol binary cache
99110
id: smol-cache
100111
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0

.github/workflows/build-wasm.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,25 @@ jobs:
5454
HASH=$(find packages/yoga-layout -type f \( -name "*.cpp" -o -name "*.h" -o -name "*.mjs" -o -name "CMakeLists.txt" \) | sort | xargs sha256sum | sha256sum | cut -d' ' -f1)
5555
echo "hash=$HASH" >> $GITHUB_OUTPUT
5656
57-
- name: Restore yoga build cache
57+
- name: Restore yoga output cache
5858
id: yoga-cache
5959
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
6060
with:
6161
path: packages/yoga-layout/build/wasm
6262
key: yoga-wasm-${{ steps.yoga-cache-key.outputs.hash }}
6363
restore-keys: yoga-wasm-
6464

65+
- name: Restore yoga build cache
66+
id: yoga-build-cache
67+
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
68+
with:
69+
path: |
70+
packages/yoga-layout/build
71+
packages/yoga-layout/.yoga-source
72+
key: yoga-build-${{ steps.yoga-cache-key.outputs.hash }}
73+
restore-keys: |
74+
yoga-build-
75+
6576
- name: Verify cached artifacts
6677
id: yoga-cache-valid
6778
run: |

0 commit comments

Comments
 (0)