Skip to content

Commit 7ad6d00

Browse files
committed
[puter] ci: don't install rust deps if cache hit
1 parent d662f5c commit 7ad6d00

File tree

2 files changed

+26
-17
lines changed

2 files changed

+26
-17
lines changed

.github/workflows/main.yml

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,36 +38,40 @@ jobs:
3838
- name: Install pnpm dependencies
3939
run: pnpm install
4040

41+
- name: Cache rewriter build artifacts
42+
uses: actions/cache@v4
43+
id: rewriter-cache
44+
with:
45+
path: |
46+
rewriter/wasm/out
47+
dist/scramjet.wasm.wasm
48+
key: rewriter-release-${{ hashFiles('rewriter/wasm/Cargo.toml', 'rewriter/wasm/src/**/*.rs', 'rewriter/wasm/build.sh') }}
49+
restore-keys: |
50+
rewriter-release-
51+
4152
- name: Cache Rust dependencies
53+
if: steps.rewriter-cache.outputs.cache-hit != 'true'
4254
uses: Swatinem/rust-cache@v2
4355
with:
4456
workspaces: "rewriter"
4557
cache-all-crates: true
4658

4759
- name: Install wbg
60+
if: steps.rewriter-cache.outputs.cache-hit != 'true'
4861
uses: jetli/[email protected]
4962
with:
5063
version: "0.2.100"
5164

5265
- name: Setup Binaryen
66+
if: steps.rewriter-cache.outputs.cache-hit != 'true'
5367
uses: Aandreba/[email protected]
5468
with:
5569
token: ${{ github.token }}
5670

5771
- name: Setup wasm-snip
72+
if: steps.rewriter-cache.outputs.cache-hit != 'true'
5873
run: "cargo install --git https://github.com/r58playz/wasm-snip"
5974

60-
- name: Cache rewriter build artifacts
61-
uses: actions/cache@v4
62-
id: rewriter-cache
63-
with:
64-
path: |
65-
rewriter/wasm/out
66-
dist/scramjet.wasm.wasm
67-
key: rewriter-release-${{ hashFiles('rewriter/wasm/Cargo.toml', 'rewriter/wasm/src/**/*.rs', 'rewriter/wasm/build.sh') }}
68-
restore-keys: |
69-
rewriter-release-
70-
7175
- name: Pack Scramjet
7276
run: pnpm pack
7377

rewriter/wasm/build.sh

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,8 @@ else
2121
: "${FEATURES:=}"
2222
fi
2323

24-
# ----------------------------------------------------------------------------------
25-
# Build cache short‑circuit: if sources & build parameters unchanged, skip heavy work
26-
# We rely on CI (and local dev optional) to restore rewriter/wasm/out + dist/ wasm file.
27-
# Hash includes Rust source files, manifest, this script, and release/debug mode.
28-
# ----------------------------------------------------------------------------------
2924
MODE="release"
3025
if [ "${RELEASE:-0}" != "1" ]; then MODE="debug"; fi
31-
HASH_INPUT_FILES=(src/**/*.rs Cargo.toml build.sh)
3226
# shellcheck disable=SC2046
3327
SRC_HASH=$( (echo "MODE=${MODE}"; sha256sum $(git ls-files -z -- "src" | tr '\0' ' ' 2>/dev/null || find src -type f -name '*.rs'; echo Cargo.toml; echo build.sh) 2>/dev/null | sort -k2 | sha256sum ) | sha256sum | cut -d' ' -f1 ) || SRC_HASH="unknown"
3428

@@ -37,6 +31,17 @@ if [ -f out/.build-hash ] && [ -f ../../dist/scramjet.wasm.wasm ] && [ "$SRC_HAS
3731
exit 0
3832
fi
3933

34+
which cargo wasm-bindgen wasm-opt wasm-snip &> /dev/null || {
35+
echo "Please install cargo, wasm-bindgen, wasm-opt from https://github.com/WebAssembly/binaryen, and wasm-snip from https://github.com/r58playz/wasm-snip!"
36+
exit 1
37+
}
38+
39+
WBG="wasm-bindgen 0.2.100"
40+
if ! [[ "$(wasm-bindgen -V)" =~ ^"$WBG" ]]; then
41+
echo "Incorrect wasm-bindgen-cli version: '$(wasm-bindgen -V)' != '$WBG'"
42+
exit 1
43+
fi
44+
4045
(
4146
export RUSTFLAGS='-Zlocation-detail=none -Zfmt-debug=none'
4247
if [ "${OPTIMIZE_FOR_SIZE:-0}" = "1" ]; then

0 commit comments

Comments
 (0)