diff --git a/.forgejo/actions/setup-rust/action.yml b/.forgejo/actions/setup-rust/action.yml index 56c1f8033..5b5e795f5 100644 --- a/.forgejo/actions/setup-rust/action.yml +++ b/.forgejo/actions/setup-rust/action.yml @@ -17,7 +17,7 @@ inputs: required: false default: '' rust-version: - description: 'Rust version to install (e.g. nightly). Defaults to 1.87.0' + description: 'Rust version to install (e.g. nightly).' required: false default: '' sccache-cache-limit: @@ -59,23 +59,7 @@ runs: mkdir -p "${{ github.workspace }}/target" mkdir -p "${{ github.workspace }}/.rustup" - - name: Start cache restore group - shell: bash - run: echo "::group::📦 Restoring caches (registry, toolchain, build artifacts)" - - name: Cache Cargo registry and git - id: registry-cache - uses: actions/cache@v4 - with: - path: | - .cargo/registry/index - .cargo/registry/cache - .cargo/git/db - # Registry cache saved per workflow, restored from any workflow's cache - # Each workflow maintains its own registry that accumulates its needed crates - key: continuwuity-cargo-registry-${{ steps.runner-os.outputs.slug }}-${{ steps.runner-os.outputs.arch }}-${{ github.workflow }} - restore-keys: | - continuwuity-cargo-registry-${{ steps.runner-os.outputs.slug }}-${{ steps.runner-os.outputs.arch }}- - name: Cache toolchain binaries id: toolchain-cache @@ -88,45 +72,6 @@ runs: # Shared toolchain cache across all Rust versions key: continuwuity-toolchain-${{ steps.runner-os.outputs.slug }}-${{ steps.runner-os.outputs.arch }} - - - name: Setup sccache - uses: https://git.tomfos.tr/tom/sccache-action@v1 - - - name: Cache dependencies - id: deps-cache - uses: actions/cache@v4 - with: - path: | - target/**/.fingerprint - target/**/deps - target/**/*.d - target/**/.cargo-lock - target/**/CACHEDIR.TAG - target/**/.rustc_info.json - /timelord/ - # Dependencies cache - based on Cargo.lock, survives source code changes - key: >- - continuwuity-deps-${{ steps.runner-os.outputs.slug }}-${{ steps.runner-os.outputs.arch }}-${{ inputs.rust-version }}${{ inputs.cache-key-suffix && format('-{0}', inputs.cache-key-suffix) || '' }}-${{ hashFiles('rust-toolchain.toml', '**/Cargo.lock') }} - restore-keys: | - continuwuity-deps-${{ steps.runner-os.outputs.slug }}-${{ steps.runner-os.outputs.arch }}-${{ inputs.rust-version }}${{ inputs.cache-key-suffix && format('-{0}', inputs.cache-key-suffix) || '' }}- - - - name: Cache incremental compilation - id: incremental-cache - uses: actions/cache@v4 - with: - path: | - target/**/incremental - # Incremental cache - based on source code changes - key: >- - continuwuity-incremental-${{ steps.runner-os.outputs.slug }}-${{ steps.runner-os.outputs.arch }}-${{ inputs.rust-version }}${{ inputs.cache-key-suffix && format('-{0}', inputs.cache-key-suffix) || '' }}-${{ hashFiles('rust-toolchain.toml', '**/Cargo.lock') }}-${{ hashFiles('**/*.rs', '**/Cargo.toml') }} - restore-keys: | - continuwuity-incremental-${{ steps.runner-os.outputs.slug }}-${{ steps.runner-os.outputs.arch }}-${{ inputs.rust-version }}${{ inputs.cache-key-suffix && format('-{0}', inputs.cache-key-suffix) || '' }}-${{ hashFiles('rust-toolchain.toml', '**/Cargo.lock') }}- - continuwuity-incremental-${{ steps.runner-os.outputs.slug }}-${{ steps.runner-os.outputs.arch }}-${{ inputs.rust-version }}${{ inputs.cache-key-suffix && format('-{0}', inputs.cache-key-suffix) || '' }}- - - - name: End cache restore group - shell: bash - run: echo "::endgroup::" - - name: Setup Rust toolchain shell: bash run: | @@ -158,6 +103,71 @@ runs: fi echo "::endgroup::" + - name: Output Rust version + id: rust-setup + shell: bash + run: | + RUST_VERSION=$(rustc --version | cut -d' ' -f2) + echo "version=$RUST_VERSION" >> $GITHUB_OUTPUT + echo "📋 Rust version: $(rustc --version)" + + - name: Setup sccache + uses: https://git.tomfos.tr/tom/sccache-action@v1 + + + - name: Start cache restore group + shell: bash + run: echo "::group::📦 Restoring caches (registry, toolchain, build artifacts)" + + - name: Cache Cargo registry and git + id: registry-cache + uses: actions/cache@v4 + with: + path: | + .cargo/registry/index + .cargo/registry/cache + .cargo/git/db + # Registry cache saved per workflow, restored from any workflow's cache + # Each workflow maintains its own registry that accumulates its needed crates + key: continuwuity-cargo-registry-${{ steps.runner-os.outputs.slug }}-${{ steps.runner-os.outputs.arch }}-${{ github.workflow }} + restore-keys: | + continuwuity-cargo-registry-${{ steps.runner-os.outputs.slug }}-${{ steps.runner-os.outputs.arch }}- + + - name: Cache dependencies + id: deps-cache + uses: actions/cache@v4 + with: + path: | + target/**/.fingerprint + target/**/deps + target/**/*.d + target/**/.cargo-lock + target/**/CACHEDIR.TAG + target/**/.rustc_info.json + /timelord/ + # Dependencies cache - based on Cargo.lock, survives source code changes + key: >- + continuwuity-deps-${{ steps.runner-os.outputs.slug }}-${{ steps.runner-os.outputs.arch }}-${{ steps.rust-setup.outputs.version }}${{ inputs.cache-key-suffix && format('-{0}', inputs.cache-key-suffix) || '' }}-${{ hashFiles('rust-toolchain.toml', '**/Cargo.lock') }} + restore-keys: | + continuwuity-deps-${{ steps.runner-os.outputs.slug }}-${{ steps.runner-os.outputs.arch }}-${{ steps.rust-setup.outputs.version }}${{ inputs.cache-key-suffix && format('-{0}', inputs.cache-key-suffix) || '' }}- + + - name: Cache incremental compilation + id: incremental-cache + uses: actions/cache@v4 + with: + path: | + target/**/incremental + # Incremental cache - based on source code changes + key: >- + continuwuity-incremental-${{ steps.runner-os.outputs.slug }}-${{ steps.runner-os.outputs.arch }}-${{ steps.rust-setup.outputs.version }}${{ inputs.cache-key-suffix && format('-{0}', inputs.cache-key-suffix) || '' }}-${{ hashFiles('rust-toolchain.toml', '**/Cargo.lock') }}-${{ hashFiles('**/*.rs', '**/Cargo.toml') }} + restore-keys: | + continuwuity-incremental-${{ steps.runner-os.outputs.slug }}-${{ steps.runner-os.outputs.arch }}-${{ steps.rust-setup.outputs.version }}${{ inputs.cache-key-suffix && format('-{0}', inputs.cache-key-suffix) || '' }}-${{ hashFiles('rust-toolchain.toml', '**/Cargo.lock') }}- + continuwuity-incremental-${{ steps.runner-os.outputs.slug }}-${{ steps.runner-os.outputs.arch }}-${{ steps.rust-setup.outputs.version }}${{ inputs.cache-key-suffix && format('-{0}', inputs.cache-key-suffix) || '' }}- + + - name: End cache restore group + shell: bash + run: echo "::endgroup::" + - name: Configure PATH and install tools shell: bash env: @@ -225,13 +235,9 @@ runs: echo "📦 Installing target: ${{ inputs.rust-target }}" rustup target add ${{ inputs.rust-target }} - - name: Output version and summary - id: rust-setup + - name: Output summary shell: bash run: | - RUST_VERSION=$(rustc --version | cut -d' ' -f2) - echo "version=$RUST_VERSION" >> $GITHUB_OUTPUT - echo "📋 Setup complete:" echo " Rust: $(rustc --version)" echo " Cargo: $(cargo --version)"