diff --git a/.config/nextest.toml b/.config/nextest.toml index ee7e1b8cf..306d431da 100644 --- a/.config/nextest.toml +++ b/.config/nextest.toml @@ -16,3 +16,10 @@ test-group = "nvenc" [[profile.default.overrides]] filter = "package(filmcraft-render) and binary(mixer_perf)" threads-required = "num-test-threads" + +# Real-time audio: a wall-clock device takes a period every 10.7 ms, and the mixer thread must +# stay ahead of it. With other tests' processes busy on every core, the thread isn't scheduled in +# time and the device plays silence (Windows runners, #4649), so nothing runs beside them. +[[profile.default.overrides]] +filter = "package(filmcraft-ui-egui) and binary(play_ahead)" +threads-required = "num-test-threads" diff --git a/.github/workflows/ci-windows.yml b/.github/workflows/ci-windows.yml new file mode 100644 index 000000000..d872d2012 --- /dev/null +++ b/.github/workflows/ci-windows.yml @@ -0,0 +1,76 @@ +name: CI (Windows) + +# The Windows leg of the gate: clippy and the tests of the crates with Windows-only code, on pull +# requests and pushes to main that touch that code, and on pull requests labelled `full-ci`. +# The Linux gate (ci.yml) still runs everything else on every pull request. +# +# Most bug reports come from Windows, and code there differs: WASAPI audio (the scrub output and +# playback, #2633), the graphics test start and the registry driver lookup (#1061), Media +# Foundation and D3D11 decoding (crates/platform). Nothing else runs these crates' tests on +# Windows. Not the full `cargo xtask ci`: on a cold windows-latest runner that is well over an +# hour, and its wasm, layering and asset steps don't differ by platform. +on: + push: + branches: [main] + pull_request: + # `labeled`: adding `full-ci` starts it. Other labels skip (see concurrency and the scope job). + types: [opened, synchronize, reopened, labeled] + workflow_dispatch: + +permissions: + contents: read + +# Its own group, so the Windows leg never cancels the Linux gate. A newer push to a PR branch +# cancels its older run; a label other than `full-ci` gets a group of its own, so it cancels nothing. +concurrency: + group: ci-windows-${{ github.event_name == 'pull_request' && github.ref || github.run_id }}${{ github.event.action == 'labeled' && github.event.label.name != 'full-ci' && format('-label-{0}', github.run_id) || '' }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + +jobs: + windows-scope: + if: github.event.action != 'labeled' || github.event.label.name == 'full-ci' + uses: storytold/craft-common-actions/.github/workflows/changed-paths.yml@main + with: + label: full-ci + # The crates and files with `cfg(windows)` code or Windows-only behaviour, and what decides + # how they build: their manifests, the lockfile and cargo's configuration (a dependency bump + # can break only Windows). + paths: | + .github/workflows/ci-windows.yml + apps/filmcraft/* + crates/platform/* + crates/media/* + crates/engine/src/autosave* + crates/engine/Cargo.toml + crates/gpu/* + crates/testkit/* + crates/ui-egui/src/frames.rs + crates/ui-egui/src/scrub.rs + crates/ui-egui/src/hooks.rs + crates/ui-egui/src/app/playback.rs + crates/ui-egui/src/app/playback/* + crates/ui-egui/src/app/prefs.rs + crates/ui-egui/tests/it/scrub_* + crates/ui-egui/Cargo.toml + Cargo.toml + Cargo.lock + .cargo/* + + gate-windows: + needs: windows-scope + if: needs.windows-scope.outputs.matched == 'true' + # Tracks @main so suite-wide CI fixes reach every app without a PR in each repository. + uses: storytold/craft-common-actions/.github/workflows/gate.yml@main + with: + os: '["windows-latest"]' + # Same craft-fonts commit as ci.yml and release.yml. + craft-fonts-ref: b076417b5880bd4154bd22f00695b1d28c6bea83 + timeout-minutes: 120 + # The tests run under nextest (the gate installs it), as in `cargo xtask ci` on Linux: each + # test in a process of its own, with .config/nextest.toml's groups. Under `cargo test` the + # tests of one binary share a process, rayon's global pool included, so one test's work + # waits behind another's and the timing-bound UI tests fail now and then. + windows-command: | + pkgs=(-p filmcraft -p filmcraft-platform -p filmcraft-media -p filmcraft-engine -p filmcraft-gpu -p filmcraft-ui-egui) + cargo clippy "${pkgs[@]}" --all-targets --locked --keep-going -- -D warnings + cargo nextest run "${pkgs[@]}" --locked --lib --bins --tests --no-fail-fast diff --git a/apps/filmcraft/src/control_server/tests.rs b/apps/filmcraft/src/control_server/tests.rs index 62737cdfb..674aa2775 100644 --- a/apps/filmcraft/src/control_server/tests.rs +++ b/apps/filmcraft/src/control_server/tests.rs @@ -142,7 +142,13 @@ fn timed_out_connection_releases_slot(partial: &[u8]) { let completion = finished.recv_timeout(Duration::from_secs(5)); let mut unsolicited = String::new(); if completion.is_ok() { - client.read_to_string(&mut unsolicited).unwrap(); + // Windows can end the expired connection with a reset instead of a close. Either way no + // reply came, and bytes read before a reset stay in `unsolicited` for the check below. + match client.read_to_string(&mut unsolicited) { + Ok(_) => {} + Err(e) if matches!(e.kind(), std::io::ErrorKind::ConnectionReset | std::io::ErrorKind::ConnectionAborted) => {} + Err(e) => panic!("reading after the server closed the connection failed: {e}"), + } } // Always unblock and join the test worker before asserting, even on the unfixed server. let unexpected_command = rx.try_recv().is_ok(); diff --git a/crates/engine/src/lib.rs b/crates/engine/src/lib.rs index f8a7f6a38..d7b5925b9 100644 --- a/crates/engine/src/lib.rs +++ b/crates/engine/src/lib.rs @@ -123,9 +123,15 @@ pub fn private_temp_dir() -> std::io::Result { *cached = Some((path.clone(), None)); return Ok(path); } - let mut dir = std::fs::DirBuilder::new(); + // Owner-only on Unix. Elsewhere there's no mode to set, and a `mut` would be unused. #[cfg(unix)] - std::os::unix::fs::DirBuilderExt::mode(&mut dir, 0o700); + let dir = { + let mut dir = std::fs::DirBuilder::new(); + std::os::unix::fs::DirBuilderExt::mode(&mut dir, 0o700); + dir + }; + #[cfg(not(unix))] + let dir = std::fs::DirBuilder::new(); // `create` fails when the name exists, so a folder someone else made is never accepted match dir.create(&path) { Ok(()) => { diff --git a/crates/ui-egui/tests/it/perf_ui.rs b/crates/ui-egui/tests/it/perf_ui.rs index eb41acb00..f7edf0a32 100644 --- a/crates/ui-egui/tests/it/perf_ui.rs +++ b/crates/ui-egui/tests/it/perf_ui.rs @@ -312,12 +312,17 @@ fn program_monitor_plays_on_while_a_value_is_dragged() { d.harness.state_mut().play(1.0); let mut frames = std::collections::BTreeSet::new(); let mut newest = at_rest.revision; - for i in 0..90 { + // Drag until five frames have shown, for up to ~10 s: on a busy CI runner the workers can take + // longer than a second and a half to finish frames. A picture held for the whole drag still fails. + for i in 0..600 { // one change and one UI pass, as a mouse move while dragging the value d.exec("effects.setParam", json!({"clip": clip, "effect": "crop", "param": "left", "value": (i % 30) as f64})); let shown = d.harness.state().program_picture().unwrap(); frames.insert(shown.frame); newest = newest.max(shown.revision); + if frames.len() >= 5 && newest > at_rest.revision { + break; + } std::thread::sleep(std::time::Duration::from_millis(16)); } assert!(frames.len() >= 5, "the picture kept playing during the drag: frames shown {frames:?}");