Skip to content

Commit

Permalink
Dynamic linking feature (#294)
Browse files Browse the repository at this point in the history
- Removes incremental build from CI
- Adds rust-cache for cargo build times
- Reduces example time
-  Separates cargo test build from execution
  • Loading branch information
naomijub authored Apr 10, 2024
1 parent a99149b commit b678b6c
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 106 deletions.
4 changes: 2 additions & 2 deletions .github/example-run/external_plugin.ron
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(
exit_after: Some(1000),
exit_after: Some(200),
frame_time: Some(0.03),
screenshot_frames: [101],
screenshot_frames: [100],
)
4 changes: 2 additions & 2 deletions .github/example-run/platformer.ron
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(
exit_after: Some(1000),
exit_after: Some(200),
frame_time: Some(0.03),
screenshot_frames: [200],
screenshot_frames: [100],
)
4 changes: 2 additions & 2 deletions .github/example-run/spawn_prefab_with_physics.ron
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(
exit_after: Some(1000),
exit_after: Some(200),
frame_time: Some(0.03),
screenshot_frames: [101],
screenshot_frames: [100],
)
62 changes: 18 additions & 44 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,17 @@ jobs:
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Cache
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo_${{ hashFiles('**/Cargo.toml') }}
- name: Install stable@stable toolchain
uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Install Dependencies
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libwayland-dev
- name: Compile
run: cargo test --no-run --locked --release
- name: Run cargo test
run: cargo test --workspace --no-default-features --profile=ci
run: cargo test --workspace --no-default-features --release
env:
RUSTFLAGS: "-C debuginfo=0"

test_all:
name: Test all features
Expand All @@ -57,49 +52,36 @@ jobs:
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Cache
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo_${{ hashFiles('**/Cargo.toml') }}
- name: Install stable@stable toolchain
uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Install Dependencies
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libwayland-dev
- name: Compile
run: cargo test --no-run --locked --release
- name: Run cargo test
run: cargo test --workspace --all-features --profile=ci
run: cargo test --workspace --all-features --release
env:
RUSTFLAGS: "-C debuginfo=0"

test_all_macos_n_windows:
strategy:
matrix:
os: [windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
name: Test ${{ matrix.os }} all features
timeout-minutes: 30
timeout-minutes: 60
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Cache
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.toml') }}
- name: Install stable@stable toolchain
uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Compile
run: cargo test --no-run --locked --release
- name: Run cargo test
run: cargo test --workspace --all-features --release
env:
CARGO_INCREMENTAL: 0
RUSTFLAGS: "-C debuginfo=0"


Expand All @@ -111,25 +93,17 @@ jobs:
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Cache
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo_${{ hashFiles('**/Cargo.toml') }}
- name: Install stable@stable toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- uses: Swatinem/rust-cache@v2
- name: Install Dependencies
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libwayland-dev
- name: Run clippy
run: cargo clippy --all-features -- -D warnings


# Run cargo fmt --all -- --check
format:
name: Format
Expand Down
48 changes: 9 additions & 39 deletions .github/workflows/example_validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,34 +37,24 @@ jobs:
sudo apt-get update
sudo apt install -y xvfb libegl1-mesa libgl1-mesa-dri libxcb-xfixes0-dev mesa-vulkan-drivers
- 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_${{ hashFiles('**/Cargo.toml') }}
- uses: dtolnay/rust-toolchain@nightly
with:
toolchain: nightly
target: x86_64-unknown-linux-gnu
- uses: Swatinem/rust-cache@v2
- name: Build bevy
# this uses the same command as when running the example to ensure build is reused
run: CARGO_PROFILE_RELEASE_DEBUG=true TRACE_CHROME=trace-platformer.json CI_TESTING_CONFIG=.github/example-run/platformer.ron cargo +nightly build --example platformer --profile=ci --features "bevy_xpbd_3d,bevy/bevy_ci_testing,bevy/trace_chrome,bevy/trace,backtrace"
run: CARGO_PROFILE_RELEASE_DEBUG=true TRACE_CHROME=trace-platformer.json CI_TESTING_CONFIG=.github/example-run/platformer.ron cargo +nightly build --example platformer --release --features "bevy_xpbd_3d,bevy/bevy_ci_testing,bevy/trace_chrome,bevy/trace,backtrace"
env:
CARGO_INCREMENTAL: 0
RUSTFLAGS: "-C debuginfo=0"
- name: Run examples
env:
CARGO_INCREMENTAL: 0
RUSTFLAGS: "-C debuginfo=0"
run: |
example_name=`basename plaformer.ron`
echo -n $example_name > last_example_run
echo "running platformer - "`date`
time CARGO_PROFILE_RELEASE_DEBUG=true TRACE_CHROME=trace-platformer.json CI_TESTING_CONFIG=.github/example-run/platformer.ron xvfb-run cargo +nightly run --profile=ci --example platformer --features "backtrace,bevy_xpbd_3d,bevy/bevy_ci_testing,bevy/trace_chrome,bevy/trace"
time CARGO_PROFILE_RELEASE_DEBUG=true TRACE_CHROME=trace-platformer.json CI_TESTING_CONFIG=.github/example-run/platformer.ron xvfb-run cargo +nightly run --release --example platformer --features "backtrace,bevy_xpbd_3d,bevy/bevy_ci_testing,bevy/trace_chrome,bevy/trace"
sleep 10
if [ `find ./ -maxdepth 1 -name 'screenshot-*.png' -print -quit` ]; then
mkdir screenshots-platformer
Expand Down Expand Up @@ -107,34 +97,24 @@ jobs:
sudo apt-get update
sudo apt install -y xvfb libegl1-mesa libgl1-mesa-dri libxcb-xfixes0-dev mesa-vulkan-drivers
- 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_${{ hashFiles('**/Cargo.toml') }}
- uses: dtolnay/rust-toolchain@nightly
with:
toolchain: nightly
target: x86_64-unknown-linux-gnu
- uses: Swatinem/rust-cache@v2
- name: Build bevy
# this uses the same command as when running the example to ensure build is reused
run: TRACE_CHROME=trace-spawn_prefab_with_physics.json CI_TESTING_CONFIG=.github/example-run/spawn_prefab_with_physics.ron cargo +nightly build --example spawn_prefab_with_physics --profile=ci --features "bevy_xpbd_3d,bevy/bevy_ci_testing,bevy/trace_chrome,bevy/trace"
run: TRACE_CHROME=trace-spawn_prefab_with_physics.json CI_TESTING_CONFIG=.github/example-run/spawn_prefab_with_physics.ron cargo +nightly build --example spawn_prefab_with_physics --release --features "bevy_xpbd_3d,bevy/bevy_ci_testing,bevy/trace_chrome,bevy/trace"
env:
CARGO_INCREMENTAL: 0
RUSTFLAGS: "-C debuginfo=0"
- name: Run examples
env:
CARGO_INCREMENTAL: 0
RUSTFLAGS: "-C debuginfo=0"
run: |
example_name=`basename plaformer.ron`
echo -n $example_name > last_example_run
echo "running spawn_prefab_with_physics - "`date`
time TRACE_CHROME=trace-spawn_prefab_with_physics.json CI_TESTING_CONFIG=.github/example-run/spawn_prefab_with_physics.ron xvfb-run cargo +nightly run --profile=ci --example spawn_prefab_with_physics --features "bevy_xpbd_3d,bevy/bevy_ci_testing,bevy/trace_chrome,bevy/trace"
time TRACE_CHROME=trace-spawn_prefab_with_physics.json CI_TESTING_CONFIG=.github/example-run/spawn_prefab_with_physics.ron xvfb-run cargo +nightly run --release --example spawn_prefab_with_physics --features "bevy_xpbd_3d,bevy/bevy_ci_testing,bevy/trace_chrome,bevy/trace"
sleep 10
if [ `find ./ -maxdepth 1 -name 'screenshot-*.png' -print -quit` ]; then
mkdir screenshots-spawn_prefab_with_physics
Expand Down Expand Up @@ -177,34 +157,24 @@ jobs:
sudo apt-get update
sudo apt install -y xvfb libegl1-mesa libgl1-mesa-dri libxcb-xfixes0-dev mesa-vulkan-drivers
- 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_${{ hashFiles('**/Cargo.toml') }}
- uses: dtolnay/rust-toolchain@nightly
with:
toolchain: nightly
target: x86_64-unknown-linux-gnu
- uses: Swatinem/rust-cache@v2
- name: Build bevy
# this uses the same command as when running the example to ensure build is reused
run: TRACE_CHROME=trace-external_plugin.json CI_TESTING_CONFIG=.github/example-run/external_plugin.ron cargo +nightly build --bin plugin_test --profile=ci --features "bevy/bevy_ci_testing,bevy/trace_chrome,bevy/trace"
run: TRACE_CHROME=trace-external_plugin.json CI_TESTING_CONFIG=.github/example-run/external_plugin.ron cargo +nightly build --bin plugin_test --release --features "bevy/bevy_ci_testing,bevy/trace_chrome,bevy/trace"
env:
CARGO_INCREMENTAL: 0
RUSTFLAGS: "-C debuginfo=0"
- name: Run examples
env:
CARGO_INCREMENTAL: 1
RUSTFLAGS: "-C debuginfo=0"
run: |
example_name=`basename plaformer.ron`
echo -n $example_name > last_example_run
echo "running external_plugin - "`date`
time TRACE_CHROME=trace-external_plugin.json CI_TESTING_CONFIG=.github/example-run/external_plugin.ron xvfb-run cargo +nightly run --profile=ci --bin plugin_test --features "bevy/bevy_ci_testing,bevy/trace_chrome,bevy/trace"
time TRACE_CHROME=trace-external_plugin.json CI_TESTING_CONFIG=.github/example-run/external_plugin.ron xvfb-run cargo +nightly run --release --bin plugin_test --features "bevy/bevy_ci_testing,bevy/trace_chrome,bevy/trace"
sleep 10
if [ `find ./ -maxdepth 1 -name 'screenshot-*.png' -print -quit` ]; then
mkdir screenshots-external_plugin
Expand Down
10 changes: 0 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 20 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ backtrace-on-stack-overflow = {version = "0.3", optional = true}
[workspace.lints.rust]
future-incompatible = "warn"
nonstandard_style = "deny"
non_local_definitions = { level = "allow", priority = 2 }

[workspace.lints.clippy]
nursery = { level = "deny", priority = -1 }
Expand All @@ -125,25 +126,37 @@ workspace = true

[profile.dev]
opt-level = 1
overflow-checks = false
incremental = true # works well when target/ is stored

[profile.dev.package."*"]
opt-level = 3

[profile.ci]
inherits = "dev"
opt-level = 0
[profile.release-fast]
inherits = "release"
debug = 0
strip = "none"
strip = "debuginfo"
lto = false
codegen-units = 256
incremental = true
incremental = false

[profile.retail]
inherits = "release"
lto = true

[profile.release-lto]
inherits = "release"
lto = "thin"

[features]
backtrace = ["backtrace-on-stack-overflow"]
bevy_xpbd_3d = ["dep:space_bevy_xpbd_plugin"]
persistence_editor = []
no_event_registration = ["space_prefab/no_event_registration"]
default = ["bevy_xpbd_3d", "persistence_editor", "bevy/dynamic_linking", "space_prefab/editor"]
default = [
"bevy_xpbd_3d",
"persistence_editor",
"space_prefab/editor",
]

[[example]]
name = "platformer"
Expand Down

0 comments on commit b678b6c

Please sign in to comment.