Repository navigation
Speed up CI tests and the docs build; unify test conventions - #266
Merged
Merged
Conversation
The tests themselves run in under a minute; CI time was coverlet instrumentation. Two generated members in MTConnect.NET-JSON-cppagent (Streams/JsonEvents.g.cs and Streams/JsonSamples.g.cs, ~5,000-line constructors plus getters with hundreds of branches) took ~9.5 minutes to instrument, repeated in every test project that loads the assembly (JSON-cppagent, Common, Compliance, Integration). - Exclude those two files from coverage (both runsettings). The solution-wide unit run with coverage drops to ~44 s locally; the JSON-cppagent project alone from 9m34s to 7s. - Collect coverage on ubuntu only; the Windows leg runs tests plain. - Give every test project its own TRX (LogFilePrefix) instead of a shared LogFileName that each project overwrote, and replace the three copied zero-test guards with tools/ci/check-trx.sh, which checks every TRX. - Add a per-PR concurrency group that cancels superseded PR runs, a NuGet package cache, and a 45 min job timeout. - E2E route-check shards build only Docs-Tests (not the whole solution) and skip coverage that was never merged into the report. - docs.yml: scope the `pages` concurrency group to the deploy job so PR docs builds no longer queue behind each other. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Add tests/Directory.Build.props. It imports the root props and adds
Microsoft.NET.Test.Sdk 17.14.1, NUnit 3.14.0, NUnit3TestAdapter 4.6.0
and coverlet.collector 6.0.4 to every *-Tests project (NUnit packages
skipped for the one xunit project), replacing three different
Test.Sdk versions, two NUnit versions and three adapter versions
pinned per project. It also defaults RootNamespace to
MTConnect.Tests.<Area>.
- Normalize namespaces to MTConnect.Tests.<Area>[.<Folder>]:
MTConnect.NET_{Common,Docs,JSON,JSON_cppagent}_Tests,
MTConnect.AgentModule.<X>.Tests, MTConnect.Compliance.Tests and
MTConnect.Tests.Xml are renamed; SHDR-Tests no longer uses the
product namespace MTConnect.Shdr as its root. The Compliance XSD
embedded-resource prefix follows the new root namespace.
- SHDR-Tests/DataItems.cs: replace 27 `if (a == b) Assert.Pass(); else
Assert.Fail()` blocks with Assert.That(actual, Is.EqualTo(expected)),
fixing the swapped input/output naming so failure messages label the
expected and actual values correctly.
- CONTRIBUTING.md: document the conventions for projects, namespaces,
files, test names, assertions, async waits and network ports.
All 5,953 unit tests and 13 integration tests pass with the same counts
as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CppAgentParityWorkflowTests ran mtconnect/agent:latest, which now resolves to cppagent 2.8.0.4; the fixture's own version probe expects 2.7.x, so all three parity tests failed in OneTimeSetUp. Pin the image to the 2.7.0.7 digest the fixture comment already recorded, and update the two other places that named :latest. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every API page rendered the whole ~2,500-entry API sidebar, and every page inlined the full site config, so the build wrote 3.2 GB of HTML (~1.4 MB per API page) and needed an 8 GB Node heap. - sidebar.ts: one sidebar per namespace (parents, child namespaces, own types) keyed `/api/<Namespace>.`, plus an `/api/` index of all namespaces, instead of one sidebar holding every type. - config.ts: metaChunk so the site data is one shared chunk instead of ~0.4 MB inlined into every page. VitePress build locally: 267 s -> 117 s; HTML 3.28 GB -> 0.18 GB. Route check (MTConnect.NET-Docs-Tests, Category=E2E): - Walk every narrative page but only a sample of the docfx API pages (overview, each namespace page, one type per namespace): 390 of 2,445 routes, ~33 s. ROUTE_CHECK_ALL_API=true walks all of them. - Start `vitepress preview` with node directly. Through npx.cmd the server outlived its parents on Windows, Kill(entireProcessTree) missed it, and every run leaked a preview server. - The dist-rebuild check is inconclusive when the fixture reused an existing dist/ instead of failing every run that had one. - Note docfx as a local prerequisite. Also add the XML doc comments the durable-buffer tests were missing: the docs build compiles every project with GenerateDocumentationFile and warnings as errors, so CS1591 there broke `npm run build`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CI on a PR took 40–70 minutes, and the docs build plus its route check about 30. Almost all of that was overhead rather than tests: the unit tests themselves run in under a minute.
What changed
CI test time (
ci: cut test wall-clock…)JsonEvents.g.cs/JsonSamples.g.cs, ~5,000-line constructors) took ~9.5 minutes per run. They're excluded from coverage in both runsettings files; the full unit suite with coverage now runs in under a minute locally.LogFilePrefix) instead of overwriting one shared file, and a sharedtools/ci/check-trx.shguard fails the job on a missing, unreadable or empty result.concurrencycancels superseded PR runs; NuGet packages are cached.docs.yml: PR runs get their own concurrency group; the Pages group now applies only to the deploy job.Test conventions (
test: unify test project conventions)tests/Directory.Build.props: one version of Test.Sdk, NUnit, the NUnit adapter and coverlet for every test project (there were three Test.Sdk versions, two NUnit and three adapter versions), and a defaultRootNamespaceofMTConnect.Tests.<Area>.MTConnect.Tests.<Area>(SHDR-Tests no longer uses the product namespaceMTConnect.Shdr); the Compliance embedded-schema resource prefix follows.if … Assert.Pass(); else Assert.Fail();blocks are nowAssert.That(actual, Is.EqualTo(expected)), so failures show both values.CONTRIBUTING.mddocuments the conventions.Compliance (
test(compliance): pin the cppagent parity image…)mtconnect/agent:latest, which now resolves to 2.8.0.4 and fails the fixture's 2.7.x version check. Pinned to the 2.7.0.7 digest.Docs site (
docs: cut the site build and route check…)metaChunk). Local VitePress build: 267 s → 117 s; HTML 3.28 GB → 0.18 GB.ROUTE_CHECK_ALL_API=truewalks all of them.vitepress previewserver on Windows, and its rebuild check no longer fails whendist/already exists.npm run build.How to verify
./tools/test.sh, ordotnet test tests/MTConnect.NET-Docs-Tests --filter Category=E2Eafternpm run buildindocs/(needs docfx).Known failures not addressed here
These also fail on master and are left for a separate fix:
ShdrNetworkTests(Adapter_AnswersPing,QueueAdapter_SendsEveryQueuedValueInOrder_AndAssetsToo) are flaky: they can connect before the adapter's listener is bound.DeviceFilesTests.NewFile_IsCreatedFromTheTemplatefails on Linux becauseDeviceFiles.csmixes a case-insensitive lookup with a case-sensitiveFile.Exists.formatjob flagsAgentClientConnectionListener.csandDeviceDocumentTests.cs.🤖 Generated with Claude Code