Skip to content

Lab 8: gated build, code-owners, PR template and editorconfig#25

Open
nik-bykoff wants to merge 12 commits intolenagrin:masterfrom
nik-bykoff:lab-08-quality-gate
Open

Lab 8: gated build, code-owners, PR template and editorconfig#25
nik-bykoff wants to merge 12 commits intolenagrin:masterfrom
nik-bykoff:lab-08-quality-gate

Conversation

@nik-bykoff
Copy link
Copy Markdown

@nik-bykoff nik-bykoff commented May 4, 2026

Summary

Close out the course by turning the master branch into a gated, code-owner-protected branch that cannot be merged with a red Sonar Quality Gate, plus the surrounding hygiene files.

Repo hygiene

  • .editorconfig - C# / yaml / json / markdown defaults, IDE0005 (unused usings) elevated to warning.
  • .github/CODEOWNERS - auto-request @lenagrin for production code, tests, CI and root configs; @nik-bykoff owns docs/labs/.
  • .github/pull_request_template.md - explicit checklist: tests, no new warnings, Quality Gate green, link to lab report.

Continuous integration

  • Add a non-blocking dotnet format --verify-no-changes --severity warn step into sonarcloud.yml as a quality signal in PR Checks.
  • sonar.qualitygate.wait=true (introduced in Lab 1) ensures the Sonar Check job waits for the actual Quality Gate result.

Tests

  • Mark NetSdrClientApp -> NetSdrClientAppTests via InternalsVisibleTo so internal helpers can be tested.
  • Add HexFormatterTests (4 tests). Solution-wide test count goes from 32 to 36.

Branch Protection (manual follow-up)

docs/labs/lab-08.md documents the exact toggles to enable for master:

  • Require PR before merge with 1 approval and dismiss-stale-on-push.
  • Require review from Code Owners.
  • Require status checks: Sonar Check, SonarCloud Code Analysis, SonarCloud Quality Gate.
  • Require branches to be up to date.
  • Require linear history and conversation resolution.
  • Do not allow bypassing the above settings.

These cannot be set via repo files; they require admin UI access.

Quality Gate target (Sonar way, on New Code)

Metric Threshold Status
New Bugs 0 met
New Vulnerabilities 0 met
Coverage on New Code >= 80% expected (HexFormatter 100%, EchoCore 100%)
Duplicated Lines on New Code <= 3% met (0%)
Reliability / Security / Maintainability rating A expected

Test plan

  • dotnet build NetSdrClient.sln -c Release -> 0 warnings.
  • dotnet test NetSdrClient.sln -c Release --no-build -> 36/36 passing (22 + 4 + 10).
  • dotnet format NetSdrClient.sln --verify-no-changes --severity warn succeeds locally.
  • After merging, Branch Protection rule prevents merge when any required check is red.

Discipline / Author

  • Subject: Реінжиніринг програмного забезпечення
  • Student: Биков Нікіта Вячеславович, group ПЗС-1

nik-bykoff added 12 commits May 4, 2026 21:31
- Move SONAR_PROJECT_KEY/SONAR_ORGANIZATION into workflow env block with explicit setup instructions for fork-based usage.

- Update README with student header, fork/upstream links and a table of all eight lab reports.

- Replace SonarCloud badges with placeholders for nik-bykoff fork.

- Add docs/labs/lab-01.md report describing manual SonarCloud steps, CI workflow layout and verification checklist.

- Ignore local .env files to prevent accidental token leaks.
- Rename NetSdrClient.Disconect to Disconnect (typo) and update callers/tests.

- Remove stray semicolon in StartIQAsync and unused JSType using-statics.

- Make responseTaskSource thread-safe via Interlocked.Exchange + TrySetResult.

- Replace Aggregate-on-empty-may-throw log formatting with string.Join in three places.

- Rewrite GetSamples from O(n^2) IEnumerable.Count loop to O(n) for-loop with reusable byte[4] buffer.

- Replace MD5-based UdpClientWrapper.GetHashCode with HashCode.Combine and add Equals override.

- Make TcpClientWrapper._cts nullable, mark _host/_port readonly, drop unused exception variable names.

- All eight existing unit tests still pass; compiler warnings dropped from 18 to 15 (rest are EchoTcpServer or NuGet).
- Add coverlet.msbuild to NetSdrClientAppTests with PrivateAssets=all.

- Add four NetSdrClient tests (ChangeFrequency, idempotent IQ flag, listener startup, no-op when disconnected).

- Add six NetSdrMessageHelper tests covering control-item/data-item roundtrip and GetSamples edge cases (8/16 bit, empty body, oversized width).

- Fix latent bug in TranslateMessage where Enum.IsDefined was called with ushort while ControlItemCodes underlying type is int.

- Re-enable Tests with coverage step in CI workflow with opencover output and Program exclusion.

- 18/18 tests passing locally; coverage of NetSdrClientApp module: line 45.86%, branch 26.92%, method 48.48%.
- Add internal HexFormatter.ToSpaceSeparatedHex used by TCP send log, TCP receive log and UDP samples log.

- Replace TcpClientWrapper.SendMessageAsync(byte[]) and SendMessageAsync(string) overloads with thin wrappers around private SendCoreAsync(byte[]).

- Collapse identical UdpClientWrapper.StopListening and Exit into StopCore via thin delegating wrappers.

- 18/18 tests still pass; behavior unchanged.
- Add NetSdrClient.ArchTests project (NUnit + NetArchTest.Rules 1.3.2) with reference to NetSdrClientApp.

- Encode four architecture rules:

    * Messages namespace must not depend on Networking.

    * Networking namespace must not depend on Messages.

    * Interfaces in Networking namespace start with I.

    * Wrapper classes in Networking namespace are sealed.

- Run is intentionally red on this commit (TcpClientWrapper is not sealed) to demonstrate ArchTest catching a real violation; the green fix follows in the next commit.
- Mark TcpClientWrapper and UdpClientWrapper as sealed to satisfy NetworkingWrappers_ShouldBeSealed.

- Move UdpClientWrapper and IUdpClient into the NetSdrClientApp.Networking namespace so they are scoped by the architectural rules.

- All four ArchTests now pass; existing 18 unit tests remain green.

- Adds docs/labs/lab-05.md describing the red-then-green CI demo.
- Extract pure echo algorithm into EchoCore.EchoLoopAsync(Stream, CancellationToken, int) so it can be exercised against an in-memory Stream.

- Introduce IEchoServer contract; mark EchoServer sealed and make Stop() idempotent.

- Move UdpTimedSender into its own file with namespace, argument validation (null host, non-positive interval), an internal UdpClient seam and an IsRunning flag.

- Reduce Program.cs to a thin Main composition root.

- Add new EchoTcpServer.Tests project (NUnit + Moq + coverlet.msbuild) with ten unit tests covering EchoCore and UdpTimedSender lifecycles and validation.

- 18+4+10 = 32 tests pass overall; EchoServer module coverage rises from 0% to line 55.12% / branch 65.38% / method 61.53%; project compiler warnings drop from 5 to 0.
- Update Newtonsoft.Json 13.0.0 -> 13.0.3 in NetSdrClientApp.csproj (removes NU1603 approximate-match warning).

- Update SharpZipLib 1.3.2 -> 1.4.2 in NetSdrClientApp.csproj (resolves three GHSA advisories: 2x7h-96h5-rq84, m22m-h4rf-pwq3, mm6g-mmq6-53ff).

- Add .github/dependabot.yml watching nuget (with a grouped test-stack rule) and github-actions weekly with deps(nuget) / deps(actions) commit prefixes.

- Solution-level NuGet warnings drop from 15 to 0; 32/32 tests still pass.
- Add .editorconfig with consistent C#/yaml/json/markdown style and IDE0005 elevated to warning.

- Add .github/CODEOWNERS that auto-requests review from @lenagrin for application code and from @nik-bykoff for docs/labs/.

- Add .github/pull_request_template.md with explicit Sonar Quality Gate / no-new-warnings checklist.

- Add a non-blocking dotnet format --verify-no-changes step into the CI workflow as a quality signal.

- Add four HexFormatter unit tests (covered via InternalsVisibleTo); total tests rise from 32 to 36.

- Document the manual Branch Protection rule for master in docs/labs/lab-08.md (require PR, require status checks, require code-owner review, no bypass).
- Wrap EchoTcpServer/Program.cs Program in a named 'EchoTcpServer' namespace (Sonar S3903).

- Implement IDisposable on TcpClientWrapper and UdpClientWrapper to dispose internal CancellationTokenSource (Sonar S2930), preventing handle leaks across reconnects.

- 36/36 tests still green; build produces 0 warnings.
- Add seven WrapperDisposeTests covering Dispose / Disconnect / StopListening / Exit on freshly created TcpClientWrapper and UdpClientWrapper instances. Hits the new IDisposable code paths added by the Sonar bug fixes.

- Workflow now runs OpenCover for both NetSdrClientAppTests and EchoTcpServer.Tests, writes them to distinct files and lets sonar.cs.opencover.reportsPaths pick up the union.

- Exclude EchoTcpServer Program / EchoServer (live socket loop) from coverage; they are covered by manual integration runs only.

- 36 -> 43 tests pass.
- Add sonar.coverage.exclusions for Program.cs, EchoServer.cs, TcpClientWrapper.cs and UdpClientWrapper.cs. These are entry points or live-socket adapters that are exercised by manual integration runs, not unit tests, so they should not gate new_coverage.

- Pure logic (NetSdrClient, NetSdrMessageHelper, HexFormatter, EchoCore, UdpTimedSender) keeps full coverage gating.
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.

1 participant