* ci: cancel superseded Workspace pull-request runs
The Workspace workflow (the native, MSRV and WASM legs) had no concurrency
group, so every push to a lockfile or dependency pull request started a second
full set of runs while the first set kept going, up to three runners each.
Give pull requests one group per pull request, so a newer push cancels the
older run, and give every other run a group of its own, so a main push, a
release tag or a manual run is neither cancelled nor replaced while queued.
github.ref is refs/pull/<n>/merge for a pull request, so two forks with the
same branch name stay separate. The pattern is the one merged in #772 for the
23 crate workflows, which left this reusable-workflow caller out.
The gate commands, jobs, inputs, matrices, timeouts, triggers and permissions
are untouched.
scripts/test-workspace-concurrency.py checks the policy itself: the two fields
and their documented expression shapes, one group per pull request and one per
other run, cancellation on a pull request only, and no job-level concurrency.
It reads the workflow without wiring anything into CI.
* test(workspace-concurrency): reject a scalar concurrency value
`read_concurrency` matched any line starting with `concurrency:` and read the
indented lines under it as fields. Under `concurrency: |` — a block scalar, not
a mapping — the workflow would have passed every policy check with the reader
alone, while the `PyYAML` cross-check that catches it is skipped when PyYAML is
absent. `concurrency: some-string` was rejected only by accident, through the
empty field set.
Require the header itself to be `concurrency:` (an inline comment allowed), and
test both scalar shapes. CodeRabbit found this on the pull request.
* sonar: analyse the Workspace concurrency guard as a test
scripts/test-workspace-concurrency.py is a unittest module: each case reads a
workflow and asserts on the policy. Listing it in sonar.test.inclusions keeps it
analysed as test code — linted, indexed and reported — instead of counting it as
production code that needs coverage, which is what failed the quality gate at
0.0% Coverage on New Code.
The exact path is appended to the three existing Rust patterns, so no other
script, and nothing else in the repository, is reclassified. No coverage
exclusion, quality threshold, workflow or build change.
* ci: run the Workspace concurrency guard in the gate
scripts/test-workspace-concurrency.py guarded the policy only when someone remembered to
run it, so a reworded concurrency block could land with 16 green checks. The gate's
`command` step now runs it before the cargo steps; `command` covers the Linux and macOS
legs, and it is one python3 call that needs nothing installed and fails in a second, ahead
of an hour of building.
The Windows leg keeps its existing `windows-command`: the script passes on a CRLF copy of
the workflow, but this change does not put an untested step on Windows.
`Interned::insert` looked the key up and then inserted it, two probes for a
new key. It now goes through `HashMap::entry`, one probe either way, and
counts that probe itself, so the tests count what the index does.
`author()` built a `String` key on every call. It now looks the author up
borrowed first, and allocates only for a new one.
Review on #1467.
Both writers found each run's font and colour by scanning the table so far
(write.rs `Tables`, doc/export.rs `Tables` and `author` for `\revtbl`), so
a document with n distinct fonts or colours took O(n²) comparisons. 3,000
runs with their own font and colour took 18,006,000 steps in the small
writer and 13,498,500 in the word-model writer.
Each table stays a Vec, in first-use order, so the output is unchanged.
`Interned` adds a map from key to place beside it: the colour, the font
name lowercased (as `eq_ignore_ascii_case` matched), or the trimmed author.
Tests count lookups through a test-only counter, as PdfCraft's own RTF
writer does: at most four per run for 3,000 runs in each writer, and font
names still match without regard to ASCII case.