Skip to content

Commit

Permalink
hacks for running the examples on CI on a github runner
Browse files Browse the repository at this point in the history
  • Loading branch information
mockersf committed Jul 20, 2023
1 parent 7fe0853 commit e169e2a
Showing 1 changed file with 36 additions and 2 deletions.
38 changes: 36 additions & 2 deletions tools/example-showcase/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ enum Action {
#[arg(long)]
/// Take a screenshot
screenshot: bool,

#[arg(long)]
/// Running in CI (some adaptation to the code)
in_ci: bool,
},
/// Build the markdown files for the website
BuildWebsiteList {
Expand Down Expand Up @@ -111,6 +115,7 @@ fn main() {
wgpu_backend,
manual_stop,
screenshot,
in_ci,
} => {
let examples_to_run = parse_examples();

Expand All @@ -132,20 +137,49 @@ fn main() {
(false, true) => {
let mut file = File::create("example_showcase_config.ron").unwrap();
file.write_all(
b"(exit_after: Some(300), frame_time: Some(0.05), screenshot_frames: [100])",
b"(exit_after: Some(150), frame_time: Some(0.05), screenshot_frames: [100])",
)
.unwrap();
extra_parameters.push("--features");
extra_parameters.push("bevy_ci_testing");
}
(false, false) => {
let mut file = File::create("example_showcase_config.ron").unwrap();
file.write_all(b"(exit_after: Some(300))").unwrap();
file.write_all(b"(exit_after: Some(150))").unwrap();
extra_parameters.push("--features");
extra_parameters.push("bevy_ci_testing");
}
}

if in_ci {
// Removing desktop mode as is slows down too much in CI
let sh = Shell::new().unwrap();
cmd!(
sh,
"sed -i.bak 's/pub fn desktop_app() -> Self {/pub fn desktop_app() -> Self {Self::game()} pub fn desktop_app_old() -> Self {/' crates/bevy_winit/src/winit_config.rs"
)
.run()
.unwrap();

// Setting lights ClusterConfig to have less clusters by default
// This is needed as the default config is too much for the CI runner
cmd!(
sh,
"sed -i.bak 's/let config = config.copied().unwrap_or_default();/let config = config.copied().unwrap_or(ClusterConfig::FixedZ {total: 128, z_slices: 4, z_config: ClusterZConfig::default(), dynamic_resizing: true});/' crates/bevy_pbr/src/light.rs"
)
.run()
.unwrap();

// Sending extra WindowResize events. They are not sent on CI with xvfb x11 server
// This is needed for example split_screen that uses the window size to set the panels
cmd!(
sh,
"sed -i.bak 's/winit_state.low_power_event = true;/winit_state.low_power_event = true; window_events.window_resized.send(WindowResized {window: window_entity, width: window.width(), height: window.height()});/' crates/bevy_winit/src/lib.rs"
)
.run()
.unwrap();
}

let work_to_do = || {
examples_to_run
.iter()
Expand Down

0 comments on commit e169e2a

Please sign in to comment.