Skip to content
This repository was archived by the owner on Jul 16, 2026. It is now read-only.

v1.0.9

Latest

Choose a tag to compare

@github-actions github-actions released this 10 Jul 21:53
8bfb84d

🚀 [Feature]: Import-TestData is available from the shared Helpers module (#20)

The shared Helpers module now provides an Import-TestData command, so every repo that installs the helpers gets it automatically — the same way Install-PSModule is already provided. It reads the PSMODULE_TEST_DATA environment variable (a single-line JSON object with optional secrets and variables maps) and exposes each entry as an environment variable for the remaining steps in the same job, masking secret values in the logs.

New: Import-TestData in the Helpers module

Test data no longer has to be wired up per repo. Previously this logic lived in a caller-shipped ./.github/scripts/Expose-TestData.ps1 that every consumer had to carry, and most never did (Template-PSModule, Confluence, …), so the Test/BeforeAll/AfterAll-ModuleLocal workflows failed with script not found. Shipping the logic in the installed Helpers module means every consumer gets it for free.

Call it from any step after the helpers are installed:

- name: Expose caller-provided test data
  shell: pwsh
  env:
    PSMODULE_TEST_DATA: ${{ secrets.TestData }}
  run: Import-TestData

Behavior:

  • secrets values are masked in the logs via ::add-mask::; variables values are not.
  • Keys are validated: they must be legal environment-variable names, must not override reserved or GitHub-provided variables, must not be duplicated across the two maps, and values must be scalar.
  • When no data is provided it is a no-op.
  • Outside GitHub Actions (no GITHUB_ENV) it fails fast with a clear message instead of a generic parameter-binding error.

Technical Details

  • src/Helpers/Helpers.psm1: adds the Import-TestData function. Its validators (Assert-EnvironmentName, Assert-Map, Get-EnvironmentValue, Add-EnvFromMap) are nested inside it so they stay private — the manifest has no FunctionsToExport, so every top-level function is exported and nesting avoids leaking generic helper names. Named Import-TestData (not Expose-…) because module functions must use an approved verb (PSUseApprovedVerbs is enforced by super-linter across the ecosystem).
  • Values are written to GITHUB_ENV using heredoc syntax, and the writes are terminating (-ErrorAction Stop) even when the caller's ErrorActionPreference is Continue.
  • tests/Import-TestData.Tests.ps1: new standalone test covering masking, GITHUB_ENV heredoc output, the no-op path, missing GITHUB_ENV, an unwritable GITHUB_ENV path, and every validation error (invalid JSON, unexpected top-level key, invalid env name, reserved override, duplicate across maps, non-scalar value).
  • .github/workflows/Action-Test.yml: runs the new test alongside the existing Install-PSModule regression test.
  • Validation: PSScriptAnalyzer clean with the repo settings; the module imports without an unapproved-verb warning; Import-TestData is exported while the validators stay private; the existing regression test still passes.
  • Release chain: release Install-PSModuleHelpers with Import-TestData → pin Process-PSModule to that version → Template-PSModule bumps.