Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions .cargo/config_ci.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# This config is used for the CI workflow.
# Feel free to also use it locally for fast builds if you have the required setup!

[unstable]
codegen-backend = true

[profile.dev]
codegen-backend = "cranelift"

# Consider using llvm for this setting if you use tests that `#[should_panic]`,
# as cranelift only supports `panic = abort`.
# Since Foxtrot does not use `#[should_panic]` so far, we can use cranelift for speed increases.
[profile.dev.package."*"]
codegen-backend = "cranelift"

# Disable cranelift for release profile
[profile.release]
codegen-backend = "llvm"

# cranelift cannot build wasm32-unknown-unknown out of the box
[profile.web]
codegen-backend = "llvm"

[profile.web.package."*"]
codegen-backend = "llvm"

# Override the high opt-level from the dev profile for the test profile
[profile.test.package."*"]
opt-level = 1

[target.wasm32-unknown-unknown]
# Clang does not support wasm32-unknown-unknown,
# so it's hard to use a better linker.
# Note that Wasm already uses rust-lld by default.
rustflags = [
"-Dwarnings",
"-Cdebuginfo=line-tables-only",
"--cfg",
"getrandom_backend=\"wasm_js\"",
# Nightly
"-Zshare-generics=y",
"-Zthreads=0",
]
rustdocflags = [
"-Dwarnings",
# Nightly
"-Zshare-generics=y",
"-Zthreads=0",
]


[target.x86_64-unknown-linux-gnu]
linker = "clang"
rustflags = [
"-Dwarnings",
"-Cdebuginfo=line-tables-only",
# Faster linker
"-Clink-arg=--ld-path=wild",
# Nightly
"-Zshare-generics=y",
"-Zthreads=0",
]
rustdocflags = [
"-Dwarnings",
# Faster linker
"-Clink-arg=--ld-path=wild",
# Nightly
"-Zshare-generics=y",
"-Zthreads=0",
]
197 changes: 197 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
name: CI

on:
push:
branches: [main]
pull_request:
branches: [main]

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

env:
# Use the same Rust toolchain across jobs so they can share a cache.
toolchain: nightly-2026-01-22

jobs:
# Run tests.
test:
name: Tests
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
components: rustc-codegen-cranelift-preview
toolchain: ${{ env.toolchain }}

- name: Set LD_LIBRARY_PATH
id: ld_library_path
run: |
# Setting LD_LIBRARY_PATH is a workaround for <https://github.com/TheBevyFlock/bevy_new_2d/pull/318#issuecomment-2585935350>.
echo "LD_LIBRARY_PATH=$(rustc --print target-libdir)" >> $GITHUB_ENV

- name: Populate target directory from cache
uses: Swatinem/rust-cache@v2
with:
save-if: ${{ github.ref == 'refs/heads/main' }}
cache-directories: ${{ env.LD_LIBRARY_PATH }}

- name: Install dependencies
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libwayland-dev

- name: Active CI cargo config
run: mv .cargo/config_ci.toml .cargo/config.toml

- name: Install cargo binstall
uses: cargo-bins/cargo-binstall@main

- name: Install Wild
run: cargo binstall wild-linker --locked --force

- name: Install nextest
run: cargo binstall cargo-nextest --locked --force

- name: Run tests
run: cargo nextest run --locked --workspace --all-targets --no-fail-fast --no-tests warn

# Running doc tests separately is a workaround for <https://github.com/rust-lang/cargo/issues/6669>.
- name: Run doctests
run: cargo test --locked --workspace --doc

# Run clippy lints.
clippy:
name: Clippy
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
components: clippy, rustc-codegen-cranelift-preview
toolchain: ${{ env.toolchain }}

- name: Active CI cargo config
run: mv .cargo/config_ci.toml .cargo/config.toml

- name: Install cargo binstall
uses: cargo-bins/cargo-binstall@main

- name: Install Wild
run: cargo binstall wild-linker --locked --force

- name: Install dependencies
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libwayland-dev

- name: Populate target directory from cache
uses: Swatinem/rust-cache@v2
with:
save-if: false
shared-key: lints

- name: Run clippy lints
run: cargo clippy --locked --workspace --all-targets -- --deny warnings

# Check formatting.
format:
name: Format
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
components: rustfmt
toolchain: ${{ env.toolchain }}

- name: Run cargo fmt
run: cargo fmt --all -- --check

# Check documentation.
doc:
name: Docs
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
components: rustc-codegen-cranelift-preview
toolchain: ${{ env.toolchain }}

- name: Active CI cargo config
run: mv .cargo/config_ci.toml .cargo/config.toml

- name: Install cargo binstall
uses: cargo-bins/cargo-binstall@main

- name: Install Wild
run: cargo binstall wild-linker --locked --force

- name: Install dependencies
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libwayland-dev

- name: Populate target directory from cache
uses: Swatinem/rust-cache@v2
with:
save-if: false
shared-key: lints

- name: Check documentation
run: cargo doc --locked --workspace --document-private-items --no-deps

# Run Bevy lints.
bevy-lint:
name: Bevy linter
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
components: rustc-codegen-cranelift-preview, rustc-dev, llvm-tools-preview
toolchain: ${{ env.toolchain }}

- name: Install dependencies
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libwayland-dev

- name: Populate target directory from cache
uses: Swatinem/rust-cache@v2
with:
save-if: ${{ github.ref == 'refs/heads/main' }}
shared-key: lints

- name: Install Bevy linter
run: cargo install --git https://github.com/TheBevyFlock/bevy_cli --locked bevy_lint

- name: Add cranelift to rustc
run: rustup component add rustc-codegen-cranelift-preview --toolchain ${{ env.toolchain }}

- name: Active CI cargo config
run: mv .cargo/config_ci.toml .cargo/config.toml

- name: Install cargo binstall
uses: cargo-bins/cargo-binstall@main

- name: Install Wild
run: cargo binstall wild-linker --locked --force

- name: Run Bevy linter
run: bevy_lint --locked --workspace --all-targets
Loading