Skip to content

feat(scripts): add structured JSON log output to Validate-Marketplace.ps1#1430

Merged
katriendg merged 4 commits intomicrosoft:mainfrom
MauroDruwel:feat/991-marketplace-json-output
Apr 29, 2026
Merged

feat(scripts): add structured JSON log output to Validate-Marketplace.ps1#1430
katriendg merged 4 commits intomicrosoft:mainfrom
MauroDruwel:feat/991-marketplace-json-output

Conversation

@MauroDruwel
Copy link
Copy Markdown
Contributor

@MauroDruwel MauroDruwel commented Apr 23, 2026

Pull Request

Description

Add structured JSON log output support to Validate-Marketplace.ps1 so marketplace validation results are persisted to logs/ in a machine-readable format, consistent with other linting scripts.

This update now also includes review-requested help documentation improvements:

  • script-level .EXAMPLE shows -OutputPath usage
  • Write-MarketplaceValidationReport now includes .OUTPUTS and .EXAMPLE

Related Issue(s)

Closes #991

Type of Change

Select all that apply:

Code & Documentation:

  • Bug fix (non-breaking change fixing an issue)
  • New feature (non-breaking change adding functionality)
  • Breaking change (fix or feature causing existing functionality to change)
  • Documentation update

Infrastructure & Configuration:

  • GitHub Actions workflow
  • Linting configuration (markdown, PowerShell, etc.)
  • Security configuration
  • DevContainer configuration
  • Dependency update

AI Artifacts:

  • Reviewed contribution with prompt-builder agent and addressed all feedback
  • Copilot instructions (.github/instructions/*.instructions.md)
  • Copilot prompt (.github/prompts/*.prompt.md)
  • Copilot agent (.github/agents/*.agent.md)
  • Copilot skill (.github/skills/*/SKILL.md)

Other:

  • Script/automation (.ps1, .sh, .py)
  • Other (please describe):

Testing

  • npm run lint:ps
  • npm run test:ps -- -TestPath "scripts/tests/plugins/"

Checklist

Required Checks

  • Documentation is updated (if applicable)
  • Files follow existing naming conventions
  • Changes are backwards compatible (if applicable)
  • Tests added for new functionality (if applicable)

AI Artifact Contributions

  • Used /prompt-analyze to review contribution
  • Addressed all feedback from prompt-builder review
  • Verified contribution follows common standards and type-specific requirements

Required Automated Checks

The following validation commands must pass before merging:

  • Markdown linting: npm run lint:md
  • Spell checking: npm run spell-check
  • Frontmatter validation: npm run lint:frontmatter
  • Skill structure validation: npm run validate:skills
  • Link validation: npm run lint:md-links
  • PowerShell analysis: npm run lint:ps
  • Plugin freshness: npm run plugin:generate
  • Docusaurus tests: npm run docs:test

Security Considerations

  • This PR does not contain any sensitive or NDA information
  • Any new dependencies have been reviewed for security issues
  • Security-related scripts follow the principle of least privilege

Additional Notes

JSON output is additive. Existing console output and failure behavior remain unchanged.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@MauroDruwel MauroDruwel marked this pull request as ready for review April 23, 2026 19:12
@MauroDruwel MauroDruwel requested a review from a team as a code owner April 23, 2026 19:12
Copy link
Copy Markdown
Contributor

@katriendg katriendg left a comment

Choose a reason for hiding this comment

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

Thanks for this contribution, @MauroDruwel! The implementation is looking good.

Before merge, please update the PR description to follow the PR template. You can generate one automatically by checking out your branch locally and running the /pull-request slash command in Copilot Chat, agent mode:

/pull-request issue https://github.com/microsoft/hve-core/issues/991

This will generate the correctly formatted description with the Type of Change checklist, Testing section, Required Automated Checks, and Security Considerations sections.
Then copy the output of the pr.md file into this PR manually, since the PR already exists.

Additional note: also update your other PRs with this approach?

Optional improvements:

  1. Update the script-level .EXAMPLE in the comment-based help to show the new -OutputPath parameter usage.
  2. Add .OUTPUTS and .EXAMPLE to the Write-MarketplaceValidationReport function's comment-based help, consistent with the other helper functions in the file.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@MauroDruwel
Copy link
Copy Markdown
Contributor Author

Thanks @katriendg — updated.

I applied the requested changes:

  1. PR description now follows .github/PULL_REQUEST_TEMPLATE.md sections and checklists.
  2. Script-level .EXAMPLE now shows -OutputPath usage.
  3. Added .OUTPUTS and .EXAMPLE to Write-MarketplaceValidationReport comment-based help.

Latest commit: 97491a3.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 24, 2026

Codecov Report

❌ Patch coverage is 98.30508% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 87.43%. Comparing base (d51b4d3) to head (ac1b3c6).

Files with missing lines Patch % Lines
scripts/plugins/Validate-Marketplace.ps1 98.30% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1430      +/-   ##
==========================================
- Coverage   87.64%   87.43%   -0.22%     
==========================================
  Files          65       64       -1     
  Lines       10152     9930     -222     
==========================================
- Hits         8898     8682     -216     
+ Misses       1254     1248       -6     
Flag Coverage Δ
pester 85.12% <98.30%> (+0.08%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
scripts/plugins/Validate-Marketplace.ps1 92.59% <98.30%> (+3.82%) ⬆️

... and 3 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Contributor

@katriendg katriendg left a comment

Choose a reason for hiding this comment

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

Thank you Mauro for the fast update, LGTM!

@katriendg katriendg merged commit ec2aa53 into microsoft:main Apr 29, 2026
58 checks passed
katriendg pushed a commit that referenced this pull request May 3, 2026
….ps1

`Validate-Collections.ps1` was the only collections-facing linting
script that did not write structured results to `logs/`. All other
pipeline scripts persist JSON reports after each run; this gap meant
collection validation results were lost at terminal close, blocking any
tooling or CI step that reads from `logs/`.

Changes made:
- Added `-OutputPath` parameter to `Validate-Collections.ps1` (default:
`logs/collection-validation-results.json`).
- Refactored `$fileErrors` from plain strings to typed hashtables
(`ErrorType` + `Message`), enabling specific error codes in JSON output:
`MissingRequiredField`, `InvalidIdFormat`, `DuplicateCollectionId`,
`InvalidCollectionMaturity`, `RepoSpecificPath`, `PathNotFound`,
`MissingSuffix`, `MissingItemKind`, `InvalidMaturity`,
`IntraCollectionDuplicate`.
- Introduced inner helper `Add-ValidationResult` that accumulates a
typed results list alongside every existing `Write-Host` call (console
output unchanged).
- Added `Export-CollectionValidationReport` function for path
resolution, directory creation, and JSON serialization.
- Moved `Create logs directory` step in `plugin-validation.yml` to
before `Validate collection metadata` to make workflow intent explicit.
- Expanded Pester test coverage: updated `ErrorType` assertion to
specific type, added severity differentiation, directory creation,
multiple distinct `ErrorType` values in one run, and clean-run `Results`
key presence tests.

Output schema:
```json
{
  "Timestamp": "2026-04-23T17:00:00.000Z",
  "TotalCollections": 14,
  "ErrorCount": 0,
  "Results": [
    {
      "Collection": "hve-core",
      "Severity": "Warning",
      "ErrorType": "MissingCompanionCollectionMd",
      "Message": "missing companion 'hve-core.collection.md'"
    }
  ]
}
```

## Related Issue(s)

Closes #992.

## Type of Change

Select all that apply:

**Code & Documentation:**

* [ ] Bug fix (non-breaking change fixing an issue)
* [x] New feature (non-breaking change adding functionality)
* [ ] Breaking change (fix or feature causing existing functionality to
change)
* [ ] Documentation update

**Infrastructure & Configuration:**

* [x] GitHub Actions workflow
* [ ] Linting configuration (markdown, PowerShell, etc.)
* [ ] Security configuration
* [ ] DevContainer configuration
* [ ] Dependency update

**AI Artifacts:**

* [ ] Reviewed contribution with `prompt-builder` agent and addressed
all feedback
* [ ] Copilot instructions (`.github/instructions/*.instructions.md`)
* [ ] Copilot prompt (`.github/prompts/*.prompt.md`)
* [ ] Copilot agent (`.github/agents/*.agent.md`)
* [ ] Copilot skill (`.github/skills/*/SKILL.md`)

**Other:**

* [x] Script/automation (`.ps1`, `.sh`, `.py`)
* [ ] Other (please describe):

## Testing

| Command | Result |
|---|---|
| `npm run lint:collections-metadata` | ✅ pass, writes
`logs/collection-validation-results.json` |
| `npm run lint:ps` | ✅ pass |
| `npm run test:ps -- -TestPath scripts/tests/collections/` | ✅ pass, 6
tests (2 pre-existing + 4 new), no regressions |

Baseline runs confirmed pre-existing test suite intact; post-change runs
confirmed new tests pass and JSON file is created with correct schema.

## Checklist

### Required Checks

* [x] Documentation is updated (if applicable)
* [x] Files follow existing naming conventions
* [x] Changes are backwards compatible (if applicable)
* [x] Tests added for new functionality (if applicable)

### AI Artifact Contributions
* [ ] Used `/prompt-analyze` to review contribution
* [ ] Addressed all feedback from `prompt-builder` review
* [ ] Verified contribution follows common standards and type-specific
requirements

### Required Automated Checks

The following validation commands must pass before merging:

* [ ] Markdown linting: `npm run lint:md`
* [ ] Spell checking: `npm run spell-check`
* [ ] Frontmatter validation: `npm run lint:frontmatter`
* [ ] Skill structure validation: `npm run validate:skills`
* [ ] Link validation: `npm run lint:md-links`
* [ ] PowerShell analysis: `npm run lint:ps`
* [ ] Plugin freshness: `npm run plugin:generate`
* [ ] Docusaurus tests: `npm run docs:test`

## Security Considerations

* [x] This PR does not contain any sensitive or NDA information
* [x] Any new dependencies have been reviewed for security issues
* [x] Security-related scripts follow the principle of least privilege

## Additional Notes

This PR was rebased on top of the main branch which includes #1430
(structured JSON output for `Validate-Marketplace.ps1`). The merge
conflict in `package.json` was resolved by combining both `-OutputPath`
flags: `lint:collections-metadata` and `lint:marketplace` both now pass
their respective output paths.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

Add JSON log output to Validate-Marketplace.ps1

5 participants