Skip to content

Update Actions Caches #73

Update Actions Caches

Update Actions Caches #73

Workflow file for this run

name: Update Actions Caches
permissions:
contents: read
on:
# Manually
workflow_dispatch:
# On PR merge
push:
branches:
- main
# After nightly release
schedule:
- cron: "0 1 * * *"
# Environment variables must be kept in sync with all workflows that defines them.
env:
CARGO_INCREMENTAL: 0
CARGO_PROFILE_TEST_DEBUG: 0
CARGO_PROFILE_DEV_DEBUG: 0
# Keep in sync between all workflows
RUSTFLAGS: "-C debuginfo=0 -D warnings"
jobs:
env:
runs-on: ubuntu-latest
outputs:
MSRV: ${{ steps.msrv.outputs.MSRV }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: $/.github/actions/install-rust
- name: get MSRV
id: msrv
run: |
msrv=`cargo metadata --no-deps --format-version 1 | jq --raw-output '.packages[] | select(.name=="bevy") | .rust_version'`
echo "MSRV=$msrv" >> $GITHUB_OUTPUT
build-caches:
name: Build Caches
needs: ["env"]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
toolchain: stable
target: ""
- os: macos-latest
toolchain: stable
target: ""
- os: windows-latest
toolchain: stable
target: ""
- os: ubuntu-latest
toolchain: nightly
target: ""
- os: ubuntu-latest
toolchain: ${{ needs.env.outputs.MSRV }}
target: ""
- os: macos-latest
toolchain: nightly
target: ""
# ci.yml / build-wasm-atomics
- os: ubuntu-latest
toolchain: nightly
target: wasm32-unknown-unknown
components: rust-src
rustflags: '-C debuginfo=0 -D warnings -C target-feature=+atomics,+bulk-memory --cfg getrandom_backend="wasm_js"'
command: cargo check --target wasm32-unknown-unknown -Z build-std=std,panic_abort
# ci.yml / build-wasm, and validation-jobs.yml / run-examples-on-wasm
- os: ubuntu-latest
toolchain: stable
target: wasm32-unknown-unknown
rustflags: '-C debuginfo=0 -D warnings --cfg getrandom_backend="wasm_js"'
command: |
cargo check --target wasm32-unknown-unknown
cargo build --release --example testbed_ui --target wasm32-unknown-unknown
# ci.yml / check-compiles-no-std and check-compiles-no-std-examples
- os: ubuntu-latest
toolchain: stable
target: x86_64-unknown-none
command: |
cargo check -p bevy --no-default-features --features default_no_std --target x86_64-unknown-none
cargo check -p bevy --no-default-features --features default_no_std,web --target x86_64-unknown-none
cd examples/no_std/library && cargo check --no-default-features --features libm,critical-section --target x86_64-unknown-none
# ci.yml / check-compiles-no-std-portable-atomic
- os: ubuntu-latest
toolchain: stable
target: thumbv6m-none-eabi
command: cargo check -p bevy --no-default-features --features default_no_std --target thumbv6m-none-eabi
# validation-jobs.yml / build-android
- os: ubuntu-latest
toolchain: stable
target: aarch64-linux-android
command: |
cargo install cargo-ndk
cargo ndk -t arm64-v8a -P 26 -o android_example/app/src/main/jniLibs build --package bevy_mobile_example
# validation-jobs.yml / build-and-install-on-iOS builds through Xcode, no shared build cache
- os: macos-14
toolchain: stable
target: aarch64-apple-ios-sim
steps:
# prepare the date - used to rebuild the cache daily to update the cache for rust nightly, even if no change on Bevy dependencies
- name: Get Date
id: get-date
run: |
echo "date=$(/bin/date -u "+%Y%m%d")" >> $GITHUB_OUTPUT
shell: bash
- name: Checkout Bevy main branch
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: "bevyengine/bevy"
ref: "main"
persist-credentials: false
- uses: $/.github/actions/install-rust
with:
channel: ${{ matrix.toolchain }}
target: ${{ matrix.target }}
components: ${{ matrix.components }}
# prepare the lockfile - to have a complete image of the dependencies on the current platform
- name: Create lock file
run: cargo update
# Fetch the cache using the complete key - to avoid rebuilding the cache if nothing changed
- uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
id: cache
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-${{ matrix.toolchain }}-${{ matrix.target }}-${{ hashFiles('**/Cargo.toml') }}-${{ hashFiles('Cargo.lock') }}-${{ steps.get-date.outputs.date }}
lookup-only: true
- name: Fetch Rust dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: cargo fetch
- name: Install Linux dependencies
if: steps.cache.outputs.cache-hit != 'true'
uses: $/.github/actions/install-linux-deps
with:
wayland: true
xkb: true
x264: true
fontconfig: true
# Build Bevy for the dev profile, used by check, doc, ...
- name: Build dev cache
if: steps.cache.outputs.cache-hit != 'true' && matrix.target == ''
run: cargo build --profile dev --package bevy
# Build Bevy for the test profile, used by test
- name: Build test cache
if: steps.cache.outputs.cache-hit != 'true' && matrix.target == ''
run: cargo build --profile test --package bevy
- name: Build cross-target cache
if: steps.cache.outputs.cache-hit != 'true' && matrix.command != ''
run: ${{ matrix.command }}
env:
RUSTFLAGS: ${{ matrix.rustflags || env.RUSTFLAGS }}
- name: Save cache
if: steps.cache.outputs.cache-hit != 'true'
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-${{ matrix.toolchain }}-${{ matrix.target }}-${{ hashFiles('**/Cargo.toml') }}-${{ hashFiles('Cargo.lock') }}-${{ steps.get-date.outputs.date }}
build-apt-cache:
name: Build apt kisak/turtle Cache
runs-on: ubuntu-24.04
steps:
# prepare the date - used to rebuild the cache daily to catch new versions
- name: Get Date
id: get-date
run: |
echo "date=$(/bin/date -u "+%Y%m%d")" >> $GITHUB_OUTPUT
shell: bash
- name: Install llvmpipe and lavapipe
run: |
sudo apt-get update -y -qq
sudo add-apt-repository ppa:kisak/turtle -y
DEBIAN_FRONTEND=noninteractive sudo apt-get install --no-install-recommends -yq \
libgl1-mesa-dri mesa-vulkan-drivers
rm -rf ~/apt-cache; mkdir ~/apt-cache
for package in libgbm1 libgl1-mesa-dri libglx-mesa0 mesa-libgallium libdisplay-info1 mesa-vulkan-drivers; do
echo $package
dpkg -L $package | while IFS= read -r f; do if test -f "$f"; then echo "$f"; fi; done | xargs -d '\n' cp --parents --target-directory ~/apt-cache/
done
- name: Save cache
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
~/apt-cache/
key: ${{ runner.os }}-apt-kisak_turtle-${{ steps.get-date.outputs.date }}