Skip to content

Commit 4aa6fbe

Browse files
Apply TemplateDotNetTool template consistency updates to SonarMark (#98)
* Initial plan * Fix code/config drift from TemplateDotNetTool template - Program.cs: route errors to Console.Error.WriteLine (stderr) - Program.cs: version display uses context.WriteLine (respects --silent) - Context.cs: add AutoFlush=true on log StreamWriter - Context.cs: WriteError uses Console.Error.WriteLine (stderr) - Tests: update to capture Console.Error for error assertions - Tests.csproj: LangVersion 12 → latest - SonarMark.csproj: reorganize packages into labeled ItemGroups - build.yaml: add dotnet tool restore step to CodeQL job - build.yaml: add sonarmark to versionmark capture list - pull_request_template.md: add self-validation checklist item Co-authored-by: Malcolmnixon <[email protected]> * Update agent documentation for template consistency - AGENTS.md: C# 12 → C# (latest), .markdownlint.json → .markdownlint-cli2.jsonc - code-quality-agent.md: .markdownlint.json → .markdownlint-cli2.jsonc - repo-consistency-agent.md: fix markdownlint filename, add Tracking Template Evolution section - requirements-agent.md: add Test Source Filters section Co-authored-by: Malcolmnixon <[email protected]> * Fix Validation.cs: use test names in console output, title-case Passed/Failed - Output now shows test names (SonarMark_QualityGateRetrieval) instead of descriptions - Status now uses title case (Passed/Failed) consistent with template PR #51 - Removed unused 'displayName' parameter from RunValidationTest Co-authored-by: Malcolmnixon <[email protected]> * Apply remaining template updates: semantic IDs, self-validation docs - requirements.yaml: semantic IDs (CLI-001 → Sonar-Cmd-Cli, PLT-001 → Sonar-Platform-Windows, etc.) - README.md: replace Self-Validation Tests table with Self Validation section showing actual output format - docs/guide/guide.md: restructure self-validation section with Validation Report example (template PR #51) - .markdownlint-cli2.jsonc: allow siblings_only duplicate headings for Self-Validation Co-authored-by: Malcolmnixon <[email protected]> * requirements.yaml: rename IDs to SonarMark- prefix with Svr/Rpt/Plt abbreviations Co-authored-by: Malcolmnixon <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: Malcolmnixon <[email protected]>
1 parent 25c8ce9 commit 4aa6fbe

File tree

17 files changed

+190
-130
lines changed

17 files changed

+190
-130
lines changed

.github/agents/code-quality-agent.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Ensure the project is:
3131

3232
1. **Build**: Zero warnings (TreatWarningsAsErrors=true)
3333
2. **Linting**:
34-
- markdownlint (`.markdownlint.json`)
34+
- markdownlint (`.markdownlint-cli2.jsonc`)
3535
- cspell (`.cspell.json`)
3636
- yamllint (`.yamllint.yaml`)
3737
- dotnet format (`.editorconfig`)

.github/agents/repo-consistency-agent.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ The agent reviews the following areas for consistency with the template:
5656

5757
#### Quality Configuration
5858

59-
- **Linting Rules**: `.cspell.json`, `.markdownlint.json`, `.yamllint.yaml`
59+
- **Linting Rules**: `.cspell.json`, `.markdownlint-cli2.jsonc`, `.yamllint.yaml`
6060
- Note: Spelling exceptions will be repository-specific
6161
- **Editor Config**: `.editorconfig` settings (file-scoped namespaces, 4-space indent, UTF-8+BOM, LF endings)
6262
- **Code Style**: C# code style rules and analyzer configuration
@@ -88,6 +88,34 @@ The agent reviews the following areas for consistency with the template:
8888
3. **Recommend Updates**: Suggest specific files or patterns that should be updated
8989
4. **Respect Customizations**: Recognize valid project-specific customizations
9090

91+
### Tracking Template Evolution
92+
93+
To ensure downstream projects benefit from recent template improvements, review recent pull requests
94+
merged into the template repository:
95+
96+
1. **List Recent PRs**: Retrieve recently merged PRs from `demaconsulting/TemplateDotNetTool`
97+
- Review the last 10-20 PRs to identify template improvements
98+
99+
2. **Identify Propagatable Changes**: For each PR, determine if changes should apply to downstream
100+
projects:
101+
- Focus on structural changes (workflows, agents, configurations) over content-specific changes
102+
- Note changes to `.github/`, linting configurations, project patterns, and documentation
103+
structure
104+
105+
3. **Check Downstream Application**: Verify if identified changes exist in the downstream project:
106+
- Check if similar files/patterns exist in downstream
107+
- Compare file contents between template and downstream project
108+
- Look for similar PR titles or commit messages in downstream repository history
109+
110+
4. **Recommend Missing Updates**: For changes not yet applied, include them in the consistency
111+
review with:
112+
- Description of the template change (reference PR number)
113+
- Explanation of benefits for the downstream project
114+
- Specific files or patterns that need updating
115+
116+
This technique ensures downstream projects don't miss important template improvements and helps
117+
maintain long-term consistency.
118+
91119
### What NOT to Flag
92120

93121
- Project-specific naming (tool names, package IDs, repository URLs)

.github/agents/requirements-agent.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,23 @@ Follow the `requirements.yaml` structure:
4949
- Linked to appropriate test(s)
5050
- Enforced via: `dotnet reqstream --requirements requirements.yaml --tests "test-results/**/*.trx" --enforce`
5151

52+
### Test Source Filters
53+
54+
Test links in `requirements.yaml` can include a source filter prefix to restrict which test results count as
55+
evidence. This is critical for platform and framework requirements - **never remove these filters**.
56+
57+
- `windows@TestName` - proves the test passed on a Windows platform
58+
- `ubuntu@TestName` - proves the test passed on a Linux (Ubuntu) platform
59+
- `net8.0@TestName` - proves the test passed under the .NET 8 target framework
60+
- `net9.0@TestName` - proves the test passed under the .NET 9 target framework
61+
- `net10.0@TestName` - proves the test passed under the .NET 10 target framework
62+
- `dotnet8.x@TestName` - proves the self-validation test ran on a machine with .NET 8.x runtime
63+
- `dotnet9.x@TestName` - proves the self-validation test ran on a machine with .NET 9.x runtime
64+
- `dotnet10.x@TestName` - proves the self-validation test ran on a machine with .NET 10.x runtime
65+
66+
Without the source filter, a test result from any platform/framework satisfies the requirement. Removing a
67+
filter invalidates the evidence for platform/framework requirements.
68+
5269
## Defer To
5370

5471
- **Software Developer Agent**: For implementing self-validation tests

.github/pull_request_template.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ Before submitting this pull request, ensure you have completed the following:
2828

2929
- [ ] Code builds successfully: `dotnet build --configuration Release`
3030
- [ ] All tests pass: `dotnet test --configuration Release`
31+
- [ ] Self-validation tests pass:
32+
`dotnet run --project src/DemaConsulting.SonarMark --configuration Release --framework net10.0`
33+
`--no-build -- --validate`
3134
- [ ] Code produces zero warnings
3235

3336
### Code Quality

.github/workflows/build.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,10 @@ jobs:
201201
9.x
202202
10.x
203203
204+
- name: Restore Tools
205+
run: >
206+
dotnet tool restore
207+
204208
- name: Restore Dependencies
205209
run: >
206210
dotnet restore
@@ -419,7 +423,7 @@ jobs:
419423
run: |
420424
echo "Capturing tool versions..."
421425
dotnet versionmark --capture --job-id "build-docs" -- \
422-
dotnet git node npm pandoc weasyprint sarifmark reqstream buildmark versionmark
426+
dotnet git node npm pandoc weasyprint sarifmark sonarmark reqstream buildmark versionmark
423427
echo "✓ Tool versions captured"
424428
425429
# === GENERATE MARKDOWN REPORTS ===

.markdownlint-cli2.jsonc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"MD003": { "style": "atx" },
55
"MD007": { "indent": 2 },
66
"MD013": { "line_length": 120 },
7+
"MD024": { "siblings_only": true },
78
"MD025": false,
89
"MD033": false,
910
"MD041": false

AGENTS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ SonarQube/SonarCloud analysis results.
1414

1515
## Tech Stack
1616

17-
- C# 12, .NET 8.0/9.0/10.0, MSTest, dotnet CLI, NuGet
17+
- C# (latest), .NET 8.0/9.0/10.0, MSTest, dotnet CLI, NuGet
1818

1919
## Key Files
2020

2121
- **`requirements.yaml`** - All requirements with test linkage (enforced via `dotnet reqstream --enforce`)
2222
- **`.editorconfig`** - Code style (file-scoped namespaces, 4-space indent, UTF-8+BOM, LF endings)
23-
- **`.cspell.json`, `.markdownlint.json`, `.yamllint.yaml`** - Linting configs
23+
- **`.cspell.json`, `.markdownlint-cli2.jsonc`, `.yamllint.yaml`** - Linting configs
2424
- **`.vscode/tasks.json`** - VS Code tasks for build, test, lint, and quality checks
2525

2626
## Requirements (SonarMark-Specific)

README.md

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -137,29 +137,41 @@ sonarmark --validate
137137
sonarmark --validate --results validation-results.trx
138138
```
139139

140-
### Self-Validation Tests
140+
## Self Validation
141141

142-
SonarMark includes built-in self-validation tests that verify the tool's functionality without requiring
143-
a live SonarQube/SonarCloud server. These tests use mock data to validate core features and generate test
144-
result files in TRX or JUnit format.
142+
Running self-validation produces a report containing the following information:
145143

146-
The self-validation suite includes the following tests:
144+
```text
145+
# DEMA Consulting SonarMark
146+
147+
| Information | Value |
148+
| :------------------ | :------------------------------------------------- |
149+
| SonarMark Version | <version> |
150+
| Machine Name | <machine-name> |
151+
| OS Version | <os-version> |
152+
| DotNet Runtime | <dotnet-runtime-version> |
153+
| Time Stamp | <timestamp> UTC |
154+
155+
✓ SonarMark_QualityGateRetrieval - Passed
156+
✓ SonarMark_IssuesRetrieval - Passed
157+
✓ SonarMark_HotSpotsRetrieval - Passed
158+
✓ SonarMark_MarkdownReportGeneration - Passed
159+
160+
Total Tests: 4
161+
Passed: 4
162+
Failed: 0
163+
```
147164

148-
| Test Name | Description |
149-
| :-------- | :---------- |
150-
| `SonarMark_QualityGateRetrieval` | Verifies fetching and processing quality gate status |
151-
| `SonarMark_IssuesRetrieval` | Verifies fetching and processing code issues |
152-
| `SonarMark_HotSpotsRetrieval` | Verifies fetching and processing security hot-spots |
153-
| `SonarMark_MarkdownReportGeneration` | Verifies generating markdown reports with quality metrics |
165+
Each test in the report proves:
154166

155-
These tests provide evidence of the tool's functionality and are particularly useful for:
167+
- **`SonarMark_QualityGateRetrieval`** - Verifies fetching and processing quality gate status from SonarQube/SonarCloud.
168+
- **`SonarMark_IssuesRetrieval`** - Verifies fetching and processing code issues with severity classification.
169+
- **`SonarMark_HotSpotsRetrieval`** - Verifies fetching and processing security hot-spots and vulnerabilities.
170+
- **`SonarMark_MarkdownReportGeneration`** - Verifies generating markdown reports with quality metrics and findings.
156171

157-
- Verifying the installation is working correctly
158-
- Running automated tests in CI/CD pipelines without requiring SonarQube access
159-
- Generating test evidence for compliance and traceability requirements
172+
See the [User Guide][link-guide] for more details on the self-validation tests.
160173

161-
For detailed usage instructions, command-line options, and examples, including tool update instructions, see the
162-
[Usage Guide](https://github.com/demaconsulting/SonarMark/blob/main/docs/guide/guide.md).
174+
On validation failure the tool will exit with a non-zero exit code.
163175

164176
## Report Format
165177

@@ -251,6 +263,7 @@ SonarMark is built with the following open-source projects:
251263

252264
<!-- Link References -->
253265
[link-forks]: https://github.com/demaconsulting/SonarMark/network/members
266+
[link-guide]: https://github.com/demaconsulting/SonarMark/blob/main/docs/guide/guide.md
254267
[link-stars]: https://github.com/demaconsulting/SonarMark/stargazers
255268
[link-contributors]: https://github.com/demaconsulting/SonarMark/graphs/contributors
256269
[link-license]: https://github.com/demaconsulting/SonarMark/blob/main/LICENSE

docs/guide/guide.md

Lines changed: 33 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -437,70 +437,64 @@ If no security hot-spots are found:
437437
Found no security hot-spots
438438
```
439439

440-
# Running Self-Validation
440+
# Self-Validation
441441

442-
SonarMark includes built-in self-validation tests to verify functionality without requiring access to a real
443-
SonarQube/SonarCloud server. The validation uses mock data to test core features.
442+
Self-validation produces a report demonstrating that SonarMark is functioning
443+
correctly. This is useful in regulated industries where tool validation evidence is required.
444444

445445
## Running Validation
446446

447+
To perform self-validation:
448+
447449
```bash
448450
sonarmark --validate
449451
```
450452

451-
## Validation Tests
452-
453-
The self-validation suite includes the following tests that verify core functionality:
454-
455-
| Test Name | Description |
456-
| :-------- | :---------- |
457-
| `SonarMark_QualityGateRetrieval` | Verifies fetching and processing quality gate status from SonarQube/SonarCloud |
458-
| `SonarMark_IssuesRetrieval` | Verifies fetching and processing code issues with severity classification |
459-
| `SonarMark_HotSpotsRetrieval` | Verifies fetching and processing security hot-spots and vulnerabilities |
460-
| `SonarMark_MarkdownReportGeneration` | Verifies generating markdown reports with quality metrics and findings |
453+
To save validation results to a file:
461454

462-
These tests provide evidence of the tool's functionality and are particularly useful for:
455+
```bash
456+
sonarmark --validate --results results.trx
457+
```
463458

464-
- Verifying the installation is working correctly on different platforms and .NET versions
465-
- Running automated tests in CI/CD pipelines without requiring SonarQube access
466-
- Generating test evidence for compliance and traceability requirements
467-
- Validating tool functionality before deployment
459+
The results file format is determined by the file extension: `.trx` for TRX (MSTest) format,
460+
or `.xml` for JUnit format.
468461

469-
**Note**: The test names with the `SonarMark_` prefix are designed for clear identification in test
470-
result files (TRX/JUnit) when integrating with larger projects or test frameworks.
462+
## Validation Report
471463

472-
## Validation Output
464+
The validation report contains the tool version, machine name, operating system version,
465+
.NET runtime version, timestamp, and test results.
473466

474-
Example output:
467+
Example validation report:
475468

476469
```text
477-
SonarMark version 1.0.0
478-
Copyright (c) DEMA Consulting
479-
480470
# DEMA Consulting SonarMark
481-
## Self-Validation Tests
482471
483-
[PASS] Quality Gate Status Retrieval
484-
[PASS] Issues Retrieval
485-
[PASS] Hot-Spots Retrieval
486-
[PASS] Markdown Report Generation
472+
| Information | Value |
473+
| :------------------ | :------------------------------------------------- |
474+
| SonarMark Version | 1.0.0 |
475+
| Machine Name | BUILD-SERVER |
476+
| OS Version | Ubuntu 22.04.3 LTS |
477+
| DotNet Runtime | .NET 10.0.0 |
478+
| Time Stamp | 2024-01-15 10:30:00 UTC |
479+
480+
✓ SonarMark_QualityGateRetrieval - Passed
481+
✓ SonarMark_IssuesRetrieval - Passed
482+
✓ SonarMark_HotSpotsRetrieval - Passed
483+
✓ SonarMark_MarkdownReportGeneration - Passed
487484
488485
Total Tests: 4
489486
Passed: 4
490487
Failed: 0
491488
```
492489

493-
## Saving Validation Results
490+
## Validation Tests
494491

495-
Save results in TRX or JUnit XML format for integration with test reporting tools:
492+
Each test proves specific functionality works correctly:
496493

497-
```bash
498-
# TRX format (for Azure DevOps, Visual Studio)
499-
sonarmark --validate --results validation-results.trx
500-
501-
# JUnit XML format (for Jenkins, GitLab CI)
502-
sonarmark --validate --results validation-results.xml
503-
```
494+
- **`SonarMark_QualityGateRetrieval`** - Verifies fetching and processing quality gate status from SonarQube/SonarCloud.
495+
- **`SonarMark_IssuesRetrieval`** - Verifies fetching and processing code issues with severity classification.
496+
- **`SonarMark_HotSpotsRetrieval`** - Verifies fetching and processing security hot-spots and vulnerabilities.
497+
- **`SonarMark_MarkdownReportGeneration`** - Verifies generating markdown reports with quality metrics and findings.
504498

505499
# Best Practices
506500

0 commit comments

Comments
 (0)