Skip to content

Commit 5b08939

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 5b08939

1 file changed

Lines changed: 54 additions & 1 deletion

File tree

.github/workflows/pyoxidizer.yml

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,12 @@ 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: 'gregoryszorc-ci-pyoxidizer-sccache'
2326
steps:
2427
- name: Install Linux system packages
25-
if: ${{ runner.os == 'Linux' }}
28+
if: runner.os == 'Linux'
2629
run: |
2730
sudo apt-get install -y libyaml-dev snapcraft
2831
@@ -44,17 +47,67 @@ jobs:
4447
profile: minimal
4548
target: x86_64-unknown-linux-musl
4649

50+
- name: Cache sccache (Windows)
51+
id: cache-sccache-windows
52+
if: runner.os == 'Windows'
53+
uses: actions/cache@v2
54+
with:
55+
path: C:/Rust/.cargo/bin/sccache.exe
56+
key: ${{ runner.os }}-sccache-0
57+
58+
- name: Install sccache build dependencies (Windows)
59+
if: runner.os == 'Windows' && steps.cache-sccache-windows.outputs.cache-hit != 'true'
60+
run: |
61+
vcpkg integrate install
62+
vcpkg install openssl:x64-windows
63+
64+
- name: Install sccache (Linux)
65+
if: runner.os == 'Linux'
66+
run: |
67+
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
68+
tar -xvzf sccache.tar.gz
69+
mv sccache-0.2.13-x86_64-unknown-linux-musl/sccache /usr/share/rust/.cargo/bin/sccache
70+
71+
- name: Install sccache (macOS)
72+
if: runner.os == 'macOS'
73+
run: |
74+
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
75+
tar -xvzf sccache.tar.gz
76+
mv sccache-0.2.13-x86_64-apple-darwin/sccache /Users/runner/.cargo/bin/sccache
77+
78+
- name: Install sccache (Windows)
79+
if: steps.cache-sccache-windows.outputs.cache-hit != 'true' && runner.os == 'Windows'
80+
# sccache doesn't work with Rust 1.48. https://github.com/mozilla/sccache/issues/887
81+
run: |
82+
rustup install 1.47.0
83+
cargo +1.47.0 install --features 'azure s3' sccache
84+
85+
- name: Start sccache
86+
run: |
87+
sccache --start-server
88+
4789
# TODO get pyembed working. It needs a working libpython.
4890
- name: Build Workspace
91+
env:
92+
RUSTC_WRAPPER: sccache
4993
run: |
5094
cargo build --workspace --exclude pyembed --exclude oxidized-importer
5195
cargo run --bin pyoxidizer -- --version
5296
5397
- name: Test Workspace
98+
env:
99+
RUSTC_WRAPPER: sccache
54100
run: |
55101
cargo test --workspace --exclude pyembed --exclude oxidized-importer
56102
57103
- name: Run Clippy
58104
if: ${{ matrix.rust_toolchain == 'stable' || matrix.rust_toolchain == 'beta' }}
105+
env:
106+
RUSTC_WRAPPER: sccache
59107
run: |
60108
cargo clippy --workspace --exclude pyembed --exclude oxdized-importer
109+
110+
- name: Stop sccache
111+
run: |
112+
sccache --show-stats
113+
sccache --stop-server

0 commit comments

Comments
 (0)