Skip to content

Commit 13e08f6

Browse files
committed
ci: use sccache
We install sccache using cargo and cache its binary to avoid this overhead on subsequent invocations. We start an sccache server before building and stop it afterwards, printing stats before doing so. We also set environment variables to point sccache at an S3 bucket that I control. I manually installed secrets with an AWS access key with read/write access to just the key prefix in this bucket.
1 parent 7c74e66 commit 13e08f6

File tree

1 file changed

+55
-1
lines changed

1 file changed

+55
-1
lines changed

.github/workflows/pyoxidizer.yml

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,13 @@ jobs:
2020
runs-on: ${{ matrix.os }}
2121
env:
2222
IN_CI: '1'
23+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
24+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
25+
SCCACHE_BUCKET: 'pyoxidizer-sccache'
26+
SCCACHE_S3_USE_SSL: '1'
2327
steps:
2428
- name: Install Linux system packages
25-
if: ${{ runner.os == 'Linux' }}
29+
if: runner.os == 'Linux'
2630
run: |
2731
sudo apt-get install -y libyaml-dev snapcraft
2832
@@ -44,17 +48,67 @@ jobs:
4448
profile: minimal
4549
target: x86_64-unknown-linux-musl
4650

51+
- name: Cache sccache (Windows)
52+
id: cache-sccache-windows
53+
if: runner.os == 'Windows'
54+
uses: actions/cache@v2
55+
with:
56+
path: C:/Rust/.cargo/bin/sccache.exe
57+
key: ${{ runner.os }}-sccache-0
58+
59+
- name: Install sccache build dependencies (Windows)
60+
if: runner.os == 'Windows' && steps.cache-sccache-windows.outputs.cache-hit != 'true'
61+
run: |
62+
vcpkg integrate install
63+
vcpkg install openssl:x64-windows
64+
65+
- name: Install sccache (Linux)
66+
if: runner.os == 'Linux'
67+
run: |
68+
wget -O sccache.tar.gz https://github.com/mozilla/sccache/releases/download/0.2.13/sccache-0.2.13-x86_64-unknown-linux-musl.tar.gz
69+
tar -xvzf sccache.tar.gz
70+
mv sccache-0.2.13-x86_64-unknown-linux-musl/sccache /usr/share/rust/.cargo/bin/sccache
71+
72+
- name: Install sccache (macOS)
73+
if: runner.os == 'macOS'
74+
run: |
75+
wget -O sccache.tar.gz https://github.com/mozilla/sccache/releases/download/0.2.13/sccache-0.2.13-x86_64-apple-darwin.tar.gz
76+
tar -xvzf sccache.tar.gz
77+
mv sccache-0.2.13-x86_64-apple-darwin/sccache /Users/runner/.cargo/bin/sccache
78+
79+
- name: Install sccache (Windows)
80+
if: steps.cache-sccache-windows.outputs.cache-hit != 'true' && runner.os == 'Windows'
81+
# sccache doesn't work with Rust 1.48. https://github.com/mozilla/sccache/issues/887
82+
run: |
83+
rustup install 1.47.0
84+
cargo +1.47.0 install --features 'azure s3' sccache
85+
86+
- name: Start sccache
87+
run: |
88+
sccache --start-server
89+
4790
# TODO get pyembed working. It needs a working libpython.
4891
- name: Build Workspace
92+
env:
93+
RUSTC_WRAPPER: sccache
4994
run: |
5095
cargo build --workspace --exclude pyembed --exclude oxidized-importer
5196
cargo run --bin pyoxidizer -- --version
5297
5398
- name: Test Workspace
99+
env:
100+
RUSTC_WRAPPER: sccache
54101
run: |
55102
cargo test --workspace --exclude pyembed --exclude oxidized-importer
56103
57104
- name: Run Clippy
58105
if: ${{ matrix.rust_toolchain == 'stable' || matrix.rust_toolchain == 'beta' }}
106+
env:
107+
RUSTC_WRAPPER: sccache
59108
run: |
60109
cargo clippy --workspace --exclude pyembed --exclude oxdized-importer
110+
111+
- name: Stop sccache
112+
run: |
113+
sccache --show-stats
114+
sccache --stop-server

0 commit comments

Comments
 (0)