Skip to main content

Quality Gates

This page documents the quality gates and code standards currently enforced in HaloAPI.

Overview​

HaloAPI quality checks are centered on these repo entrypoints:

pwsh -File .\DevOps\Quality\run-pssa.ps1
pwsh -File .\DevOps\Quality\test.ps1 -Suite Meta

The repo currently uses:

  • PSScriptAnalyzer for static analysis.
  • HaloAPI-specific custom rules under CustomRules/.
  • Inline parameter comments for functions where the custom rules require them.
  • Comment-based help on public cmdlets.

PSScriptAnalyzer​

Use the dedicated wrapper instead of ad hoc analyzer commands:

pwsh -File .\DevOps\Quality\run-pssa.ps1

The wrapper intentionally applies the full repo ruleset to Public/ and a reduced ruleset elsewhere.

Public-surface conventions currently enforced include:

  • required comment-based help
  • empty help section detection
  • missing parameter description detection
  • self-referential parameter alias detection

Tests​

Use the dedicated test script rather than calling Invoke-Pester directly:

pwsh -File .\DevOps\Quality\test.ps1 -Suite Meta -Verbosity Detailed

Generate coverage through the same entrypoint:

pwsh -File .\DevOps\Quality\test.ps1 -Suite Meta -Verbosity Detailed -CodeCoverage

Code Coverage​

Code coverage is generated in CI for the Meta and Unit suites.

CI enforces a minimum 70% coverage threshold for the Unit suite.

Coverage artifacts are uploaded for each run as:

  • code-coverage-meta-results (.artifacts/CodeCoverage.meta.xml)
  • code-coverage-unit-results (.artifacts/CodeCoverage.unit.xml)

You can access them from the CI workflow runs:

GitHub Actions CI workflow

Local Live and E2E Testing​

Run test suites through the quality script entrypoints in DevOps/Quality.

For local Live and E2E runs, use the Key Vault wrapper script. It loads the required environment variables from Azure Key Vault before invoking DevOps/Quality/test.ps1.

  1. Sign in to Azure first:

    Connect-AzAccount
  2. Run the Live suite:

    pwsh -NoProfile -File .\DevOps\Quality\Invoke-HaloLiveTests.ps1 -Suite Live -Verbosity Normal
  3. Run both Live and E2E in one invocation:

    pwsh -NoProfile -File .\DevOps\Quality\Invoke-HaloLiveTests.ps1 -Suite Live,E2E -Verbosity Normal

The wrapper expects these secrets in Key Vault (default vault name: MSPsUK):

  • HaloTestingURL
  • HaloTestingClientID
  • HaloTestingClientSecret
  • HaloTestingTenant

For non-live suites, use the standard test entrypoint directly:

pwsh -NoProfile -File .\DevOps\Quality\test.ps1 -Suite Meta,Unit -Verbosity Normal

CI Quality Gates​

The GitHub Actions CI flow on develop currently validates:

  1. PSScriptAnalyzer on Windows.
  2. Cross-platform metadata smoke tests on Linux and macOS.
  3. Windows metadata tests with JUnit output and coverage artifact generation.

Expectations For Changes​

When changing public cmdlets:

  • keep comment-based help intact
  • preserve exported function naming and aliasing conventions
  • rerun run-pssa.ps1
  • rerun test.ps1 -Suite Meta

When changing workflows:

  • keep the repo script entrypoints as the source of truth
  • avoid broadening secret usage unless required
  • preserve the develop integration branch and main release branch behavior