Skip to content

armgit / raea

Public Imported from GitHub
0

Render Anything Engine: tell your AI what to make. Videos, motion graphics, 3D and games as React and TypeScript, rendered on your own GPU. Rust + Bevy, macOS, Linux and Windows.

release.yml: a compile cache for release builds, sccache on an R2 bucket (raea-build-cache), so a candidate after a small change compiles only what changed instead of three cold hours. GitHub's own cache can't carry it: a tag's run reads only its own tag's caches and the default branch's, so rc3's would never reach rc4, and the repo's 10 GB are CI's. tools/release/compile-cache.sh turns it on when the job has the bucket's key (secrets RELEASE_CACHE_ENDPOINT, RELEASE_CACHE_KEY_ID, RELEASE_CACHE_SECRET), each OS and architecture under its own prefix, C and C++ in build scripts through cc-rs and CMake's launchers; when the bucket can't be reached or written the build runs uncached, as before. Each cargo call's minutes are a notice on the run, and sccache's hits and misses are printed after the build. Linking (thin LTO) and build scripts' runs aren't cached

shinyobjectzb4e6f54d5573
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 3cc9a46a..3468889b 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -63,6 +63,11 @@ jobs:
runs-on: ${{ matrix.os }}
# a cold thin-LTO build of raea-cli with the plugin catalog is the long part; GitHub's own limit is 6 hours
timeout-minutes: 340
+ env:
+ # the compile cache (the "Compile cache" step): an R2 bucket, read and written by every build
+ RELEASE_CACHE_ENDPOINT: ${{ secrets.RELEASE_CACHE_ENDPOINT }}
+ AWS_ACCESS_KEY_ID: ${{ secrets.RELEASE_CACHE_KEY_ID }}
+ AWS_SECRET_ACCESS_KEY: ${{ secrets.RELEASE_CACHE_SECRET }}
steps:
- uses: actions/checkout@v4
with:
@@ -104,14 +109,27 @@ jobs:
wait
echo "kept $keep"
df -h . | tail -1
+ # The compile cache: sccache on an R2 bucket. GitHub's own cache can't carry a release build: a tag's run reads
+ # only its own tag's caches and the default branch's (so rc3's never reached rc4), and the repo's 10 GB are CI's.
+ # A bucket is read by every tag. A cold build fills it; a candidate after a small change compiles only the crates
+ # that changed and the ones above them. Linking (thin LTO) and build scripts' runs aren't cached. With no secrets
+ # (a fork) the build runs as before, uncached.
+ - name: Compile cache (sccache)
+ if: env.RAEA_PROMOTED_FROM == '' && env.AWS_ACCESS_KEY_ID != ''
+ uses: mozilla-actions/[email protected]
+ - name: Use the compile cache
+ if: env.RAEA_PROMOTED_FROM == '' && env.AWS_ACCESS_KEY_ID != ''
+ run: bash tools/release/compile-cache.sh
- name: Build
if: env.RAEA_PROMOTED_FROM == ''
run: |
feat=$(bash tools/bevy-plugins.sh features sdk/raea/bench/bevy-plugins)
- cargo build --profile dist --locked -p raea-cli --bin raea --no-default-features --features "$feat"
- cargo build --profile dist --locked -p raea-rune-host
- cargo build --profile dist --locked -p raea-page-host --features window
- if [ -n "${{ matrix.extra }}" ]; then cargo build --profile dist --locked -p ${{ matrix.extra }}; fi
+ t() { s=$SECONDS; "$@"; echo "::notice::${{ runner.os }} $(( (SECONDS - s) / 60 )) min: ${*:7}"; }
+ t cargo build --profile dist --locked -p raea-cli --bin raea --no-default-features --features "$feat"
+ t cargo build --profile dist --locked -p raea-rune-host
+ t cargo build --profile dist --locked -p raea-page-host --features window
+ if [ -n "${{ matrix.extra }}" ]; then t cargo build --profile dist --locked -p ${{ matrix.extra }}; fi
+ if [ -n "${RUSTC_WRAPPER:-}" ]; then sccache --show-stats; fi
mkdir ship
cp target/dist/raea target/dist/${{ matrix.lib }} target/dist/raea-rune-host target/dist/raea-page-host ship/
if [ -n "${{ matrix.extra }}" ]; then cp target/dist/${{ matrix.extra }} ship/; fi
@@ -179,6 +197,11 @@ jobs:
windows:
runs-on: windows-latest
timeout-minutes: 350
+ env:
+ # the compile cache, as build's
+ RELEASE_CACHE_ENDPOINT: ${{ secrets.RELEASE_CACHE_ENDPOINT }}
+ AWS_ACCESS_KEY_ID: ${{ secrets.RELEASE_CACHE_KEY_ID }}
+ AWS_SECRET_ACCESS_KEY: ${{ secrets.RELEASE_CACHE_SECRET }}
defaults:
run:
shell: bash
@@ -219,14 +242,22 @@ jobs:
done < <(tr -d '\r' < tools/release/models.tsv)
# the app targets' hosts a cargo call each: with raea-cli's crates in one call taffy's features unify and
# rune-taffy doesn't build; raea-perceive (`raea song`'s map, #43) a call of its own too
+ - name: Compile cache (sccache, as build's)
+ if: env.RAEA_PROMOTED_FROM == '' && env.AWS_ACCESS_KEY_ID != ''
+ uses: mozilla-actions/[email protected]
+ - name: Use the compile cache
+ if: env.RAEA_PROMOTED_FROM == '' && env.AWS_ACCESS_KEY_ID != ''
+ run: bash tools/release/compile-cache.sh
- name: Build
if: env.RAEA_PROMOTED_FROM == ''
run: |
feat=$(bash tools/bevy-plugins.sh features sdk/raea/bench/bevy-plugins)
- cargo build --profile dist --locked -p raea-cli --bin raea --no-default-features --features "$feat"
- cargo build --profile dist --locked -p raea-rune-host
- cargo build --profile dist --locked -p raea-page-host --features window
- cargo build --profile dist --locked -p raea-perceive
+ t() { s=$SECONDS; "$@"; echo "::notice::Windows $(( (SECONDS - s) / 60 )) min: ${*:7}"; }
+ t cargo build --profile dist --locked -p raea-cli --bin raea --no-default-features --features "$feat"
+ t cargo build --profile dist --locked -p raea-rune-host
+ t cargo build --profile dist --locked -p raea-page-host --features window
+ t cargo build --profile dist --locked -p raea-perceive
+ if [ -n "${RUSTC_WRAPPER:-}" ]; then sccache --show-stats; fi
- name: The candidate's binaries (tools/release/promoted-bins.sh)
if: env.RAEA_PROMOTED_FROM != ''
env:
diff --git a/tools/release/compile-cache.sh b/tools/release/compile-cache.sh
new file mode 100755
index 00000000..bd8a1f4a
--- /dev/null
+++ b/tools/release/compile-cache.sh
@@ -0,0 +1,39 @@
+#!/bin/bash
+# The release build's compile cache (.github/workflows/release.yml, "Use the compile cache"): sccache on an R2 bucket
+# that every tag's build reads and writes. The job's env carries RELEASE_CACHE_ENDPOINT (the account's R2 endpoint)
+# and the bucket's key as AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY; sccache is on PATH (mozilla-actions/sccache-action).
+# Each OS and architecture has its own prefix, so a key only ever names one platform's output.
+# If the bucket can't be reached, the build goes on uncached: a cache must never be why a release fails.
+set -euo pipefail
+: "${RELEASE_CACHE_ENDPOINT:?}" "${AWS_ACCESS_KEY_ID:?}" "${AWS_SECRET_ACCESS_KEY:?}" "${GITHUB_ENV:?}"
+export SCCACHE_BUCKET=raea-build-cache
+export SCCACHE_ENDPOINT="$RELEASE_CACHE_ENDPOINT"
+export SCCACHE_REGION=auto
+export SCCACHE_S3_KEY_PREFIX="release/${RUNNER_OS:-local}-${RUNNER_ARCH:-local}"
+# a request that fails mid-build compiles that crate locally instead of failing it
+export SCCACHE_IGNORE_SERVER_IO_ERROR=1
+# the server stays up for the whole build (cargo's calls are minutes apart while one crate links)
+export SCCACHE_IDLE_TIMEOUT=0
+
+if ! sccache --start-server >/dev/null 2>&1; then
+ echo "::warning::the compile cache didn't start; building uncached"
+ exit 0
+fi
+stats=$(sccache --show-stats)
+echo "$stats" | sed -n '/Cache location/p'
+# sccache checks the bucket when it starts: a key without write access is read-only, and no access is an error
+if echo "$stats" | grep -qiE 'Cache location +s3' && ! echo "$stats" | grep -qiE 'read.?only'; then
+ {
+ echo "RUSTC_WRAPPER=sccache"
+ for v in SCCACHE_BUCKET SCCACHE_ENDPOINT SCCACHE_REGION SCCACHE_S3_KEY_PREFIX SCCACHE_IGNORE_SERVER_IO_ERROR SCCACHE_IDLE_TIMEOUT; do
+ echo "$v=${!v}"
+ done
+ # C and C++ in build scripts: cc-rs wraps its compiler in sccache when RUSTC_WRAPPER is sccache; CMake reads these
+ echo "CMAKE_C_COMPILER_LAUNCHER=sccache"
+ echo "CMAKE_CXX_COMPILER_LAUNCHER=sccache"
+ } >> "$GITHUB_ENV"
+ echo "compile cache on: s3://$SCCACHE_BUCKET/$SCCACHE_S3_KEY_PREFIX"
+else
+ echo "::warning::the compile cache isn't writable; building uncached"
+ echo "$stats"
+fi