Skip to content

Infrastructure

Infrastructure #14

name: validation jobs
on:
merge_group:
pull_request:
push:
branches:
- main
- release-*
concurrency:
group: ${{github.workflow}}-${{github.ref}}
cancel-in-progress: ${{github.event_name == 'pull_request'}}
env:
CARGO_TERM_COLOR: always
# If nightly is breaking CI, modify this variable to target a specific nightly version.
NIGHTLY_TOOLCHAIN: nightly
jobs:
build-and-install-on-iOS:
if: ${{ github.event_name == 'merge_group' }}
runs-on: macos-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: actions/cache@v4
with:
path: |
target
key: ${{ runner.os }}-ios-install-${{ hashFiles('**/Cargo.lock') }}
# TODO: remove x86 target once it always run on arm GitHub runners
- name: Add iOS targets
run: rustup target add aarch64-apple-ios x86_64-apple-ios aarch64-apple-ios-sim
- name: Build and install iOS app in iOS Simulator.
run: cd examples/mobile && make install
build-android:
if: ${{ github.event_name == 'merge_group' }}
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-build-android-${{ hashFiles('**/Cargo.toml') }}
run-examples-linux:
# also run when pushed to main to update reference screenshots
if: ${{ github.event_name != 'pull_request' }}
runs-on: ubuntu-22.04
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- name: Build
# this uses the same command as when running the example to ensure build is reused
run: |
CI_TESTING_CONFIG=.github/example-run/all_tuples.ron cargo build --example all_tuples
- name: Run examples
run: |
for example in .github/example-run/*.ron; do
example_name=`basename $example .ron`
echo -n $example_name > last_example_run
echo "running $example_name - "`date`
time CI_TESTING_CONFIG=$example cargo run --example $example_name
sleep 10
done
- uses: actions/upload-artifact@v4
if: ${{ failure() && github.event_name == 'pull_request' }}
with:
name: example-run-linux
path: example-run/
run-examples-on-windows-dx12:
if: ${{ github.event_name != 'pull_request' }}
runs-on: windows-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Build
shell: bash
# this uses the same command as when running the example to ensure build is reused
run: |
CI_TESTING_CONFIG=.github/example-run/all_tuples.ron cargo build --example all_tuples
- name: Run examples
shell: bash
run: |
for example in .github/example-run/*.ron; do
example_name=`basename $example .ron`
echo -n $example_name > last_example_run
echo "running $example_name - "`date`
time CI_TESTING_CONFIG=$example cargo run --example $example_name
sleep 10
done
- uses: actions/upload-artifact@v4
if: ${{ failure() && github.event_name == 'pull_request' }}
with:
name: example-run-windows
path: example-run/
run-examples-on-wasm:
if: ${{ github.event_name == 'merge_group' }}
runs-on: ubuntu-22.04
timeout-minutes: 60
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
target: wasm32-unknown-unknown
- uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
~/.github/start-wasm-example/node_modules
target/
key: ${{ runner.os }}-wasm-run-examples-${{ hashFiles('**/Cargo.toml') }}
- name: install xvfb, llvmpipe and lavapipe
run: |
sudo apt-get update -y -qq
sudo add-apt-repository ppa:kisak/turtle -y
sudo apt-get update
sudo apt install -y xvfb libegl1-mesa libgl1-mesa-dri libxcb-xfixes0-dev mesa-vulkan-drivers
- name: Install wasm-bindgen
run: cargo install --force wasm-bindgen-cli
- name: Setup playwright
run: |
cd .github/start-wasm-example
npm install
npx playwright install --with-deps
cd ../..
- name: First Wasm build
run: |
cargo build --release --example testbed_ui --target wasm32-unknown-unknown
- name: Run examples
shell: bash
run: |
# start a webserver
python3 -m http.server --directory examples/wasm &
xvfb-run cargo run -p build-wasm-example -- --browsers chromium --browsers firefox --frames 25 --test 2d_shapes lighting text_debug breakout
- name: Save screenshots
uses: actions/upload-artifact@v4
with:
name: screenshots-wasm
path: .github/start-wasm-example/screenshot-*.png
build-without-default-features:
if: ${{ github.event_name == 'merge_group' }}
timeout-minutes: 30
strategy:
max-parallel: 1
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Build
run: cargo build --no-default-features
env:
CARGO_INCREMENTAL: 0
RUSTFLAGS: "-C debuginfo=0 -D warnings"
build-without-default-features-status:
if: |
always() &&
github.event_name == 'merge_group'
needs: build-without-default-features
runs-on: ubuntu-latest
steps:
- name: Successful
if: ${{ !(contains(needs.*.result, 'failure')) }}
run: exit 0
- name: Failing
if: ${{ contains(needs.*.result, 'failure') }}
run: exit 1
check-unused-dependencies:
if: ${{ github.event_name == 'merge_group' }}
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-check-unused-dependencies-${{ hashFiles('**/Cargo.toml') }}
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.NIGHTLY_TOOLCHAIN }}
- name: Installs cargo-udeps
run: cargo install --force cargo-udeps
- name: Run cargo udeps
run: cargo udeps