Skip to content

refactor(scripts): align linting and tests with CIHelpers#401

Merged
WilliamBerryiii merged 6 commits intomainfrom
refactor/351-linting-cihelpers
Feb 4, 2026
Merged

refactor(scripts): align linting and tests with CIHelpers#401
WilliamBerryiii merged 6 commits intomainfrom
refactor/351-linting-cihelpers

Conversation

@WilliamBerryiii
Copy link
Member

Description

Refactored CI helper usage in linting and security scripts, expanded CI helper APIs, and aligned tests and documentation with the new behavior.

  • Extended CI helpers with environment flag and annotation helpers, plus coverage for new APIs.
  • Reworked linting scripts to rely on CI helper outputs and annotations, including the link language check core flow.
  • Hardened security and utility scripts with CI helper usage, response parsing improvements, and updated error handling.
  • Updated linting and security tests and mocks to use CI helper APIs and removed GitHub helper-specific coverage.
  • Updated GitHub documentation and removed the copilot setup workflow.

Related Issue(s)

Related to #351

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)

Note for AI Artifact Contributors:

  • Agents: Research, indexing/referencing other project (using standard VS Code GitHub Copilot/MCP tools), planning, and general implementation agents likely already exist. Review .github/agents/ before creating new ones.
  • Model Versions: Only contributions targeting the latest Anthropic and OpenAI models will be accepted. Older model versions (e.g., GPT-3.5, Claude 3) will be rejected.
  • See Agents Not Accepted and Model Version Requirements.

Other:

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

Testing

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)

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
  • Link validation: npm run lint:md-links
  • PowerShell analysis: npm run lint:ps

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

@WilliamBerryiii WilliamBerryiii requested a review from a team as a code owner February 3, 2026 19:38
Copilot AI review requested due to automatic review settings February 3, 2026 19:38
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Refactors linting and security PowerShell scripts to standardize CI integration via the shared CIHelpers module, and updates tests/mocks/docs to match the new CI helper APIs and behaviors.

Changes:

  • Expanded CIHelpers.psm1 with new helpers (notably CI env-var support and bulk annotation emission) and added/updated Pester coverage.
  • Updated linting and security scripts to use CI helper outputs/annotations and introduced skip-main patterns to make scripts more testable.
  • Updated Pester tests and mocks to use CI-focused environment helpers instead of GitHub-specific helpers, and refreshed linting documentation.

Reviewed changes

Copilot reviewed 24 out of 24 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
scripts/tests/security/Update-ActionSHAPinning.Tests.ps1 Switches tests to dot-source the script with HVE_SKIP_MAIN and uses CI environment mocks.
scripts/tests/security/Test-SHAStaleness.Tests.ps1 Switches tests to dot-source the script with HVE_SKIP_MAIN and uses CI environment mocks.
scripts/tests/linting/Validate-MarkdownFrontmatter.Tests.ps1 Updates tests to CI naming and validates CI annotation integration paths.
scripts/tests/linting/Markdown-Link-Check.Tests.ps1 Updates tests to dot-source with HVE_SKIP_MAIN for function access without executing main.
scripts/tests/linting/LintingHelpers.Tests.ps1 Removes GitHub-helper-focused coverage and narrows tests to core linting helper behaviors.
scripts/tests/linting/Link-Lang-Check.Tests.ps1 Updates tests to dot-source with HVE_SKIP_MAIN for function access without executing main.
scripts/tests/linting/Invoke-YamlLint.Tests.ps1 Updates mocks/assertions from GitHub helpers to CI helpers (Set-CIOutput, Write-CIAnnotation, etc.).
scripts/tests/linting/Invoke-PSScriptAnalyzer.Tests.ps1 Updates mocks/assertions from GitHub helpers to CI helpers and CI integration naming.
scripts/tests/linting/Invoke-LinkLanguageCheck.Tests.ps1 Adds unit coverage for the new core flow and updates CI helper export expectations.
scripts/tests/linting/FrontmatterValidation.Tests.ps1 Updates tests to validate Write-CIAnnotations behavior.
scripts/tests/lib/CIHelpers.Tests.ps1 Adds/updates coverage for new CI helper APIs (including env var helper and bulk annotation helper).
scripts/tests/Mocks/GitMocks.psm1 Renames and generalizes mock helpers from GitHub-specific to CI-oriented environment helpers.
scripts/security/Update-ActionSHAPinning.ps1 Improves response parsing/error handling and adds HVE_SKIP_MAIN to prevent executing main during tests.
scripts/security/Test-SHAStaleness.ps1 Adds HVE_SKIP_MAIN guard around main execution for testability.
scripts/linting/Validate-MarkdownFrontmatter.ps1 Replaces GitHub-only checks with Test-CIEnvironment and CI helper annotation/summary/env helpers.
scripts/linting/README.md Updates linting documentation to describe CI helper integration and exported helper APIs.
scripts/linting/Modules/LintingHelpers.psm1 Removes GitHub-specific helper implementations and aligns module surface toward CI helpers + file/git helpers.
scripts/linting/Modules/FrontmatterValidation.psm1 Removes GitHub-specific annotation helper implementation from the module.
scripts/linting/Markdown-Link-Check.ps1 Adds HVE_SKIP_MAIN and replaces GitHub helper usage with CI helper annotations/summary/env helpers.
scripts/linting/Link-Lang-Check.ps1 Adds HVE_SKIP_MAIN and replaces GitHub-only failure annotation with CI helper annotation.
scripts/linting/Invoke-YamlLint.ps1 Replaces GitHub helper outputs/annotations/summary/env with CI helpers.
scripts/linting/Invoke-PSScriptAnalyzer.ps1 Replaces GitHub helper outputs/annotations/summary/env with CI helpers and maps severities to CI levels.
scripts/linting/Invoke-LinkLanguageCheck.ps1 Refactors into a testable core function and switches annotations/outputs/env/summary to CI helpers.
scripts/lib/Modules/CIHelpers.psm1 Adds CI env var helper and bulk annotation helper; expands exported CI integration surface.
Comments suppressed due to low confidence (1)

scripts/security/Test-SHAStaleness.ps1:83

  • Even when $env:HVE_SKIP_MAIN is set (tests dot-source this script), the script still creates the log directory at import time. This is a side effect outside the guarded main block and can cause tests to write to the repo filesystem unexpectedly. Consider moving the log directory creation behind the skip-main guard (or lazily creating it inside Write-SecurityLog) so loading functions for tests is side-effect free.
$script:SkipMain = $env:HVE_SKIP_MAIN -eq '1'

# Ensure logging directory exists
$LogDir = Split-Path -Parent $LogPath
if (!(Test-Path $LogDir)) {
    New-Item -ItemType Directory -Path $LogDir -Force | Out-Null
}

WilliamBerryiii and others added 2 commits February 3, 2026 19:23
- replace GitHub Actions helpers across linting scripts
- extend CIHelpers for env and annotations with tests
- update linting and security test mocks for CI integration
- document CIHelpers usage in linting README

🔧 - Generated by Copilot
- Standardize SPDX-License-Identifier headers across 7 files
- Fix HVE_SKIP_MAIN handling in integration test contexts
- Add ErrorAction Continue to prevent terminating errors in catch blocks
- Remove legacy Created date headers from script files

🔧 - Generated by Copilot

Co-authored-by: littleKitchen <55852668+littleKitchen@users.noreply.github.com>
@WilliamBerryiii WilliamBerryiii force-pushed the refactor/351-linting-cihelpers branch from fbd8cc4 to d680c7d Compare February 4, 2026 05:42
@github-actions
Copy link

github-actions bot commented Feb 4, 2026

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@codecov-commenter
Copy link

codecov-commenter commented Feb 4, 2026

Codecov Report

❌ Patch coverage is 70.12987% with 69 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.66%. Comparing base (492a7b1) to head (052af87).

Files with missing lines Patch % Lines
scripts/security/Update-ActionSHAPinning.ps1 59.03% 34 Missing ⚠️
scripts/linting/Markdown-Link-Check.ps1 12.50% 14 Missing ⚠️
scripts/linting/Invoke-LinkLanguageCheck.ps1 87.23% 6 Missing ⚠️
scripts/linting/Invoke-PSScriptAnalyzer.ps1 78.94% 4 Missing ⚠️
scripts/linting/Link-Lang-Check.ps1 33.33% 4 Missing ⚠️
scripts/security/Test-SHAStaleness.ps1 50.00% 3 Missing ⚠️
scripts/linting/Invoke-YamlLint.ps1 84.61% 2 Missing ⚠️
scripts/linting/Validate-MarkdownFrontmatter.ps1 71.42% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##             main     #401       +/-   ##
===========================================
+ Coverage   60.96%   74.66%   +13.70%     
===========================================
  Files          19       19               
  Lines        3233     3296       +63     
===========================================
+ Hits         1971     2461      +490     
+ Misses       1262      835      -427     
Flag Coverage Δ
pester 74.66% <70.12%> (+13.70%) ⬆️

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

Files with missing lines Coverage Δ
scripts/lib/Modules/CIHelpers.psm1 95.74% <100.00%> (+1.35%) ⬆️
scripts/linting/Modules/FrontmatterValidation.psm1 96.02% <ø> (-0.27%) ⬇️
scripts/linting/Modules/LintingHelpers.psm1 100.00% <ø> (ø)
scripts/linting/Invoke-YamlLint.ps1 95.83% <84.61%> (+2.59%) ⬆️
scripts/linting/Validate-MarkdownFrontmatter.ps1 65.45% <71.42%> (+0.58%) ⬆️
scripts/security/Test-SHAStaleness.ps1 56.72% <50.00%> (+8.06%) ⬆️
scripts/linting/Invoke-PSScriptAnalyzer.ps1 92.30% <78.94%> (+0.30%) ⬆️
scripts/linting/Link-Lang-Check.ps1 48.14% <33.33%> (+48.14%) ⬆️
scripts/linting/Invoke-LinkLanguageCheck.ps1 90.00% <87.23%> (+90.00%) ⬆️
scripts/linting/Markdown-Link-Check.ps1 30.12% <12.50%> (+30.12%) ⬆️
... and 1 more

... and 1 file with indirect coverage changes

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

@WilliamBerryiii
Copy link
Member Author

@littleKitchen - This PR is ready for review! It incorporates the learnings from your work on PR #379 and implements the script-as-orchestrator pattern we discussed.

Changes in latest commits:

  • Standardized SPDX-License-Identifier headers across 7 files
  • Fixed HVE_SKIP_MAIN handling in integration test contexts
  • Added ErrorAction Continue to prevent terminating errors in catch blocks
  • All 850 tests passing

Would appreciate your eyes on it when you have a chance. 🙏

- sanitize file paths in step summaries for AzDO injection prevention

- move Set-StrictMode inside SkipMain guard to prevent test scope leak

- add ExcludePaths param to mock scripts in Link-Lang-Check tests

- update README documentation for LintingHelpers module exports

🔒 - Generated by Copilot
Copilot AI review requested due to automatic review settings February 4, 2026 06:11
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 25 out of 25 changed files in this pull request and generated 6 comments.

WilliamBerryiii and others added 2 commits February 4, 2026 08:31
- replace direct ::error:: output with Write-CIAnnotation
- aligns with CIHelpers convention used elsewhere

🔧 - Generated by Copilot
Copilot AI review requested due to automatic review settings February 4, 2026 16:47
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 25 out of 25 changed files in this pull request and generated 7 comments.

- Use delimiter-based format for Set-CIEnv GitHub env file writes

- Add variable name validation for GitHub Actions env vars

- Add -ErrorAction Continue to Write-Error in catch blocks

- Update CIHelpers tests for new delimiter format

🔧 - Generated by Copilot
@WilliamBerryiii WilliamBerryiii merged commit 3587e6a into main Feb 4, 2026
16 checks passed
WilliamBerryiii added a commit that referenced this pull request Feb 4, 2026
🤖 I have created a release *beep* *boop*
---


##
[2.1.0](hve-core-v2.0.1...hve-core-v2.1.0)
(2026-02-04)


### ✨ Features

* add PowerShell script to validate copyright headers
([#370](#370))
([92fce72](92fce72))
* **docs:** Replace deprecated chat.modeFilesLocations with
chat.agentFilesLocations
([#413](#413))
([67fb2ab](67fb2ab))
* **scripts:** add CIHelpers module for CI platform abstraction
([#348](#348))
([23e7a7e](23e7a7e))
* **scripts:** add SecurityHelpers and CIHelpers modules
([#354](#354))
([b93d990](b93d990))
* **workflow:** add copilot-setup-steps.yml for Coding Agent environment
([#398](#398))
([085a38b](085a38b))


### 🐛 Bug Fixes

* **build:** increase release-please search depths to prevent 250-commit
window issue ([#342](#342))
([4bb857d](4bb857d))
* **build:** patch @isaacs/brace-expansion critical vulnerability
([#404](#404))
([292ef51](292ef51))
* **ci:** disable errexit during spell check exit code capture
([#356](#356))
([ed6ed46](ed6ed46))
* **ci:** exclude extension/README.md from frontmatter validation
([#362](#362))
([e0d7378](e0d7378))
* exclude test fixtures from markdown link checker
([#345](#345))
([58147f9](58147f9))
* **extension:** resolve path resolution issues in Windows/WSL
environments ([#407](#407))
([8529725](8529725))
* **linting:** use Write-Error instead of Write-Host for error output
([#377](#377))
([2ca766b](2ca766b))
* **scripts:** apply CI output escaping to infrastructure scripts
([#369](#369))
([251021e](251021e))
* **scripts:** apply CI output escaping to linting scripts
([#367](#367))
([fdd75ed](fdd75ed))
* **scripts:** apply CI output escaping to security scripts
([#368](#368))
([1237c9a](1237c9a))
* **scripts:** ensure reliable array count operations in linting and
security scripts
([#395](#395))
([de43e73](de43e73))
* **scripts:** standardize PowerShell requirements header block
([#385](#385))
([6e26282](6e26282))


### 📚 Documentation

* add doc-ops agent to CUSTOM-AGENTS reference
([#358](#358))
([15f7185](15f7185))
* add memory agent to CUSTOM-AGENTS.md
([#359](#359))
([d92c4e1](d92c4e1))
* add missing agents to extension README
([#357](#357))
([d58541c](d58541c))
* add task-reviewer agent to CUSTOM-AGENTS.md
([#363](#363))
([0efb722](0efb722))
* **contributing:** add copyright header guidelines
([#382](#382))
([881a567](881a567))
* **scripts:** update README.md with missing directory sections
([#355](#355))
([ac2966f](ac2966f))


### ♻️ Refactoring

* **scripts:** align linting and tests with CIHelpers
([#401](#401))
([3587e6a](3587e6a))
* **scripts:** extract Invoke-PackageExtension for testability
([#343](#343))
([858a1be](858a1be))
* **scripts:** extract orchestration function for Prepare-Extension
testability ([#344](#344))
([9fd4bd1](9fd4bd1))
* **scripts:** replace raw GITHUB_OUTPUT with Set-CIOutput in
Package-Extension
([#391](#391))
([74a30bb](74a30bb))
* **security:** move DependencyViolation and ComplianceReport to shared
module ([#378](#378))
([1dd31ad](1dd31ad))


### 🔧 Maintenance

* add copyright headers to PowerShell scripts
([#381](#381))
([d19c9b3](d19c9b3))
* add copyright headers to shell scripts
([#380](#380))
([284b456](284b456))
* **deps-dev:** bump cspell from 9.6.1 to 9.6.2 in the npm-dependencies
group ([#387](#387))
([23c2b9f](23c2b9f))
* **workflows:** simplify Copilot setup steps workflow triggers
([#414](#414))
([492a7b1](492a7b1))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Co-authored-by: hve-core-release-please[bot] <254602402+hve-core-release-please[bot]@users.noreply.github.com>
Co-authored-by: Bill Berry <wberry@microsoft.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.

4 participants