From 89765f88a8742e031eb0cdb74827d471e3eaab37 Mon Sep 17 00:00:00 2001 From: marc0246 <40955683+marc0246@users.noreply.github.com> Date: Mon, 30 Oct 2023 04:59:15 +0100 Subject: [PATCH 1/6] Add `run_all_headless.sh` --- examples/run_all_headless.sh | 5 +++++ 1 file changed, 5 insertions(+) create mode 100755 examples/run_all_headless.sh 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 From 96d7b7fedfc0740df194b168d9ed96d2eb1681fc Mon Sep 17 00:00:00 2001 From: marc0246 <40955683+marc0246@users.noreply.github.com> Date: Tue, 31 Oct 2023 16:04:47 +0100 Subject: [PATCH 2/6] Add `run_all.ps1` and `run_all_headless.ps1` --- examples/run_all.ps1 | 3 +++ examples/run_all_headless.ps1 | 13 +++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 examples/run_all.ps1 create mode 100644 examples/run_all_headless.ps1 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 + } +} From c86410a1cce7c62db9e1c86d1e3a19e3bc01a683 Mon Sep 17 00:00:00 2001 From: marc0246 <40955683+marc0246@users.noreply.github.com> Date: Tue, 31 Oct 2023 16:12:33 +0100 Subject: [PATCH 3/6] Pass `--bins` flag so cargo won't rebuild the examples when running them --- .github/workflows/rust.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index fb2896ccab..c7f371fd9f 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -26,7 +26,7 @@ jobs: - name: Build examples run: | cd examples - cargo build --verbose + cargo build --bins --verbose linux_stable: runs-on: ubuntu-latest steps: @@ -38,7 +38,7 @@ jobs: - name: Build examples run: | cd examples - cargo build --verbose + cargo build --bins --verbose macos_stable: runs-on: macos-latest steps: @@ -50,4 +50,4 @@ jobs: - name: Build examples run: | cd examples - cargo build --verbose + cargo build --bins --verbose From 20e9de5bebc0910feb0479795b6a9e201e0d9f32 Mon Sep 17 00:00:00 2001 From: marc0246 <40955683+marc0246@users.noreply.github.com> Date: Thu, 2 Nov 2023 01:23:10 +0100 Subject: [PATCH 4/6] Add conditional compilation for CI --- .github/workflows/rust.yml | 24 +++++++++++++++--------- vulkano/src/swapchain/surface.rs | 12 ++++++++++++ 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index c7f371fd9f..3192a97a17 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -19,35 +19,41 @@ jobs: # - name: Ninja Install # run: pip install ninja - uses: actions/checkout@v3 + - name: Set up environment + run: | + New-Item '.cargo' -ItemType 'directory' + 'build.rustflags = [''--cfg'', ''CI'']' | Out-File .cargo/config.toml -Encoding 'utf8' - name: Build tests run: cargo build --tests --verbose - name: Run tests run: cargo test --verbose - name: Build examples - run: | - cd examples - cargo build --bins --verbose + run: cargo build --bins --verbose 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 --bins --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 --bins --verbose + run: cargo build --bins --verbose 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)?; From e3fd82bed2e853c2dea9a6efea1bbc29b04ebf4c Mon Sep 17 00:00:00 2001 From: marc0246 <40955683+marc0246@users.noreply.github.com> Date: Thu, 2 Nov 2023 01:48:36 +0100 Subject: [PATCH 5/6] Run examples on Windows --- .github/workflows/rust.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 3192a97a17..df9a765599 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -29,6 +29,10 @@ jobs: run: cargo test --verbose - name: Build examples run: cargo build --bins --verbose + - name: Run examples + run: | + cd examples + ./run_all_headless.ps1 linux_stable: runs-on: ubuntu-latest steps: From 42f7c7b66213b2f452506e80abb51de8d82f3f33 Mon Sep 17 00:00:00 2001 From: marc0246 <40955683+marc0246@users.noreply.github.com> Date: Thu, 2 Nov 2023 18:28:24 +0100 Subject: [PATCH 6/6] Let's see what happens without `--cfg CI` --- .github/workflows/rust.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index df9a765599..9f956069eb 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -19,10 +19,6 @@ jobs: # - name: Ninja Install # run: pip install ninja - uses: actions/checkout@v3 - - name: Set up environment - run: | - New-Item '.cargo' -ItemType 'directory' - 'build.rustflags = [''--cfg'', ''CI'']' | Out-File .cargo/config.toml -Encoding 'utf8' - name: Build tests run: cargo build --tests --verbose - name: Run tests