cargo-binstall/.github/actions/just-setup/action.yml
Jiahao XU a403c99d3f
Upgrade CI to use sccache v0.4.0 for caching (#934)
Remove `mozilla-actions/sccache-action@v0.0.2` and instead use `taiki-ie/install-action` to install `sccache`, since we already use `taiki-e/install-action` for installing crates.

This PR also refactor just-setup.yml and use pass `GITHUB_TOKEN` to `taiki-e/install-action` which uses `cargo-binstall` for installing `cargo-auditable` and `sccache`.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2023-03-26 17:28:35 +11:00

86 lines
2.2 KiB
YAML

name: Setup tools and cache
inputs:
tools:
description: Extra tools
required: false
default: ""
indexcache:
description: Enable index cache
required: true
default: true
type: boolean
buildcache:
description: Enable build cache
required: true
default: true
type: boolean
cache-suffix:
description: Suffix for cache key
required: false
default: ""
runs:
using: composite
steps:
- name: Add just to tools to install
run: echo "tools=just" >>$GITHUB_ENV
shell: bash
- if: inputs.buildcache
name: Add sccache to tools to install
run: echo "tools=$tools,sccache" >>$GITHUB_ENV
shell: bash
- name: Add inputs.tools to tools to install
if: inputs.tools != ''
env:
inputs_tools: ${{ inputs.tools }}
run: echo "tools=$tools,$inputs_tools" >>$GITHUB_ENV
shell: bash
- name: Install tools
uses: taiki-e/install-action@v2
with:
tool: ${{ env.tools }}
- if: inputs.indexcache
name: Configure index cache
uses: actions/cache@v3
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}-${{ inputs.cache-suffix }}
restore-keys: |
${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}-
${{ runner.os }}-cargo-index-
- name: Install rust toolchains
run: just toolchain
shell: bash
- name: rustc version
run: rustc -vV | tee rustc-version
shell: bash
- if: inputs.buildcache
name: Configure sccache
uses: actions/github-script@v6
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
- if: inputs.buildcache
name: Export env for sccache to work
shell: bash
run: |
echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
echo "CARGO_INCREMENTAL=0" >> $GITHUB_ENV
- uses: webiny/action-post-run@3.0.0
id: post-run-command
with:
run: sccache --show-stats