Skip to content

Issue #252 solved: build and test the Rust crates in CI - #253

Open
PRINCEKK122 wants to merge 3 commits into
oss-slu:mainfrom
PRINCEKK122:rust-ci
Open

PRINCEKK122 wants to merge 3 commits into
oss-slu:mainfrom
PRINCEKK122:rust-ci

Conversation

@PRINCEKK122

Copy link
Copy Markdown
Collaborator

Closes #252.

Problem

Nothing in CI builds or tests the Rust crates. .github/workflows/ holds meson-build.yml, which builds the C++ plugin on Windows with its test step commented out, and super-linter.yml, which lints YAML, GitHub Actions and clang-format. Neither runs cargo at all.

So relay, src/server and baton — where most current development happens — have had no automated coverage. That is how main came to be failing two relay tests with nobody aware of it (#251).

Change

A Rust workflow running on pull requests and pushes to main:

  • A matrix over relay, src/server and xplane_plugin/subprojects/baton, so each crate reports as its own check.
  • fail-fast: false, so one broken crate does not hide the state of the other two.
  • cargo build then cargo test per crate.
  • Cargo registry and target/ cached per crate, keyed on that crate's Cargo.lock.
  • No toolchain named: rust-toolchain.toml at the repository root decides, once Issue #188 solved: rename rust-toolchain.toml so the pin takes effect #243 lands. Until then runners use their default stable, which is the behaviour today.

The relay step installs wayland, x11, drm, udev and fontconfig headers first. Its iced dependency tree needs them to build; the other two crates are plain std and skip that step.

About the check on this PR

This may well come back red, and that is the point.

Two tests fail on main on Linux (#251): a_slow_python_reader_does_not_pace_imotions and a_python_process_that_stops_reading_is_dropped_not_waited_on. Both assert on socket backpressure that never materialises when the kernel buffers are large enough to absorb the test's volume.

Whether they also fail on a GitHub runner is unknown — nothing has ever run them there. This PR is the first time anyone finds out:

Either way the result is information the project does not currently have. I would rather surface it than special-case those two tests to get a green check.

Scope

Deliberately limited to the Rust crates. Re-enabling the commented-out Meson test step and the commented-out Ubuntu job is a separate question for whoever owns the plugin build.

@PRINCEKK122

Copy link
Copy Markdown
Collaborator Author

Rebased onto the branch for #251, so this is stacked on that PR. Without it the relay job is red for reasons that have nothing to do with the workflow, which makes this PR impossible to evaluate. The diff here therefore temporarily includes #251's commit touching relay/src/state.rs and relay/Cargo.toml — review that one over there, not here. Once #251 merges I will rebase onto main and that commit drops out on its own, leaving only .github/workflows/rust.yml.

@PRINCEKK122

Copy link
Copy Markdown
Collaborator Author

The workflow is green now that it is stacked on #251: relay, src/server and baton all pass, relay reporting 23 passed / 0 failed. https://github.com/oss-slu/PilotDataSynchronization/actions/runs/41191646149

Worth comparing against the first run of this branch before the rebase, https://github.com/oss-slu/PilotDataSynchronization/actions/runs/40808333057, which is the same workflow against unmodified main and reports 21 passed / 2 failed. That pair is the argument for this PR: main had two broken tests for days and nothing in CI could see it, because no workflow ran any Rust.

Also amended AGENTS.md, whose CI line listed only meson-build.yml and super-linter.yml.

@Sanjana-Siddani Sanjana-Siddani left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! The workflow looks good, and I ran the same --locked build and test locally for all three crates: relay 23, server 5 and baton 5, all passing. The mirror test also passed 30/30 for me.

One thing about merge order: this PR includes #265’s commit, but the fix for #265’s test is only here. So if #265 merges alone, the flaky test comes back. Could you move the “Feed the stalled-mirror test” commit into #265? Then we merge #265 first and this one after. Approving once that’s sorted

Nothing in CI touched the Rust side. meson-build.yml builds the C++
plugin on Windows with its test step commented out, and super-linter
lints YAML and clang-format. So relay, src/server and baton had no
automated coverage at all, which is how main came to be failing two
relay tests without anyone noticing (oss-slu#251).

Add a workflow that builds and tests all three crates on pull requests
and on pushes to main, as a matrix so each crate reports separately,
with fail-fast off so one failure does not hide the others.

The relay needs wayland, x11, drm and fontconfig headers because of its
iced dependency tree, installed only for that crate. No toolchain is
named: rust-toolchain.toml at the repository root decides, once oss-slu#243
lands. Cargo registry and target output are cached per crate, keyed on
each Cargo.lock.
SonarCloud's quality gate flagged githubactions:S8549, a MAJOR
vulnerability on the build step: dependencies resolved without locking
(CWE-494, CWE-829). One MAJOR on new code drops the security rating to
C, and the gate requires A.

relay/Cargo.toml pins iced and anyhow at "*", so an unlocked CI build
can resolve a different dependency set than anyone tested locally.
--locked builds the committed Cargo.lock instead, and fails loudly if a
Cargo.toml change ever lands without its matching lockfile update.

All three crates have Cargo.lock committed and pass with it: relay 23
tests, src/server 5, baton 0.
The test went red on CI again after oss-slu#251. The buffer bound in state.rs
was right; reducing SAMPLES from 3000 to 500 alongside it was not.

mirror_send try_sends into a 256-deep queue and drops when full, so a
fixed burst does not determine how much reaches the writer thread - the
race between the two threads does. A burst that loses it leaves the
writer with well under a bufferful, no write blocks, MIRROR_WRITE_TIMEOUT
never fires and the mirror is never dropped.

Feeding in batches until the mirror is actually dropped removes the guess.
The stalled reader never drains, so whatever the writer does get through
accumulates across batches and the timeout is reached regardless of how
any single batch races.

Verified against the mechanism that failed: 40/40 runs pinned to one core,
and 25/25 on one core against six competing CPU hogs.
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No CI builds or tests the Rust crates

2 participants