Skip to content

Commit

Permalink
ci: parallelize tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chyyran committed Feb 24, 2024
1 parent 8ba4b72 commit a5c684a
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 16 deletions.
59 changes: 55 additions & 4 deletions .github/workflows/pr-full-test.yml
Expand Up @@ -13,12 +13,63 @@ jobs:
steps:
- name: Approve
run: echo Full test suite for PRs needs approval by a maintainer
test:
test-presets:
runs-on: ubuntu-latest
continue-on-error: false
environment:
name: full-test
runs-on: windows-latest
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 preset processing
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
Expand All @@ -28,5 +79,5 @@ jobs:
uses: dtolnay/rust-toolchain@nightly
with:
toolchain: nightly
- name: Test
run: cargo test -p librashader --features=github-ci --test reflect -- --nocapture
- name: Test DXIL
run: cargo test -p librashader --features=github-ci --test reflect -- --nocapture compile_all_slang_presets_dxil_cross
49 changes: 46 additions & 3 deletions .github/workflows/push-full-test.yml
Expand Up @@ -8,7 +8,49 @@ on:
env:
CARGO_TERM_COLOR: always
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
continue-on-error: false
steps:
Expand All @@ -20,5 +62,6 @@ jobs:
uses: dtolnay/rust-toolchain@nightly
with:
toolchain: nightly
- name: Test
run: cargo test -p librashader --features=github-ci --test reflect -- --nocapture
- name: Test DXIL
run: cargo test -p librashader --features=github-ci --test reflect -- --nocapture compile_all_slang_presets_dxil_cross

20 changes: 11 additions & 9 deletions librashader/tests/reflect.rs
Expand Up @@ -18,7 +18,7 @@ use once_cell::sync::Lazy;
static ALL_SLANG_PRESETS: Lazy<RwLock<Vec<(PathBuf, ShaderPreset)>>> =
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")
.unwrap()
.collect::<Vec<_>>()
Expand All @@ -32,11 +32,13 @@ fn collect_all_slang_presets() -> Vec<(PathBuf, ShaderPreset)> {
return Some((path, preset));
}
Err(e) => {
#[cfg(feature = "github-ci")]
println!(
"::warning title=Failed to parse preset::{e:?} ({})",
path.display()
)
if collect_is_error {
#[cfg(feature = "github-ci")]
println!(
"::error title=Failed to parse preset::{e:?} ({})",
path.display()
)
}
}
}
}
Expand All @@ -48,7 +50,7 @@ fn collect_all_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)| {
!preset
.shaders
Expand All @@ -61,7 +63,7 @@ fn collect_all_loadable_slang_presets() -> Vec<(PathBuf, ShaderPreset)> {

#[test]
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 {
preset.shaders.into_par_iter().for_each(|shader| {
Expand Down Expand Up @@ -144,7 +146,7 @@ where

#[cfg(feature = "github-ci")]
println!(
"::warning title=Failed to reflect {} with {}::{e:?} ({})",
"::error title=Failed to reflect {} with {}::{e:?} ({})",
O::DEBUG,
R::DEBUG,
path.display()
Expand Down

0 comments on commit a5c684a

Please sign in to comment.