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>
This commit is contained in:
Jiahao XU 2023-03-26 17:28:35 +11:00 committed by GitHub
parent a27d5aebf6
commit a403c99d3f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 48 additions and 10 deletions

View file

@ -18,19 +18,30 @@ inputs:
description: Suffix for cache key
required: false
default: ""
runs:
using: composite
steps:
- if: inputs.tools == ''
name: Install just
- 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: just
- if: inputs.tools != ''
name: Install just and tools
uses: taiki-e/install-action@v2
with:
tool: just,${{ inputs.tools }}
tool: ${{ env.tools }}
- if: inputs.indexcache
name: Configure index cache
@ -55,9 +66,11 @@ runs:
- if: inputs.buildcache
name: Configure sccache
uses: mozilla-actions/sccache-action@v0.0.2
uses: actions/github-script@v6
with:
version: "v0.4.0-pre.10"
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
@ -66,3 +79,8 @@ runs:
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

View file

@ -52,6 +52,10 @@ jobs:
- uses: ./.github/actions/just-setup
with:
cache-suffix: ${{ env.CARGO_BUILD_TARGET }}
env:
# just-setup use binstall to install sccache,
# which works better when we provide it with GITHUB_TOKEN.
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: just ci-install-deps
- run: just test
@ -78,6 +82,10 @@ jobs:
- uses: ./.github/actions/just-setup
with:
cache-suffix: ${{ env.CARGO_BUILD_TARGET }}
env:
# just-setup use binstall to install sccache,
# which works better when we provide it with GITHUB_TOKEN.
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: just ci-install-deps
- run: just check
@ -92,6 +100,10 @@ jobs:
- uses: ./.github/actions/just-setup
with:
cache-suffix: ${{ env.CARGO_BUILD_TARGET }}
env:
# just-setup use binstall to install sccache,
# which works better when we provide it with GITHUB_TOKEN.
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: just check
@ -105,6 +117,10 @@ jobs:
- uses: ./.github/actions/just-setup
with:
cache-suffix: ${{ env.CARGO_BUILD_TARGET }}
env:
# just-setup use binstall to install sccache,
# which works better when we provide it with GITHUB_TOKEN.
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: just check

View file

@ -45,6 +45,10 @@ jobs:
with:
cache-suffix: release-${{ matrix.t }}
tools: cargo-auditable
env:
# just-setup use binstall to install sccache and cargo-auditable,
# which works better when we provide it with GITHUB_TOKEN.
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: just toolchain rust-src
- run: just ci-install-deps