Skip to content

PhotoCraft: An open-source, photo editor written by scratch in pure Rust

CI: build faster and stop running out of disk and cache (#1075)

BFlat5a2f42c47659
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 704f78d0c..31b8d8566 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -17,6 +17,10 @@ on:
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
+ # Debug and test builds keep line tables (file:line in panic backtraces) but drop the rest of the
+ # debug info: faster codegen and links (Windows PDBs most of all), and a target dir small enough
+ # for the Linux job's second, craft-fonts build (it ran out of disk with full debug info).
+ CARGO_PROFILE_DEV_DEBUG: line-tables-only
# A newer push to a PR branch cancels its older run. Runs on main are never cancelled: a merge
# that lands while main's run is in progress waits for it, so every main state that gets a run is
@@ -66,9 +70,13 @@ jobs:
steps:
- uses: actions/checkout@v4
+ # Unused toolchains in the image (Android SDK, .NET, GHC, CodeQL) are deleted in the
+ # background: the space is free before the craft-fonts build needs it, and nothing waits.
- name: Install Linux system dependencies (egui/winit/rfd)
if: runner.os == 'Linux'
run: |
+ nohup sudo rm -rf /usr/local/lib/android /usr/share/dotnet /opt/ghc /usr/local/.ghcup \
+ /opt/hostedtoolcache/CodeQL </dev/null >/dev/null 2>&1 &
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
libxkbcommon-dev libwayland-dev libx11-dev libxrandr-dev libxi-dev \
@@ -78,7 +86,13 @@ jobs:
with:
components: clippy, rustfmt
+ # Only main saves caches; PRs restore main's. Every PR used to save its own set (up to
+ # 3.8 GB), usable by that PR only, so the repo's 10 GB cache budget kept evicting main's.
+ # A failing test still saves: the cache holds compiled dependencies, not test results.
- uses: Swatinem/rust-cache@v2
+ with:
+ save-if: ${{ github.ref == 'refs/heads/main' }}
+ cache-on-failure: true
- name: Format
if: runner.os == 'Linux'
@@ -133,12 +147,21 @@ jobs:
# pin or manifest does, so normally this restores in seconds (fork PRs read the base cache).
name: corpus tests
runs-on: ubuntu-latest
+ env:
+ # test-corpus builds with --release, but here without the release profile's thin LTO and
+ # single codegen unit: they ran LTO over the dependency graph for each of the ~95 corpus test
+ # binaries, so building took 23.5 of the job's 37 minutes while the tests ran for 1.5.
+ # Turning them off builds 2.7x faster; the code under test is the same.
+ CARGO_PROFILE_RELEASE_LTO: "false"
+ CARGO_PROFILE_RELEASE_CODEGEN_UNITS: "16"
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
key: corpus
+ save-if: ${{ github.ref == 'refs/heads/main' }}
+ cache-on-failure: true
- name: Restore test corpora
uses: actions/cache@v4
with:
@@ -160,6 +183,8 @@ jobs:
- uses: Swatinem/rust-cache@v2
with:
key: wasm32
+ save-if: ${{ github.ref == 'refs/heads/main' }}
+ cache-on-failure: true
- name: Check wasm-safe crates
run: cargo xtask wasm