@@ -103,6 +103,15 @@ jobs:
103103 runs-on : ${{ matrix.os }}
104104
105105 steps :
106+ - name : Set Cargo output root
107+ shell : bash
108+ run : |
109+ if [[ "$RUNNER_OS" == "Windows" ]]; then
110+ echo "CARGO_TARGET_DIR=$(cygpath -m "$RUNNER_TEMP")/lk-rust" >> "$GITHUB_ENV"
111+ else
112+ echo "CARGO_TARGET_DIR=$GITHUB_WORKSPACE/client-sdk-rust/target" >> "$GITHUB_ENV"
113+ fi
114+
106115 - name : Checkout (with submodules)
107116 uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
108117 with :
@@ -222,17 +231,19 @@ jobs:
222231 id : cache-cargo-target
223232 uses : actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
224233 with :
225- path : client-sdk-rust/target/
226- key : ${{ matrix.os }}-${{ matrix.name }}-cargo-target-${{ steps.rust_sha.outputs.sha }}
234+ path : |
235+ client-sdk-rust/target/
236+ ${{ env.CARGO_TARGET_DIR }}
237+ key : ${{ matrix.os }}-${{ matrix.name }}-cargo-target-v2-${{ steps.rust_sha.outputs.sha }}
227238 restore-keys : |
228- ${{ matrix.os }}-${{ matrix.name }}-cargo-target-
239+ ${{ matrix.os }}-${{ matrix.name }}-cargo-target-v2-
229240
230241 # restore-keys can hydrate target/ from a prior submodule SHA. cxxbridge
231242 # artifacts in webrtc-sys are not compatible across those bumps.
232243 - name : Drop stale cargo target on submodule SHA cache miss
233244 if : steps.cache-cargo-target.outputs.cache-hit != 'true'
234245 shell : bash
235- run : rm -rf client-sdk-rust/target/
246+ run : rm -rf client-sdk-rust/target/ "$CARGO_TARGET_DIR"
236247
237248 # ---------- Build environment setup ----------
238249 - name : Set Linux build environment
@@ -265,8 +276,10 @@ jobs:
265276 if : github.event_name == 'push' && github.ref == 'refs/heads/main' && steps.cache-cargo-target.outputs.cache-hit != 'true'
266277 uses : actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
267278 with :
268- path : client-sdk-rust/target/
269- key : ${{ matrix.os }}-${{ matrix.name }}-cargo-target-${{ steps.rust_sha.outputs.sha }}
279+ path : |
280+ client-sdk-rust/target/
281+ ${{ env.CARGO_TARGET_DIR }}
282+ key : ${{ matrix.os }}-${{ matrix.name }}-cargo-target-v2-${{ steps.rust_sha.outputs.sha }}
270283
271284 - name : Save vcpkg binary cache
272285 if : runner.os == 'Windows' && steps.cache-vcpkg-binary.outputs.cache-hit != 'true'
0 commit comments