Matching CI to TextureCraft (#222)

* ci: port TextureCraft verification improvements

* fix: keep CI green on stable Rust
This commit is contained in:
Chris Hassebrook authored and GitHub committed 2026-11-14 08:52:48 +01:00
1 parent 848d7fd63b
commit bb7434478c
12 files changed
+54 -20

No files matched your search

-1
View File
@@ -24,7 +24,6 @@ jobs:
# Same craft-fonts commit as release.yml.
craft-fonts-ref: 3d9ab3a132ed0eff457e424226a435a901da30d3
os: '["ubuntu-24.04","windows-latest"]'
toolchain: "1.96.0"
# xtask ci runs cargo test (including doctests), not cargo nextest.
tools: ""
packages: >-
+7
View File
@@ -136,6 +136,13 @@ opt-level = 1
lto = "thin"
codegen-units = 1
# Fast optimized verification: each test executable otherwise repeats cross-crate LTO
# `false` keeps thin LTO within each crate; release packaging keeps the profile above
[profile.verify]
inherits = "release"
lto = false
codegen-units = 16
[profile.wasm-release]
inherits = "release"
opt-level = "s"
+1 -1
View File
@@ -179,7 +179,7 @@ pub struct Permit(Arc<AtomicUsize>);
impl ConnectionLimiter {
pub fn try_acquire(&self, max: usize) -> Option<Permit> {
self.0.fetch_update(Ordering::AcqRel, Ordering::Acquire, |n| (n < max).then_some(n + 1)).ok().map(|_| Permit(self.0.clone()))
self.0.try_update(Ordering::AcqRel, Ordering::Acquire, |n| (n < max).then_some(n + 1)).ok().map(|_| Permit(self.0.clone()))
}
}
+1 -1
View File
@@ -14,7 +14,7 @@ pub(crate) fn decode(bytes: &[u8], linear: bool) -> Result<Image> {
dds::ImageViewMut::new(bytemuck::cast_slice_mut(&mut data), size, dds::ColorFormat::RGBA_F32).ok_or_else(|| error("Invalid DDS dimensions".into()))?;
decoder.read_surface(view).map_err(|e| error(e.to_string()))?;
if !linear && decoder.format().precision() != dds::Precision::F32 {
for pixel in data.chunks_exact_mut(4) {
for pixel in data.as_chunks_mut::<4>().0 {
for value in pixel.iter_mut().take(3) {
*value = srgb_to_linear(*value);
}
+1 -1
View File
@@ -46,7 +46,7 @@ pub fn decode(bytes: &[u8], linear: bool) -> Result<Image> {
let mut data = img.into_rgba32f().into_raw();
if !(float || linear) {
for px in data.chunks_exact_mut(4) {
for px in data.as_chunks_mut::<4>().0 {
for c in px.iter_mut().take(3) {
*c = srgb_to_linear(*c);
}
+4 -4
View File
@@ -123,7 +123,7 @@ impl Mesh {
/// Area-weighted smooth normals over the index buffer.
pub fn compute_normals(&mut self) {
let mut n = vec![Vec3::ZERO; self.positions.len()];
for t in self.indices.chunks_exact(3) {
for t in self.indices.as_chunks::<3>().0 {
let (a, b, c) = (t[0] as usize, t[1] as usize, t[2] as usize);
let (Some(pa), Some(pb), Some(pc)) = (self.positions.get(a), self.positions.get(b), self.positions.get(c)) else { continue };
let face = (*pb - *pa).cross(*pc - *pa);
@@ -161,7 +161,7 @@ impl Mesh {
fn simple_tangents(&mut self) {
let mut acc = vec![Vec3::ZERO; self.positions.len()];
for t in self.indices.chunks_exact(3) {
for t in self.indices.as_chunks::<3>().0 {
let (a, b, c) = (t[0] as usize, t[1] as usize, t[2] as usize);
let (Some(pa), Some(pb), Some(pc)) = (self.positions.get(a), self.positions.get(b), self.positions.get(c)) else { continue };
let (Some(ua), Some(ub), Some(uc)) = (self.uvs.get(a), self.uvs.get(b), self.uvs.get(c)) else { continue };
@@ -211,7 +211,7 @@ impl Mesh {
}
}
let mut shared = vec![false; self.positions.len()];
for (_, tri) in self.indices.chunks_exact(3).enumerate().filter(|(t, _)| !is_mine.get(*t).copied().unwrap_or(false)) {
for (_, tri) in self.indices.as_chunks::<3>().0.iter().enumerate().filter(|(t, _)| !is_mine.get(*t).copied().unwrap_or(false)) {
for v in tri {
if let Some(s) = shared.get_mut(*v as usize) {
*s = true;
@@ -307,7 +307,7 @@ impl Mesh {
(m.positions.len() - 1) as u32
})
};
for t in self.indices.chunks_exact(3) {
for t in self.indices.as_chunks::<3>().0 {
if t.iter().any(|&i| i as usize >= self.positions.len()) {
continue;
}
+1 -1
View File
@@ -104,7 +104,7 @@ fn glyph(c: char) -> &'static str {
fn strokes(s: &str) -> impl Iterator<Item = Vec<[f32; 2]>> + '_ {
s.split(' ')
.filter(|t| !t.is_empty())
.map(|t| t.as_bytes().chunks_exact(2).map(|p| [p[0].saturating_sub(b'0') as f32, p[1].saturating_sub(b'0') as f32]).collect())
.map(|t| t.as_bytes().as_chunks::<2>().0.iter().map(|p| [p[0].saturating_sub(b'0') as f32, p[1].saturating_sub(b'0') as f32]).collect())
}
/// Longest text drawn (an allocation cap)
+1 -1
View File
@@ -115,7 +115,7 @@ impl Scene {
// Normals of the displaced surface, shared per spot so seams don't show
let moved = |i: u32| mesh.positions.get(i as usize).zip(offsets.get(i as usize)).map(|(p, o)| *p + *o);
let mut face_sums: HashMap<[i32; 3], Vec3> = HashMap::new();
for triangle in mesh.indices.chunks_exact(3) {
for triangle in mesh.indices.as_chunks::<3>().0 {
let (Some(a), Some(b), Some(c)) = (moved(triangle[0]), moved(triangle[1]), moved(triangle[2])) else { continue };
let face = (b - a).cross(c - a);
for spot in triangle.iter().filter_map(|&i| spots.get(i as usize)) {
+1 -1
View File
@@ -24,7 +24,7 @@ const BINS: usize = 64;
/// Histograms of the displayed 8-bit values: one for gray or isolated channels, else R, G and B.
fn histogram(px: &[u8], channels: usize) -> Vec<[u32; BINS]> {
let mut h = vec![[0u32; BINS]; channels];
for p in px.chunks_exact(4) {
for p in px.as_chunks::<4>().0 {
for (c, bins) in h.iter_mut().enumerate() {
bins[p[c] as usize * BINS / 256] += 1;
}
+3 -3
View File
@@ -1468,14 +1468,14 @@ fn material_assignment_previews_outputs_and_survives_function_editing() {
assert_eq!(harness.state().session.material_maps()[0].0, "baseColor");
let red_frame = harness.state().view3d.shown.clone().unwrap();
assert_ne!(before.2, red_frame.2, "assignment must invalidate the rendered frame");
let red_pixels = red_frame.2.chunks_exact(4).filter(|pixel| u16::from(pixel[0]) > u16::from(pixel[1]) + 30).count();
let red_pixels = red_frame.2.as_chunks::<4>().0.iter().filter(|pixel| u16::from(pixel[0]) > u16::from(pixel[1]) + 30).count();
assert!(red_pixels > 100, "the rendered mesh must show the assigned red image");
save(&mut harness, &directory, "material-assigned-red");
harness.state_mut().run("graph.node.param", json!({"id": source, "param": "color", "value": [0.02, 0.04, 0.8, 1.0]})).unwrap();
settle(&mut harness, 45);
let blue_frame = harness.state().view3d.shown.clone().unwrap();
let blue_pixels = blue_frame.2.chunks_exact(4).filter(|pixel| u16::from(pixel[2]) > u16::from(pixel[0]) + 30).count();
let blue_pixels = blue_frame.2.as_chunks::<4>().0.iter().filter(|pixel| u16::from(pixel[2]) > u16::from(pixel[0]) + 30).count();
assert!(blue_pixels > 100, "edits must refresh the assigned material");
assert_ne!(red_frame.2, blue_frame.2);
save(&mut harness, &directory, "material-assigned-blue");
@@ -1578,6 +1578,6 @@ fn explorer_inputs_and_graph_drop_share_labels_and_material_assignment() {
let binding = &harness.state().session.material_preview.channels[&MaterialChannel::BaseColor];
assert_eq!((binding.graph, binding.node), (0, NodeId(output)));
let frame = &harness.state().view3d.shown.as_ref().unwrap().2;
assert!(frame.chunks_exact(4).filter(|pixel| u16::from(pixel[0]) > u16::from(pixel[1]) + 30).count() > 100);
assert!(frame.as_chunks::<4>().0.iter().filter(|pixel| u16::from(pixel[0]) > u16::from(pixel[1]) + 30).count() > 100);
save(&mut harness, &directory, "graph-dropped-on-material");
}
+30 -4
View File
@@ -12,6 +12,31 @@ Run a feature module with a test-name filter, for example:
cargo test -p materialcraft-engine --test it graph_edit::
```
For faster optimized local verification, run the same workspace tests and doctests
with the `verify` profile:
```sh
cargo test --workspace --profile verify
```
`verify` inherits the release profile's optimization level and runtime checks, but
uses 16 codegen units and `lto = false`. Cargo retains thin LTO within each crate
without repeating cross-crate LTO for every test executable. The existing test
selection and ignore attributes still apply. Keep the target directory between
runs so Cargo can reuse unchanged build artifacts.
To compile the normal application binaries alongside the test binaries before
running them:
```sh
cargo build --workspace --bins --tests --profile verify
cargo test --workspace --profile verify
```
This profile is for local verification. Use `--release` for release validation and
performance measurements; its compiler settings remain unchanged. The regular
debug test profile and CI test selection also remain unchanged.
The language-switching test stays in its own executable because it changes the
process-global locale, which UI constructors also set.
@@ -21,7 +46,8 @@ unchanged. Tests in the shared executable can run concurrently across modules;
keep temporary paths unique and avoid changing process-wide state.
CI continues to use the shared gate workflow and `cargo xtask ci` on Ubuntu and
Windows: formatting, Clippy, workspace tests (including doctests), layering and
isolated per-package WebAssembly checks. The caller disables the shared
workflow's optional tool installation because this gate uses `cargo test` and
does not use nextest.
Windows, using the shared workflow's stable Rust default: formatting, layering,
Clippy, workspace tests (including doctests) and isolated per-package WebAssembly
checks. Layering runs before Clippy and tests to reject structural failures early.
The caller disables the shared workflow's optional tool installation because this
gate uses `cargo test` and does not use nextest.
+4 -2
View File
@@ -15,7 +15,7 @@ usage: cargo xtask <command>
commands:
layers enforce the crate dependency layering (xtask/src/layers.rs)
wasm cargo check --target wasm32-unknown-unknown for the wasm crates and the web app
ci fmt --check, clippy -D warnings, test, layers, wasm (stops at the first failure)
ci fmt --check, layers, clippy -D warnings, test, wasm (stops at the first failure)
version [set X.Y.Z[-pre]]
print the workspace version, or set it (Cargo.toml + Cargo.lock)
ico <out.ico> <in.png>...
@@ -153,11 +153,13 @@ fn cmd_ci() -> Result<(), String> {
}
};
type Step = (&'static str, Box<dyn Fn() -> Result<(), String>>);
// Reject invalid dependency layering before spending time compiling and running the workspace
let steps: Vec<Step> = vec![
("fmt", Box::new(cargo_step(&["fmt", "--all", "--", "--check"]))),
("layers", Box::new(cmd_layers)),
("clippy", Box::new(cargo_step(&["clippy", "--workspace", "--all-targets", "--", "-D", "warnings"]))),
("test", Box::new(cargo_step(&["test", "--workspace"]))),
("layers", Box::new(cmd_layers)),
("wasm", Box::new(cmd_wasm)),
];
for (i, (name, step)) in steps.iter().enumerate() {