Skip to content

feat: add a way of using GHA cache locally #33

feat: add a way of using GHA cache locally

feat: add a way of using GHA cache locally #33

name: integration-tests
on: [push, pull_request]
env:
RUST_BACKTRACE: full
RUST_LOG: debug
SCCACHE_PATH: /home/runner/.cargo/bin/sccache
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Clone repository
uses: actions/checkout@v4
- name: Install rust
uses: ./.github/actions/rust-toolchain
with:
toolchain: "stable"
- name: Build
run: |
cargo build --all-features
- uses: actions/upload-artifact@v4
with:
name: integration-tests
path: ./target/debug/sccache
gha:
runs-on: ubuntu-latest
needs: build
env:
SCCACHE_GHA_ENABLED: "on"
RUSTC_WRAPPER: /home/runner/.cargo/bin/sccache
steps:
- name: Clone repository
uses: actions/checkout@v4
- name: Configure Cache Env
uses: actions/github-script@v7
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
- name: Install rust
uses: ./.github/actions/rust-toolchain
with:
toolchain: "stable"
- uses: actions/download-artifact@v4
with:
name: integration-tests
path: /home/runner/.cargo/bin/
- name: Chmod for binary
run: chmod +x ${SCCACHE_PATH}
- name: Test
run: cargo clean && cargo build
- name: Output
run: |
${SCCACHE_PATH} --show-stats
${SCCACHE_PATH} --show-stats | grep gha
- name: Test Twice for Cache Read
run: cargo clean && cargo build
- name: Output
run: |
${SCCACHE_PATH} --show-stats
${SCCACHE_PATH} --show-stats | grep -e "Cache hits\s*[1-9]"
gha-as-local:
runs-on: ubuntu-latest
needs: build
env:
SCCACHE_GHA_ENABLED: "on"
SCCACHE_GHA_AS_LOCAL: "on"
RUSTC_WRAPPER: /home/runner/.cargo/bin/sccache
steps:
- name: Clone repository
uses: actions/checkout@v4
- name: Configure Cache Env
uses: actions/github-script@v7
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
- name: Install rust
uses: ./.github/actions/rust-toolchain
with:
toolchain: "stable"
- uses: actions/download-artifact@v4
with:
name: integration-tests
path: /home/runner/.cargo/bin/
- name: Chmod for binary
run: chmod +x ${SCCACHE_PATH}
- name: Test
run: cargo clean && cargo build
- name: Output
run: |
${SCCACHE_PATH} --show-stats
${SCCACHE_PATH} --show-stats | grep gha
- name: Test Twice for Cache Read
run: cargo clean && cargo build
- name: Output
run: |
${SCCACHE_PATH} --show-stats
${SCCACHE_PATH} --show-stats | grep -e "Cache hits\s*[1-9]"