Skip to content

Commit 321e33a

Browse files
Expose TestData via the Helpers module's Import-TestData command
Replace the caller-shipped ./.github/scripts/Expose-TestData.ps1 with a call to Import-TestData, which is provided by PSModule/Install-PSModuleHelpers. All three ModuleLocal workflows (BeforeAll/Test/AfterAll) now install the helpers and run Import-TestData to expose the caller's secrets/variables to the test jobs; BeforeAll/AfterAll take the Install-PSModuleHelpers dependency they previously lacked. The helpers ref is temporarily @feat/import-testdata for end-to-end testing.
1 parent ea19a3e commit 321e33a

5 files changed

Lines changed: 18 additions & 149 deletions

File tree

.github/scripts/Expose-TestData.ps1

Lines changed: 0 additions & 138 deletions
This file was deleted.

.github/workflows/AfterAll-ModuleLocal.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,15 @@ jobs:
3131
persist-credentials: false
3232
fetch-depth: 0
3333

34+
- name: Install-PSModuleHelpers
35+
uses: PSModule/Install-PSModuleHelpers@feat/import-testdata # E2E: temporary branch ref (Import-TestData not yet released); pin to a released SHA before merge
36+
3437
- name: Expose caller-provided test data
3538
shell: pwsh
3639
env:
3740
PSMODULE_TEST_DATA: ${{ secrets.TestData }}
3841
run: |
39-
./.github/scripts/Expose-TestData.ps1
42+
Import-TestData
4043
4144
- name: Run AfterAll Teardown Scripts
4245
if: always()

.github/workflows/BeforeAll-ModuleLocal.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,15 @@ jobs:
3131
persist-credentials: false
3232
fetch-depth: 0
3333

34+
- name: Install-PSModuleHelpers
35+
uses: PSModule/Install-PSModuleHelpers@feat/import-testdata # E2E: temporary branch ref (Import-TestData not yet released); pin to a released SHA before merge
36+
3437
- name: Expose caller-provided test data
3538
shell: pwsh
3639
env:
3740
PSMODULE_TEST_DATA: ${{ secrets.TestData }}
3841
run: |
39-
./.github/scripts/Expose-TestData.ps1
42+
Import-TestData
4043
4144
- name: Run BeforeAll Setup Scripts
4245
uses: PSModule/GitHub-Script@8083ec1f733f00357ee4d0db0c6056686e483bc0 # v1.9.0

.github/workflows/Test-ModuleLocal.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,21 +36,21 @@ jobs:
3636
persist-credentials: false
3737
fetch-depth: 0
3838

39-
- name: Expose caller-provided test data
40-
shell: pwsh
41-
env:
42-
PSMODULE_TEST_DATA: ${{ secrets.TestData }}
43-
run: |
44-
./.github/scripts/Expose-TestData.ps1
45-
4639
- name: Download module artifact
4740
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
4841
with:
4942
name: module
5043
path: ${{ fromJson(inputs.Settings).WorkingDirectory }}/outputs/module
5144

5245
- name: Install-PSModuleHelpers
53-
uses: PSModule/Install-PSModuleHelpers@68e8ca76be679bfcb7099aed8cffa911c4ab72af # v1.0.8
46+
uses: PSModule/Install-PSModuleHelpers@feat/import-testdata # E2E: temporary branch ref (Import-TestData not yet released); pin to a released SHA before merge
47+
48+
- name: Expose caller-provided test data
49+
shell: pwsh
50+
env:
51+
PSMODULE_TEST_DATA: ${{ secrets.TestData }}
52+
run: |
53+
Import-TestData
5454
5555
- name: Import-Module
5656
id: import-module

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,8 @@ Notes:
489489
Names must match `^[A-Za-z_][A-Za-z0-9_]*$` and must not override reserved variables such as `PATH`,
490490
`CI`, `GITHUB_*`, `RUNNER_*` or `ACTIONS_*`.
491491
- The `TestData` validation, masking and environment export logic is shared by the ModuleLocal workflows
492-
through `.github/scripts/Expose-TestData.ps1`.
492+
through the [`PSModule/Install-PSModuleHelpers`](https://github.com/PSModule/Install-PSModuleHelpers)
493+
action, which installs the `Import-TestData` command each workflow runs to expose the values.
493494
- Reference secrets as `"${{ secrets.<name> }}"` (quoted, directly) rather than
494495
`toJSON(secrets.<name>)`. The direct form keeps CodeQL's *excessive secrets exposure* check happy and
495496
works for single-line secret values. It cannot carry values that contain `"`, `\` or newlines, so

0 commit comments

Comments
 (0)