ci: parallelize tests

This commit is contained in:
chyyran 2024-02-24 01:59:56 -05:00 committed by Ronny Chan
parent 8ba4b72cf1
commit a5c684a7ee
3 changed files with 113 additions and 17 deletions

View file

@ -13,12 +13,12 @@ jobs:
steps: steps:
- name: Approve - name: Approve
run: echo Full test suite for PRs needs approval by a maintainer run: echo Full test suite for PRs needs approval by a maintainer
test: test-presets:
runs-on: ubuntu-latest
continue-on-error: false
environment: environment:
name: full-test name: full-test
runs-on: windows-latest
needs: [approve-full-test] needs: [approve-full-test]
continue-on-error: false
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v4 uses: actions/checkout@v4
@ -28,5 +28,56 @@ jobs:
uses: dtolnay/rust-toolchain@nightly uses: dtolnay/rust-toolchain@nightly
with: with:
toolchain: nightly toolchain: nightly
- name: Test - name: Test preset processing
run: cargo test -p librashader --features=github-ci --test reflect -- --nocapture run: cargo test -p librashader --features=github-ci --test reflect -- --nocapture preprocess_all_slang_presets_parsed
test-naga:
runs-on: ubuntu-latest
continue-on-error: false
environment:
name: full-test
needs: [ approve-full-test ]
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Install nightly Rust
uses: dtolnay/rust-toolchain@nightly
with:
toolchain: nightly
- name: Test Naga reflection
run: cargo test -p librashader --features=github-ci --test reflect -- --nocapture compile_all_slang_presets_wgsl_naga compile_all_slang_presets_msl_naga compile_all_slang_presets_spirv_naga
test-cross:
runs-on: ubuntu-latest
continue-on-error: false
environment:
name: full-test
needs: [ approve-full-test ]
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Install nightly Rust
uses: dtolnay/rust-toolchain@nightly
with:
toolchain: nightly
- name: Test SPIRV-Cross
run: cargo test -p librashader --features=github-ci --test reflect -- --nocapture compile_all_slang_presets_msl_cross compile_all_slang_presets_glsl_cross compile_all_slang_presets_hlsl_cross compile_all_slang_presets_spirv_cross
test-dxil:
runs-on: windows-latest
continue-on-error: false
environment:
name: full-test
needs: [ approve-full-test ]
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Install nightly Rust
uses: dtolnay/rust-toolchain@nightly
with:
toolchain: nightly
- name: Test DXIL
run: cargo test -p librashader --features=github-ci --test reflect -- --nocapture compile_all_slang_presets_dxil_cross

View file

@ -8,7 +8,49 @@ on:
env: env:
CARGO_TERM_COLOR: always CARGO_TERM_COLOR: always
jobs: jobs:
test: test-presets:
runs-on: ubuntu-latest
continue-on-error: false
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Install nightly Rust
uses: dtolnay/rust-toolchain@nightly
with:
toolchain: nightly
- name: Test preset preprocessing
run: cargo test -p librashader --features=github-ci --test reflect -- --nocapture preprocess_all_slang_presets_parsed
test-naga:
runs-on: ubuntu-latest
continue-on-error: false
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Install nightly Rust
uses: dtolnay/rust-toolchain@nightly
with:
toolchain: nightly
- name: Test Naga Reflection
run: cargo test -p librashader --features=github-ci --test reflect -- --nocapture compile_all_slang_presets_wgsl_naga compile_all_slang_presets_msl_naga compile_all_slang_presets_spirv_naga
test-cross:
runs-on: ubuntu-latest
continue-on-error: false
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Install nightly Rust
uses: dtolnay/rust-toolchain@nightly
with:
toolchain: nightly
- name: Test SPIRV-Cross reflection
run: cargo test -p librashader --features=github-ci --test reflect -- --nocapture compile_all_slang_presets_msl_cross compile_all_slang_presets_glsl_cross compile_all_slang_presets_hlsl_cross compile_all_slang_presets_spirv_cross
test-dxil:
runs-on: windows-latest runs-on: windows-latest
continue-on-error: false continue-on-error: false
steps: steps:
@ -20,5 +62,6 @@ jobs:
uses: dtolnay/rust-toolchain@nightly uses: dtolnay/rust-toolchain@nightly
with: with:
toolchain: nightly toolchain: nightly
- name: Test - name: Test DXIL
run: cargo test -p librashader --features=github-ci --test reflect -- --nocapture run: cargo test -p librashader --features=github-ci --test reflect -- --nocapture compile_all_slang_presets_dxil_cross

View file

@ -18,7 +18,7 @@ use once_cell::sync::Lazy;
static ALL_SLANG_PRESETS: Lazy<RwLock<Vec<(PathBuf, ShaderPreset)>>> = static ALL_SLANG_PRESETS: Lazy<RwLock<Vec<(PathBuf, ShaderPreset)>>> =
Lazy::new(|| RwLock::new(collect_all_loadable_slang_presets())); Lazy::new(|| RwLock::new(collect_all_loadable_slang_presets()));
fn collect_all_slang_presets() -> Vec<(PathBuf, ShaderPreset)> { fn collect_all_slang_presets(collect_is_error: bool) -> Vec<(PathBuf, ShaderPreset)> {
let presets = glob("../test/shaders_slang/**/*.slangp") let presets = glob("../test/shaders_slang/**/*.slangp")
.unwrap() .unwrap()
.collect::<Vec<_>>() .collect::<Vec<_>>()
@ -32,14 +32,16 @@ fn collect_all_slang_presets() -> Vec<(PathBuf, ShaderPreset)> {
return Some((path, preset)); return Some((path, preset));
} }
Err(e) => { Err(e) => {
if collect_is_error {
#[cfg(feature = "github-ci")] #[cfg(feature = "github-ci")]
println!( println!(
"::warning title=Failed to parse preset::{e:?} ({})", "::error title=Failed to parse preset::{e:?} ({})",
path.display() path.display()
) )
} }
} }
} }
}
return None; return None;
}) })
.collect(); .collect();
@ -48,7 +50,7 @@ fn collect_all_slang_presets() -> Vec<(PathBuf, ShaderPreset)> {
} }
fn collect_all_loadable_slang_presets() -> Vec<(PathBuf, ShaderPreset)> { fn collect_all_loadable_slang_presets() -> Vec<(PathBuf, ShaderPreset)> {
let mut presets = collect_all_slang_presets(); let mut presets = collect_all_slang_presets(false);
presets.retain(|(_, preset)| { presets.retain(|(_, preset)| {
!preset !preset
.shaders .shaders
@ -61,7 +63,7 @@ fn collect_all_loadable_slang_presets() -> Vec<(PathBuf, ShaderPreset)> {
#[test] #[test]
pub fn preprocess_all_slang_presets_parsed() { pub fn preprocess_all_slang_presets_parsed() {
let presets = collect_all_slang_presets(); let presets = collect_all_slang_presets(true);
for (path, preset) in presets { for (path, preset) in presets {
preset.shaders.into_par_iter().for_each(|shader| { preset.shaders.into_par_iter().for_each(|shader| {
@ -144,7 +146,7 @@ where
#[cfg(feature = "github-ci")] #[cfg(feature = "github-ci")]
println!( println!(
"::warning title=Failed to reflect {} with {}::{e:?} ({})", "::error title=Failed to reflect {} with {}::{e:?} ({})",
O::DEBUG, O::DEBUG,
R::DEBUG, R::DEBUG,
path.display() path.display()