fix(ci): restore cross-platform Rust compilation caches

This commit is contained in:
Disy committed 2026-10-21 09:40:46 +08:00
1 parent c44fb1a0a5
commit 115d31e0b4
2 files changed
+43 -19

No files matched your search

+19 -8
View File
@@ -58,24 +58,34 @@ jobs:
node-version-file: .nvmrc node-version-file: .nvmrc
cache: pnpm cache: pnpm
- uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable - uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable
- name: Restore Rust dependencies
uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3
with:
shared-key: desktop-${{ runner.os }}-${{ runner.arch }}
- name: Set up Rust compiler cache - name: Set up Rust compiler cache
if: runner.os == 'Windows' id: sccache-setup
uses: mozilla-actions/sccache-action@2df7dbab909c49ab7d3382d05da469f3f975c2d6 # v0.0.7 continue-on-error: true
uses: mozilla-actions/sccache-action@fc920bf0ec8de6ee65d409111f7ec508035751ba # v0.0.11
with:
version: v0.18.0
- name: Check Rust compiler cache availability - name: Check Rust compiler cache availability
id: sccache id: sccache
if: runner.os == 'Windows' if: steps.sccache-setup.outcome == 'success'
continue-on-error: true continue-on-error: true
shell: bash shell: bash
env: env:
SCCACHE_GHA_ENABLED: 'true' SCCACHE_GHA_ENABLED: 'true'
run: ${SCCACHE_PATH} rustc -vV run: '"${SCCACHE_PATH}" "$(rustup which rustc)" -vV'
- name: Enable Rust compiler cache - name: Enable Rust compiler cache
if: runner.os == 'Windows' && steps.sccache.outcome == 'success' if: steps.sccache.outcome == 'success'
shell: bash shell: bash
run: | run: |
echo 'RUSTC_WRAPPER=sccache' >> "$GITHUB_ENV" echo 'RUSTC_WRAPPER=sccache' >> "$GITHUB_ENV"
echo 'SCCACHE_GHA_ENABLED=true' >> "$GITHUB_ENV" echo 'SCCACHE_GHA_ENABLED=true' >> "$GITHUB_ENV"
echo 'SCCACHE_CACHE_SIZE=4G' >> "$GITHUB_ENV" - name: Report unavailable Rust compiler cache
if: steps.sccache-setup.outcome == 'failure' || steps.sccache.outcome == 'failure'
shell: bash
run: echo '::warning::Rust compiler cache is unavailable; this build will continue without compiler caching.'
- if: runner.os == 'Linux' - if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf run: sudo apt-get update && sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
- run: pnpm install --frozen-lockfile - run: pnpm install --frozen-lockfile
@@ -112,9 +122,10 @@ jobs:
} }
Write-Output "Built native NSIS installer: $($installers[0].Name)" Write-Output "Built native NSIS installer: $($installers[0].Name)"
- name: Show Rust compiler cache statistics - name: Show Rust compiler cache statistics
if: runner.os == 'Windows' && steps.sccache.outcome == 'success' && always() if: always() && steps.sccache.outcome == 'success'
continue-on-error: true
shell: bash shell: bash
run: ${SCCACHE_PATH} --show-stats run: '"${SCCACHE_PATH}" --show-stats'
website: website:
needs: guardrails needs: guardrails
+24 -11
View File
@@ -131,26 +131,38 @@ jobs:
- name: Set up Rust - name: Set up Rust
uses: dtolnay/rust-toolchain@4be7066ada62dd38de10e7b70166bc74ed198c30 # stable uses: dtolnay/rust-toolchain@4be7066ada62dd38de10e7b70166bc74ed198c30 # stable
- name: Restore Rust dependencies
uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3
with:
shared-key: desktop-${{ runner.os }}-${{ runner.arch }}
- name: Set up Rust compiler cache - name: Set up Rust compiler cache
if: runner.os == 'Windows' id: sccache-setup
uses: mozilla-actions/sccache-action@2df7dbab909c49ab7d3382d05da469f3f975c2d6 # v0.0.7 continue-on-error: true
uses: mozilla-actions/sccache-action@fc920bf0ec8de6ee65d409111f7ec508035751ba # v0.0.11
with:
version: v0.18.0
- name: Check Rust compiler cache availability - name: Check Rust compiler cache availability
id: sccache id: sccache
if: runner.os == 'Windows' if: steps.sccache-setup.outcome == 'success'
continue-on-error: true continue-on-error: true
shell: bash shell: bash
env: env:
SCCACHE_GHA_ENABLED: 'true' SCCACHE_GHA_ENABLED: 'true'
run: ${SCCACHE_PATH} rustc -vV run: '"${SCCACHE_PATH}" "$(rustup which rustc)" -vV'
- name: Enable Rust compiler cache - name: Enable Rust compiler cache
if: runner.os == 'Windows' && steps.sccache.outcome == 'success' if: steps.sccache.outcome == 'success'
shell: bash shell: bash
run: | run: |
echo 'RUSTC_WRAPPER=sccache' >> "$GITHUB_ENV" echo 'RUSTC_WRAPPER=sccache' >> "$GITHUB_ENV"
echo 'SCCACHE_GHA_ENABLED=true' >> "$GITHUB_ENV" echo 'SCCACHE_GHA_ENABLED=true' >> "$GITHUB_ENV"
echo 'SCCACHE_CACHE_SIZE=4G' >> "$GITHUB_ENV"
- name: Report unavailable Rust compiler cache
if: steps.sccache-setup.outcome == 'failure' || steps.sccache.outcome == 'failure'
shell: bash
run: echo '::warning::Rust compiler cache is unavailable; this build will continue without compiler caching.'
- name: Add macOS universal targets - name: Add macOS universal targets
if: runner.os == 'macOS' if: runner.os == 'macOS'
@@ -193,11 +205,6 @@ jobs:
updaterJsonPreferNsis: true updaterJsonPreferNsis: true
retryAttempts: 2 retryAttempts: 2
- name: Show Rust compiler cache statistics
if: runner.os == 'Windows' && steps.sccache.outcome == 'success' && always()
shell: bash
run: ${SCCACHE_PATH} --show-stats
- name: Publish Windows distribution variants - name: Publish Windows distribution variants
if: runner.os == 'Windows' if: runner.os == 'Windows'
env: env:
@@ -283,6 +290,12 @@ jobs:
throw "Binary not found at $appExe" throw "Binary not found at $appExe"
} }
- name: Show Rust compiler cache statistics
if: always() && steps.sccache.outcome == 'success'
continue-on-error: true
shell: bash
run: '"${SCCACHE_PATH}" --show-stats'
verify-and-publish: verify-and-publish:
name: Verify and publish name: Verify and publish
needs: build needs: build