Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade CI to use sccache v0.4.0 for caching #934

Merged
merged 12 commits into from
Mar 26, 2023
38 changes: 28 additions & 10 deletions .github/actions/just-setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,30 @@ inputs:
description: Suffix for cache key
required: false
default: ""

runs:
using: composite
steps:
- if: inputs.tools == ''
name: Install just
uses: taiki-e/install-action@v2
with:
tool: just
- if: inputs.tools != ''
name: Install just and tools
- 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,${{ inputs.tools }}
tool: ${{ env.tools }}

- if: inputs.indexcache
name: Configure index cache
Expand All @@ -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
Expand All @@ -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
16 changes: 16 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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

Expand All @@ -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

Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/release-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down