commit c954996a9a629168237b8585bfa5173229b242a1 Author: Hermes Date: Sat May 2 13:57:07 2026 -0700 Initial: hello world + Gitea Actions cache workflow diff --git a/.gitea/workflows/rust-cache-test.yml b/.gitea/workflows/rust-cache-test.yml new file mode 100644 index 0000000..58165f8 --- /dev/null +++ b/.gitea/workflows/rust-cache-test.yml @@ -0,0 +1,61 @@ +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 + uses: https://gitea.com/actions/go-hashfiles@v0.0.1 + with: + patterns: | + Cargo.lock + Cargo.toml + + - 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 + run: | + echo "=== Cache Key ===" + echo "rust-${{ runner.os }}-${{ steps.hash.outputs.hash }}" + echo "" + echo "=== Cargo cache directories ===" + du -sh ~/.cargo/registry ~/.cargo/git target 2>/dev/null || echo "Dirs not yet present" + echo "" + echo "=== Cargo version ===" + cargo --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)" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..9ecde95 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "rust-hello-world" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/README.md b/README.md new file mode 100644 index 0000000..ef1f4e5 --- /dev/null +++ b/README.md @@ -0,0 +1,16 @@ +# rust-hello-world + +Hello world Rust project for verifying Gitea Actions build cache. + +## What this tests + +1. `go-hashfiles` generates a hash from `Cargo.lock` and `Cargo.toml` +2. `actions/cache@v3` caches `~/.cargo/registry`, `~/.cargo/git`, and `target` +3. Subsequent runs should hit the cache and skip recompilation + +## Run locally + +```bash +cargo build +cargo run +``` diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..e7a11a9 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +}