File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3030 uses : PSModule/Process-PSModule/.github/workflows/workflow.yml@ea19a3eb1293246d1b00e4faae1544442c3be0ec # v6.1.1
3131 secrets :
3232 APIKEY : ${{ secrets.APIKEY }}
33+ # Showcase: send data down to the module tests (see tests/Environment.Tests.ps1).
34+ # TestData is a single-line JSON object with optional "secrets" (masked in logs) and
35+ # "variables" (not masked) maps. Every entry is exposed to the module test jobs as
36+ # $env:<name>. Reference a repository secret with the direct "${{ secrets.NAME }}"
37+ # form (single-line values, no quotes or backslashes) and a repository variable with
38+ # ${{ toJSON(vars.NAME) }} so any characters are encoded safely. The folded ">-" scalar
39+ # keeps the whole value on one line so GitHub registers a single log mask. Omit
40+ # TestData entirely when your tests need no data.
41+ TestData : >-
42+ { "secrets": { "TEST_SECRET": "${{ secrets.TEST_SECRET }}" },
43+ "variables": { "TEST_VARIABLE": ${{ toJSON(vars.TEST_VARIABLE) }} } }
Original file line number Diff line number Diff line change 1+ [Diagnostics.CodeAnalysis.SuppressMessageAttribute (
2+ ' PSReviewUnusedParameter' , ' ' ,
3+ Justification = ' Required for Pester tests'
4+ )]
5+ [Diagnostics.CodeAnalysis.SuppressMessageAttribute (
6+ ' PSUseDeclaredVarsMoreThanAssignments' , ' ' ,
7+ Justification = ' Required for Pester tests'
8+ )]
9+ [CmdletBinding ()]
10+ param ()
11+
12+ Describe ' TestData is exposed to the module tests' {
13+ # Showcase for the Process-PSModule 'TestData' feature. The calling workflow
14+ # (.github/workflows/Process-PSModule.yml) passes a repository secret and a repository
15+ # variable through a single TestData object, and the framework exposes each of them to
16+ # the module tests as an environment variable. To see these run, add a repository secret
17+ # named 'TEST_SECRET' and a repository variable named 'TEST_VARIABLE'. When they are not
18+ # configured the tests skip, so a fresh repository created from this template stays green.
19+
20+ It ' Exposes the secret from the "secrets" map as $env:TEST_SECRET' - Skip:([string ]::IsNullOrEmpty($env: TEST_SECRET )) {
21+ # Values in the "secrets" map are masked in the workflow logs.
22+ $env: TEST_SECRET | Should -Not - BeNullOrEmpty
23+ }
24+
25+ It ' Exposes the variable from the "variables" map as $env:TEST_VARIABLE' - Skip:([string ]::IsNullOrEmpty($env: TEST_VARIABLE )) {
26+ # Values in the "variables" map are not masked.
27+ $env: TEST_VARIABLE | Should -Not - BeNullOrEmpty
28+ }
29+ }
You can’t perform that action at this time.
0 commit comments