diff --git a/.gitea/workflows/rust-cache-test.yml b/.gitea/workflows/rust-cache-test.yml index 55dca6f..2d80f0f 100644 --- a/.gitea/workflows/rust-cache-test.yml +++ b/.gitea/workflows/rust-cache-test.yml @@ -1,4 +1,4 @@ -name: Rust Build Cache Test +name: Rust Build on: push: @@ -17,54 +17,32 @@ jobs: - name: Checkout code uses: https://gitea.com/actions/checkout@v4 - - name: Install Rust - run: | - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable - source "$HOME/.cargo/env" - - name: Get Cargo lock hash id: hash run: | - source "$HOME/.cargo/env" echo "hash=$(cat Cargo.lock Cargo.toml | sha256sum | cut -d' ' -f1)" >> $GITHUB_OUTPUT - - name: Cache cargo + - name: Cache cargo + rustup + id: cache uses: https://gitea.com/actions/cache@v3 with: path: | ~/.cargo/registry ~/.cargo/git + ~/.rustup/toolchains + ~/.rustup/settings.toml target key: rust-${{ runner.os }}-${{ steps.hash.outputs.hash }} restore-keys: | rust-${{ runner.os }}- - - name: Show cache info (before build) + - name: Setup Rust + if: steps.cache.outputs.cache-hit != 'true' run: | - source "$HOME/.cargo/env" - echo "=== Cache Key ===" - echo "rust-${{ runner.os }}-${{ steps.hash.outputs.hash }}" - echo "" - echo "=== Cargo cache directories (before build) ===" - du -sh ~/.cargo/registry ~/.cargo/git target 2>/dev/null || echo "Dirs not yet present" - echo "" - echo "=== Cargo/Rust versions ===" - cargo --version - rustc --version + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable - name: Build - run: | - source "$HOME/.cargo/env" - cargo build --verbose + run: cargo build --verbose - name: Run - run: | - source "$HOME/.cargo/env" - cargo run - - - name: Check cache after build - run: | - echo "=== After build ===" - echo "~/.cargo/registry: $(du -sh ~/.cargo/registry 2>/dev/null | cut -f1)" - echo "~/.cargo/git: $(du -sh ~/.cargo/git 2>/dev/null | cut -f1)" - echo "target: $(du -sh target 2>/dev/null | cut -f1)" + run: cargo run