Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 27 additions & 5 deletions .github/actions/setup-rust/action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: 'Setup Rust Toolchain'
description: 'Setup Rust toolchain with components and caching'
description: 'Setup Rust toolchain with components and caching based on Cargo.lock'
inputs:
toolchain:
description: 'Rust toolchain version'
Expand All @@ -26,10 +26,32 @@ runs:
toolchain: ${{ inputs.toolchain }}
components: ${{ inputs.components }}

- name: Setup Rust Cache
- name: Generate Cargo.lock hash
if: inputs.enable-cache == 'true'
id: cargo-lock-hash
shell: bash
run: |
if [ -f "Cargo.lock" ]; then
echo "hash=${{ hashFiles('**/Cargo.lock') }}" >> $GITHUB_OUTPUT
else
echo "hash=no-cargo-lock" >> $GITHUB_OUTPUT
fi

- name: Setup Rust Cache (Cargo.lock based)
if: inputs.enable-cache == 'true'
uses: Swatinem/rust-cache@v2
with:
prefix-key: ${{ inputs.cache-prefix }}-${{ inputs.toolchain }}
shared-key: shared-${{ inputs.toolchain }}
save-if: ${{ github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/main' }}
# Use Cargo.lock hash as the primary cache key
key: ${{ inputs.cache-prefix }}-${{ inputs.toolchain }}-${{ steps.cargo-lock-hash.outputs.hash }}
# Shared cache key for fallback (without Cargo.lock hash)
shared-key: ${{ inputs.cache-prefix }}-${{ inputs.toolchain }}-shared
# Save cache on develop and main branches
save-if: ${{ github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/main' }}
# Cache these directories for faster builds
cache-directories: |
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git
target/
# Don't cache the entire target directory for PRs to save space
cache-targets: ${{ github.event_name == 'pull_request' && 'false' || 'true' }}
29 changes: 26 additions & 3 deletions .github/actions/setup-wasm/action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: 'Setup WebAssembly Build Environment'
description: 'Setup Rust with WASM target and wasm-bindgen-cli'
description: 'Setup Rust with WASM target and wasm-bindgen-cli with Cargo.lock based caching'
inputs:
toolchain:
description: 'Rust toolchain version'
Expand All @@ -22,7 +22,30 @@ runs:
run: |
make setup-wasm

- name: Setup Rust Cache
- name: Generate Cargo.lock hash
id: cargo-lock-hash
shell: bash
run: |
if [ -f "Cargo.lock" ]; then
echo "hash=${{ hashFiles('**/Cargo.lock') }}" >> $GITHUB_OUTPUT
else
echo "hash=no-cargo-lock" >> $GITHUB_OUTPUT
fi

- name: Setup Rust Cache (Cargo.lock based)
uses: Swatinem/rust-cache@v2
with:
prefix-key: ${{ inputs.cache-prefix }}
# Use Cargo.lock hash as the primary cache key
key: ${{ inputs.cache-prefix }}-${{ inputs.toolchain }}-${{ steps.cargo-lock-hash.outputs.hash }}
# Shared cache key for fallback
shared-key: ${{ inputs.cache-prefix }}-${{ inputs.toolchain }}-shared
# Save cache on develop and main branches
save-if: ${{ github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/main' }}
# Cache these directories for WASM builds
cache-directories: |
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git
target/
# Don't cache the entire target directory for PRs to save space
cache-targets: ${{ github.event_name == 'pull_request' && 'false' || 'true' }}
8 changes: 4 additions & 4 deletions .github/workflows/build-reusable.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
uses: ./.github/actions/setup-rust
with:
toolchain: 1.84
cache-prefix: build-${{ inputs.os }}-${{ inputs.cache-prefix }}v0
cache-prefix: build-${{ inputs.os }}-${{ inputs.cache-prefix }}v1

- name: Release build
run: make build-release
Expand Down Expand Up @@ -91,7 +91,7 @@ jobs:
uses: ./.github/actions/setup-rust
with:
toolchain: 1.84
cache-prefix: build-tests-${{ inputs.os }}-${{ inputs.cache-prefix }}v0
cache-prefix: build-tests-${{ inputs.os }}-${{ inputs.cache-prefix }}v1

- name: Build tests
run: make build-tests
Expand All @@ -115,7 +115,7 @@ jobs:
uses: ./.github/actions/setup-rust
with:
toolchain: 1.84
cache-prefix: build-tests-webrtc-${{ inputs.os }}-${{ inputs.cache-prefix }}v0
cache-prefix: build-tests-webrtc-${{ inputs.os }}-${{ inputs.cache-prefix }}v1

- name: Build tests
run: make build-tests-webrtc
Expand All @@ -139,7 +139,7 @@ jobs:
- name: Setup WebAssembly environment
uses: ./.github/actions/setup-wasm
with:
cache-prefix: wasm-${{ inputs.os }}-${{ inputs.cache-prefix }}v0
cache-prefix: wasm-${{ inputs.os }}-${{ inputs.cache-prefix }}v1

- name: Release build
run: make build-wasm
Expand Down
Loading