Skip to content

refactor(scripts): align LintingHelpers.psm1 with hve-core upstream#193

Merged
WilliamBerryiii merged 5 commits intomainfrom
feat/issue-68-lintinghelpers-refactor
Feb 18, 2026
Merged

refactor(scripts): align LintingHelpers.psm1 with hve-core upstream#193
WilliamBerryiii merged 5 commits intomainfrom
feat/issue-68-lintinghelpers-refactor

Conversation

@WilliamBerryiii
Copy link
Member

@WilliamBerryiii WilliamBerryiii commented Feb 17, 2026

Description

Align scripts/linting/Modules/LintingHelpers.psm1 with the upstream hve-core reference, reducing the module from 7 exports to 3 and delegating CI helper functions to the existing CIHelpers.psm1 module. Address all PR review feedback and add comprehensive unit tests.

Closes #68

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 💥 Breaking change (fix or feature that changes existing functionality)
  • 📚 Documentation update
  • 🏗️ Infrastructure change (Terraform, deployment scripts)
  • ♻️ Refactoring (no functional changes)

Component(s) Affected

  • deploy/000-prerequisites
  • deploy/001-iac
  • deploy/002-setup
  • deploy/004-workflow
  • src/training
  • docs/

Note: This change affects scripts/linting/Modules/LintingHelpers.psm1 and adds scripts/tests/linting/LintingHelpers.Tests.ps1.

Changes

  • Add copyright header and SPDX license identifier
  • Add CIHelpers.psm1 import and remove 4 dead CI helper functions (Write-GitHubAnnotation, Set-GitHubOutput, Set-GitHubEnv, Write-GitHubStepSummary)
  • Add --diff-filter=ACMR and HEAD~1 fallback to Get-ChangedFilesFromGit
  • Use pipeline filtering with inline Test-Path and return @() on error
  • Make Get-FilesRecursive -Include parameter mandatory, use single Get-ChildItem call
  • Use [System.IO.Path]::DirectorySeparatorChar for platform-aware separator in Get-GitIgnorePatterns
  • Reduce Export-ModuleMember from 7 to 3 functions

PR Review Fixes (Round 1)

  • Add --diff-filter=ACMR to final fallback git diff branch and fail-fast with Write-Warning when no changed files are found
  • Wrap Get-ChildItem result in @() in Get-FilesRecursive to guarantee array return instead of $null
  • Add try/catch error handling on Get-Content in Get-GitIgnorePatterns, returning @() on failure
  • Fix file-glob gitignore patterns (e.g., *.log, *.tmp) to omit trailing directory separator that prevented matching

PR Review Fixes (Round 2)

  • Add explicit $LASTEXITCODE -eq 0 check on HEAD~1 fallback for consistency with merge-base check
  • Wrap return $filteredFiles in @() in Get-ChangedFilesFromGit to guarantee array contract
  • Wrap $files | Where-Object reassignment in @() in Get-FilesRecursive to preserve array guarantee
  • Wrap return $patterns in @() in Get-GitIgnorePatterns to match early-exit return types

Unit Tests

  • Add scripts/tests/linting/LintingHelpers.Tests.ps1 with 30 unit tests covering all 3 exported functions
  • Tests follow hve-core Pester patterns with InModuleScope, BeforeAll/AfterAll module import, and mock-based isolation

Testing Performed

  • PSScriptAnalyzer: 0 violations on LintingHelpers.psm1 and all scripts/linting/ files
  • Pester test suite: 190 passed, 0 failed, 0 skipped
  • Module import smoke-test: 3 functions exported correctly (Get-ChangedFilesFromGit, Get-FilesRecursive, Get-GitIgnorePatterns)
  • Azure ML job validation
  • Deployment validation

Documentation Impact

  • No documentation changes needed
  • Updated existing documentation
  • Created new documentation

Checklist

  • Code follows project style guidelines
  • Self-review of code completed
  • Changes generate no new warnings
  • Existing tests pass locally
  • Added tests for new functionality

- add CIHelpers.psm1 import and remove 4 dead CI helper functions
- add --diff-filter=ACMR and HEAD~1 fallback to Get-ChangedFilesFromGit
- use pipeline filtering with inline Test-Path and platform-aware separators
- make Get-FilesRecursive -Include mandatory, use single Get-ChildItem call
- reduce Export-ModuleMember from 7 to 3 functions

♻️ - Generated by Copilot
Copilot AI review requested due to automatic review settings February 17, 2026 03:09
@github-actions
Copy link

github-actions bot commented Feb 17, 2026

Dependency Review

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

Scanned Files

None

Copy link

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

Aligns scripts/linting/Modules/LintingHelpers.psm1 with the upstream hve-core implementation by slimming the module surface area and delegating CI-related helpers to CIHelpers.psm1.

Changes:

  • Adds SPDX/copyright header and imports CIHelpers.psm1; removes GitHub-specific CI helper functions and reduces exports.
  • Updates Get-ChangedFilesFromGit fallback strategy and filtering (diff-filter, HEAD~1 fallback, pipeline filtering).
  • Refactors Get-FilesRecursive/Get-GitIgnorePatterns for simpler recursion and platform-aware path separators.

@WilliamBerryiii WilliamBerryiii added this to the v0.3.0 milestone Feb 17, 2026
- add --diff-filter=ACMR to final git diff fallback with fail-fast on empty
- wrap Get-ChildItem in @() for null-safe internal handling
- add try/catch error handling on Get-Content in Get-GitIgnorePatterns
- fix file-glob patterns to omit trailing separator for *.log/*.tmp
- add 28 unit tests covering all 3 exported functions

🔧 - Generated by Copilot
Copilot AI review requested due to automatic review settings February 17, 2026 03:43
Copy link

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 2 out of 2 changed files in this pull request and generated 4 comments.

…gHelpers

- add explicit LASTEXITCODE check on HEAD~1 fallback for consistency
- wrap pipeline return values in @() to guarantee array contracts
- add tests verifying array-type returns from all three functions

🔧 - Generated by Copilot
@bindsi bindsi self-requested a review February 18, 2026 09:50
@WilliamBerryiii WilliamBerryiii merged commit f24bc04 into main Feb 18, 2026
12 checks passed
@WilliamBerryiii WilliamBerryiii modified the milestones: v0.3.0, v0.11.0 Mar 1, 2026
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.

refactor(scripts): update LintingHelpers.psm1 for new integration

4 participants