-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
87 additions
and
37 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,5 +9,8 @@ | |
"license": "ISC", | ||
"devDependencies": { | ||
"@playwright/test": "^1.22.1" | ||
}, | ||
"dependencies": { | ||
"dotenv": "^16.0.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,4 @@ license = "MIT OR Apache-2.0" | |
|
||
[dependencies] | ||
xshell = "0.2" | ||
clap = { version = "3.1.12", features = ["derive"] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,66 @@ | ||
use std::{fs::File, io::Write}; | ||
|
||
use clap::Parser; | ||
use xshell::{cmd, Shell}; | ||
|
||
#[derive(Parser, Debug)] | ||
struct Args { | ||
/// Examples to build | ||
examples: Vec<String>, | ||
|
||
#[clap(short, long)] | ||
/// Run tests | ||
test: bool, | ||
|
||
#[clap(short, long)] | ||
/// Run on the given browsers. By default, chromium, firefox, webkit | ||
browsers: Vec<String>, | ||
|
||
#[clap(short, long)] | ||
/// Stop after this number of frames | ||
frames: Option<usize>, | ||
} | ||
|
||
fn main() { | ||
let example = std::env::args().nth(1).expect("abbb"); | ||
let sh = Shell::new().unwrap(); | ||
cmd!( | ||
sh, | ||
"cargo build --release --target wasm32-unknown-unknown --example {example}" | ||
) | ||
.run() | ||
.expect("Error building example"); | ||
cmd!( | ||
sh, | ||
"wasm-bindgen --out-dir examples/wasm/target --out-name wasm_example --target web target/wasm32-unknown-unknown/release/examples/{example}.wasm" | ||
) | ||
.run() | ||
.expect("Error creating wasm binding"); | ||
let cli = Args::parse(); | ||
eprintln!("{:?}", cli); | ||
|
||
assert!(!cli.examples.is_empty(), "must have at least one example"); | ||
|
||
let mut bevy_ci_testing = vec![]; | ||
if let Some(frames) = cli.frames { | ||
let mut file = File::create("ci_testing_config.ron").unwrap(); | ||
file.write_fmt(format_args!("(exit_after: Some({}))", frames)) | ||
.unwrap(); | ||
bevy_ci_testing = vec!["--features", "bevy_ci_testing"]; | ||
} | ||
|
||
for example in cli.examples { | ||
let sh = Shell::new().unwrap(); | ||
let bevy_ci_testing = bevy_ci_testing.clone(); | ||
cmd!( | ||
sh, | ||
"cargo build {bevy_ci_testing...} --release --target wasm32-unknown-unknown --example {example}" | ||
) | ||
.run() | ||
.expect("Error building example"); | ||
cmd!( | ||
sh, | ||
"wasm-bindgen --out-dir examples/wasm/target --out-name wasm_example --target web target/wasm32-unknown-unknown/release/examples/{example}.wasm" | ||
) | ||
.run() | ||
.expect("Error creating wasm binding"); | ||
|
||
if cli.test { | ||
let _dir = sh.push_dir(".github/start-wasm-example"); | ||
let mut browsers = cli.browsers.clone(); | ||
if !browsers.is_empty() { | ||
browsers.insert(0, "--project".to_string()); | ||
} | ||
cmd!(sh, "npx playwright test --headed {browsers...}") | ||
.env("SCREENSHOT_PREFIX", format!("screenshot-{example}")) | ||
.run() | ||
.expect("Error running playwright test"); | ||
} | ||
} | ||
} |