Skip to content

Commit 176475f

Browse files
authored
BM-153: sccache with S3 backend (github#67)
This PR Adds sccache caching to CI with a s3 backend for storage now that we are running on proper CI machines. closes BM-153
1 parent 83b79f4 commit 176475f

File tree

3 files changed

+103
-12
lines changed

3 files changed

+103
-12
lines changed

.github/actions/bininstall-risc0/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ runs:
2323
- uses: risc0/cargo-install@v3
2424
with:
2525
crate: cargo-binstall
26-
version: '=1.6'
26+
version: '=1.10.8'
2727
locked: true
2828

2929
- run: cargo binstall -y --force cargo-risczero@${{ inputs.risczero-version }}

.github/actions/sccache/action.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: sccache install
2+
description: Install sccache
3+
4+
inputs:
5+
key:
6+
required: true
7+
default: rust-cache-${{ runner.os }}-${{ runner.arch }}
8+
disable_s3:
9+
default: false
10+
aws_region:
11+
default: us-west-2
12+
aws_account:
13+
default: '083632199359'
14+
aws_role:
15+
default: gha_oidc_risc0_cache_shared_access
16+
17+
runs:
18+
using: composite
19+
steps:
20+
- name: Disable idle timeout to run sccache permanently
21+
run: |
22+
echo "SCCACHE_IDLE_TIMEOUT=0" >> $GITHUB_ENV
23+
shell: bash
24+
25+
- if: runner.os == 'Linux' && runner.arch == 'X64'
26+
run: |
27+
echo "SCCACHE_ARCH=x86_64-unknown-linux-musl" >> $GITHUB_ENV
28+
shell: bash
29+
30+
- if: runner.os == 'macOS' && runner.arch == 'X64'
31+
run: |
32+
echo "SCCACHE_ARCH=x86_64-apple-darwin" >> $GITHUB_ENV
33+
shell: bash
34+
35+
- if: runner.os == 'macOS' && runner.arch == 'ARM64'
36+
run: |
37+
echo "SCCACHE_ARCH=aarch64-apple-darwin" >> $GITHUB_ENV
38+
shell: bash
39+
40+
- if: runner.os == 'Linux' && runner.arch == 'ARM64'
41+
run: |
42+
echo "SCCACHE_ARCH=aarch64-unknown-linux-musl" >> $GITHUB_ENV
43+
shell: bash
44+
45+
- env:
46+
SCCACHE_URL: https://github.com/mozilla/sccache/releases/download
47+
SCCACHE_VERSION: v0.8.2
48+
run: |
49+
SCCACHE_FILE=sccache-$SCCACHE_VERSION-$SCCACHE_ARCH
50+
curl -L "$SCCACHE_URL/$SCCACHE_VERSION/$SCCACHE_FILE.tar.gz" | tar xz
51+
mkdir -p $HOME/.local/bin
52+
mv -f $SCCACHE_FILE/sccache $HOME/.local/bin/sccache
53+
echo "$HOME/.local/bin" >> $GITHUB_PATH
54+
shell: bash
55+
56+
- if: >
57+
runner.os == 'Linux' && inputs.disable_s3 == 'false' && startsWith(runner.name, 'i-') == true
58+
run: |
59+
echo "SCCACHE_REGION=us-west-2" >> $GITHUB_ENV
60+
echo "SCCACHE_BUCKET=risc0-ci-cache" >> $GITHUB_ENV
61+
echo "SCCACHE_S3_KEY_PREFIX=shared/boundless/${{ inputs.key }}/sccache" >> $GITHUB_ENV
62+
shell: bash
63+
64+
- run: |
65+
echo "CARGO_INCREMENTAL=0" >> $GITHUB_ENV
66+
echo "CARGO_PROFILE_DEV_DEBUG=0" >> $GITHUB_ENV
67+
echo "CC=sccache clang" >> $GITHUB_ENV
68+
echo "CMAKE_C_COMPILER_LAUNCHER=sccache" >> $GITHUB_ENV
69+
echo "CMAKE_CXX_COMPILER_LAUNCHER=sccache" >> $GITHUB_ENV
70+
echo "CXX=sccache clang++" >> $GITHUB_ENV
71+
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
72+
shell: bash
73+
74+
- if: >
75+
runner.os == 'Linux' && inputs.disable_s3 == 'false' &&
76+
github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name
77+
id: aws-creds
78+
uses: aws-actions/configure-aws-credentials@v4
79+
with:
80+
aws-region: '${{ inputs.aws_region }}'
81+
role-to-assume: 'arn:aws:iam::${{ inputs.aws_account }}:role/${{ inputs.aws_role }}'

.github/workflows/main.yml

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,11 @@ jobs:
6262

6363
- name: install rust
6464
uses: risc0/risc0/.github/actions/[email protected]
65+
with:
66+
toolchain: '1.79'
6567

66-
# - name: install sccache
67-
# uses: risc0/risc0/.github/actions/sccache@main
68+
- name: setup sccache + s3
69+
uses: ./.github/actions/sccache
6870

6971
- name: install cargo risczero
7072
uses: ./.github/actions/bininstall-risc0
@@ -96,7 +98,13 @@ jobs:
9698
run: cargo check
9799

98100
- name: Install sqlx-cli
99-
run: cargo install --locked --version=0.7.4 sqlx-cli --no-default-features --features postgres
101+
uses: risc0/cargo-install@v3
102+
with:
103+
crate: sqlx-cli
104+
version: '=0.8.2'
105+
locked: true
106+
args: --no-default-features
107+
features: postgres
100108

101109
- name: run taskdb migrations
102110
env:
@@ -108,8 +116,8 @@ jobs:
108116
env:
109117
DATABASE_URL: postgres://postgres:password@localhost:5432/postgres
110118

111-
# - name: sccache stats
112-
# run: sccache --show-stats
119+
- name: sccache stats
120+
run: sccache --show-stats
113121

114122
link-check:
115123
runs-on: ubuntu-latest
@@ -128,7 +136,7 @@ jobs:
128136
uses: risc0/cargo-install@v3
129137
with:
130138
crate: cargo-binstall
131-
version: '=1.6'
139+
version: '=1.10.8'
132140
locked: true
133141

134142
- run: cargo binstall -y --force [email protected]
@@ -154,7 +162,7 @@ jobs:
154162
uses: risc0/cargo-install@v3
155163
with:
156164
crate: cargo-binstall
157-
version: '=1.6'
165+
version: '=1.10.8'
158166
locked: true
159167

160168
- run: cargo binstall -y --force [email protected]
@@ -199,9 +207,11 @@ jobs:
199207

200208
- name: install rust
201209
uses: risc0/risc0/.github/actions/[email protected]
210+
with:
211+
toolchain: '1.79'
202212

203-
# - name: install sccache
204-
# uses: risc0/risc0/.github/actions/sccache@main
213+
- name: setup sccache + s3
214+
uses: ./.github/actions/sccache
205215

206216
- name: install cargo risczero
207217
uses: ./.github/actions/bininstall-risc0
@@ -252,8 +262,8 @@ jobs:
252262
env:
253263
RISC0_DEV_MODE: 1
254264

255-
# - name: sccache stats
256-
# run: sccache --show-stats
265+
- name: sccache stats
266+
run: sccache --show-stats
257267

258268
docker:
259269
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)