diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index fb2896ccab..9f956069eb 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -24,30 +24,36 @@ jobs: - name: Run tests run: cargo test --verbose - name: Build examples + run: cargo build --bins --verbose + - name: Run examples run: | cd examples - cargo build --verbose + ./run_all_headless.ps1 linux_stable: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + - name: Set up environment + run: | + mkdir .cargo + echo 'build.rustflags = ["--cfg", "CI"]' > .cargo/config.toml - name: Build tests run: cargo build --tests --verbose - name: Run tests run: cargo test --verbose - name: Build examples - run: | - cd examples - cargo build --verbose + run: cargo build --bins --verbose macos_stable: runs-on: macos-latest steps: - uses: actions/checkout@v3 + - name: Set up environment + run: | + mkdir .cargo + echo 'build.rustflags = ["--cfg", "CI"]' > .cargo/config.toml - name: Build tests run: cargo build --tests --verbose - name: Run tests run: cargo test --verbose - name: Build examples - run: | - cd examples - cargo build --verbose + run: cargo build --bins --verbose diff --git a/examples/run_all.ps1 b/examples/run_all.ps1 new file mode 100644 index 0000000000..9cbd8b2bb9 --- /dev/null +++ b/examples/run_all.ps1 @@ -0,0 +1,3 @@ +cargo build --bins +@(Get-ChildItem -Directory -Name) | %{cargo run --bin $_} +rm pipeline-caching\pipeline_cache.bin diff --git a/examples/run_all_headless.ps1 b/examples/run_all_headless.ps1 new file mode 100644 index 0000000000..edf1fddd58 --- /dev/null +++ b/examples/run_all_headless.ps1 @@ -0,0 +1,13 @@ +foreach ($example in Get-ChildItem -Directory -Name) { + $proc = Start-Process -FilePath "cargo" -ArgumentList "run --bin $example" -NoNewWindow -PassThru + + $timeouted = $null + + Wait-Process -InputObject $proc -Timeout 15 -ErrorAction SilentlyContinue -ErrorVariable timeouted + + if ($timeouted) { + kill $proc + } elseif ($proc.ExitCode -ne 0) { + Exit $proc.ExitCode + } +} diff --git a/examples/run_all_headless.sh b/examples/run_all_headless.sh new file mode 100755 index 0000000000..44f9b6407e --- /dev/null +++ b/examples/run_all_headless.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +set -euo pipefail + +exa -F . | rg '/$' | sd '/' '' | rargs timeout --preserve-status 15s cargo run --bin {} +rm -f pipeline-caching/pipeline_cache.bin diff --git a/vulkano/src/swapchain/surface.rs b/vulkano/src/swapchain/surface.rs index fc14c6f41e..47e540129d 100644 --- a/vulkano/src/swapchain/surface.rs +++ b/vulkano/src/swapchain/surface.rs @@ -61,9 +61,17 @@ pub struct Surface { impl Surface { /// Returns the instance extensions required to create a surface from a window of the given /// event loop. + #[cfg_attr(CI, allow(unreachable_code, unused))] pub fn required_extensions( event_loop: &impl HasDisplayHandle, ) -> Result { + #[cfg(CI)] + return Ok(InstanceExtensions { + khr_surface: true, + ext_headless_surface: true, + ..InstanceExtensions::empty() + }); + let mut extensions = InstanceExtensions { khr_surface: true, ..InstanceExtensions::empty() @@ -100,10 +108,14 @@ impl Surface { /// # Safety /// /// - The given `window` must outlive the created surface. + #[cfg_attr(CI, allow(unreachable_code, unused))] pub unsafe fn from_window_ref( instance: Arc, window: &(impl HasWindowHandle + HasDisplayHandle), ) -> Result, FromWindowError> { + #[cfg(CI)] + return Self::headless(instance, None).map_err(FromWindowError::CreateSurface); + let window_handle = window .window_handle() .map_err(FromWindowError::RetrieveHandle)?;