62 lines
1.6 KiB
YAML
62 lines
1.6 KiB
YAML
name: Rust Build Cache Test
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
- master
|
|
pull_request:
|
|
|
|
env:
|
|
CARGO_TERM_COLOR: always
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: https://gitea.com/actions/checkout@v4
|
|
|
|
- name: Get Cargo lock hash
|
|
id: hash
|
|
run: |
|
|
echo "hash=$(cat Cargo.lock Cargo.toml | sha256sum | cut -d' ' -f1)" >> $GITHUB_OUTPUT
|
|
echo "=== Manifest hash ==="
|
|
echo "${{ env.hash }}"
|
|
|
|
- name: Cache cargo
|
|
uses: https://gitea.com/actions/cache@v3
|
|
with:
|
|
path: |
|
|
~/.cargo/registry
|
|
~/.cargo/git
|
|
target
|
|
key: rust-${{ runner.os }}-${{ steps.hash.outputs.hash }}
|
|
restore-keys: |
|
|
rust-${{ runner.os }}-
|
|
|
|
- name: Show cache info (before build)
|
|
run: |
|
|
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 version ==="
|
|
cargo --version
|
|
rustc --version
|
|
|
|
- name: Build
|
|
run: cargo build --verbose
|
|
|
|
- name: Run
|
|
run: 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)"
|