Skip to content

Commit 6408188

Browse files
authored
Support CI tests for old rust-gpu versions (#41)
Adds `rust-gpu` versions, `0.8.0` and `0.9.0` to the Linux matrix on CI tests. `0.7.0` has a probably minor dependency error, but it's also 18 months old and there probably aren't many users of it. Notes: * Adds a version arg to, eg: `cargo xtask --rust-gpu-version 0.8.0`. * Offers a new CLI arg to workaround a bug where conflicting v3/v4 versions of `Cargo.lock` files (between the shader and workspace) cause a build error. See `force_overwrite_lockfiles_v4_to_v3` arg.
1 parent e08d597 commit 6408188

File tree

15 files changed

+579
-143
lines changed

15 files changed

+579
-143
lines changed

.github/workflows/push.yaml

+18-2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,23 @@ jobs:
1919
- ubuntu-latest
2020
- macos-latest
2121
- windows-latest
22+
rust-gpu-version: [latest]
23+
include:
24+
# As well as testing on each OS, we also want to test to make sure we're still supporting
25+
# older versions of `rust-gpu`. However, we can assume that these tests are already okay
26+
# across platforms, so we only need to test on Linux, the chepeast in terms of minutes.
27+
#
28+
# `0.7.0` currently fails building `spirv-builder-cli` with:
29+
# """
30+
# package `is_terminal_polyfill v1.70.1` cannot be built because it requires rustc
31+
# 1.70.0 or newer, while the currently active rustc version is 1.69.0-nightly
32+
# """
33+
# It's probably easily fixable. But also `0.7.0` was released in April 2023, so there's
34+
# unlikely many users of it?
35+
- os: ubuntu-latest
36+
rust-gpu-version: 0.8.0
37+
- os: ubuntu-latest
38+
rust-gpu-version: 0.9.0
2239
runs-on: ${{ matrix.os }}
2340
defaults:
2441
run:
@@ -35,9 +52,8 @@ jobs:
3552
rustup update
3653
- run: cargo test
3754
- name: Run a full build
38-
run: cargo xtask test-build
55+
run: cargo xtask test-build --rust-gpu-version ${{ matrix.rust-gpu-version }}
3956

40-
4157
lints:
4258
runs-on: ubuntu-latest
4359
steps:

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,8 @@ flamegraph.svg
2020

2121
# Compiled shader assets from running tests
2222
crates/shader-crate-template/shaders
23+
24+
# Build artefacts used by CI tests
25+
tmp/*
26+
crates/shader-crate-template/manifest.json
27+
crates/shader-crate-template/rust_gpu_shader_crate_template.spv

Cargo.lock

+19-12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/cargo-gpu/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ toml.workspace = true
2323
chrono.workspace = true
2424
http.workspace = true
2525
crossterm.workspace = true
26+
version_check = "0.9.5"
2627

2728
[dev-dependencies]
2829
test-log.workspace = true

crates/cargo-gpu/src/build.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub struct Build {
2222

2323
impl Build {
2424
/// Entrypoint
25-
#[expect(clippy::too_many_lines, reason = "these lines are fine")]
25+
#[expect(clippy::too_many_lines, reason = "It's not too confusing")]
2626
pub fn run(&mut self) -> anyhow::Result<()> {
2727
let spirv_builder_cli_path = self.install.run()?;
2828

@@ -150,7 +150,6 @@ impl Build {
150150
);
151151
std::fs::remove_file(spirv_manifest)?;
152152
}
153-
154153
Ok(())
155154
}
156155
}

crates/cargo-gpu/src/install.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,14 @@ pub struct Install {
104104

105105
impl Install {
106106
/// Returns a [`SpirvCLI`] instance, responsible for ensuring the right version of the `spirv-builder-cli` crate.
107-
fn spirv_cli(&self, shader_crate_path: &std::path::PathBuf) -> anyhow::Result<SpirvCli> {
107+
fn spirv_cli(&self, shader_crate_path: &std::path::Path) -> anyhow::Result<SpirvCli> {
108108
SpirvCli::new(
109109
shader_crate_path,
110110
self.spirv_install.spirv_builder_source.clone(),
111111
self.spirv_install.spirv_builder_version.clone(),
112112
self.spirv_install.rust_toolchain.clone(),
113113
self.spirv_install.auto_install_rust_toolchain,
114+
self.spirv_install.force_overwrite_lockfiles_v4_to_v3,
114115
)
115116
}
116117

crates/cargo-gpu/src/main.rs

+19-19
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ fn run() -> anyhow::Result<()> {
134134
"installing with final merged arguments: {:#?}",
135135
command.install
136136
);
137-
let _: std::path::PathBuf = command.install.run()?;
137+
command.install.run()?;
138138
}
139139
Command::Build(build) => {
140140
let shader_crate_path = build.install.spirv_install.shader_crate;
@@ -150,7 +150,7 @@ fn run() -> anyhow::Result<()> {
150150
command.run()?;
151151
} else {
152152
command.run()?;
153-
}
153+
};
154154
}
155155
Command::Show(show) => show.run()?,
156156
Command::DumpUsage => dump_full_usage_for_readme()?,
@@ -274,6 +274,23 @@ mod test {
274274
use crate::cache_dir;
275275
use std::io::Write as _;
276276

277+
fn copy_dir_all(
278+
src: impl AsRef<std::path::Path>,
279+
dst: impl AsRef<std::path::Path>,
280+
) -> anyhow::Result<()> {
281+
std::fs::create_dir_all(&dst)?;
282+
for maybe_entry in std::fs::read_dir(src)? {
283+
let entry = maybe_entry?;
284+
let ty = entry.file_type()?;
285+
if ty.is_dir() {
286+
copy_dir_all(entry.path(), dst.as_ref().join(entry.file_name()))?;
287+
} else {
288+
std::fs::copy(entry.path(), dst.as_ref().join(entry.file_name()))?;
289+
}
290+
}
291+
Ok(())
292+
}
293+
277294
pub fn shader_crate_template_path() -> std::path::PathBuf {
278295
let project_base = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));
279296
project_base.join("../shader-crate-template")
@@ -304,21 +321,4 @@ mod test {
304321
}
305322
std::fs::remove_dir_all(cache_dir).unwrap();
306323
}
307-
308-
pub fn copy_dir_all(
309-
src: impl AsRef<std::path::Path>,
310-
dst: impl AsRef<std::path::Path>,
311-
) -> anyhow::Result<()> {
312-
std::fs::create_dir_all(&dst)?;
313-
for maybe_entry in std::fs::read_dir(src)? {
314-
let entry = maybe_entry?;
315-
let ty = entry.file_type()?;
316-
if ty.is_dir() {
317-
copy_dir_all(entry.path(), dst.as_ref().join(entry.file_name()))?;
318-
} else {
319-
std::fs::copy(entry.path(), dst.as_ref().join(entry.file_name()))?;
320-
}
321-
}
322-
Ok(())
323-
}
324324
}

0 commit comments

Comments
 (0)