Skip to content

Commit 3ed96da

Browse files
🩹 [Patch]: Framework-generated code coverage no longer penalizes module authors (#310)
Framework-generated boilerplate — type accelerator registration and `OnRemove` cleanup — is now tested and covered by updated action versions referenced in this workflow. The obsolete `$IsWindows` PS 5.1 shim is no longer injected into built modules. Coverage from the framework test step and the module test step is already aggregated by Get-CodeCoverage, so module authors' coverage percentages now reflect only the code they wrote. - Fixes #309 ## Changed: Build-PSModule updated to v4.0.14 Built modules no longer include the `$IsWindows = $true` Desktop edition shim or its PSScriptAnalyzer suppression attributes. PSModule targets PowerShell LTS (7.6+), where `$IsWindows` is a built-in automatic variable. See [PSModule/Build-PSModule#132](PSModule/Build-PSModule#132) for details. ## Changed: Test-PSModule updated to v3.0.10 The framework module tests now validate that every public class and enum is registered as a type accelerator after import, and that the `OnRemove` hook cleans them up when the module is removed. These tests produce coverage artifacts that are aggregated with module author test coverage, so framework-generated boilerplate no longer counts against the module author's coverage target. See [PSModule/Test-PSModule#113](PSModule/Test-PSModule#113) for details. ## Changed: README documents the framework testing design The README now explains: - Why framework-generated code is tested by the framework itself - How coverage from both the framework test step and the module test step is aggregated - That module authors do not need to test framework-generated code themselves ## Technical Details - `.github/workflows/Build-Module.yml`: Updated Build-PSModule from v4.0.13 to v4.0.14 (`345728124d201f371a8b0f1aacb98f89000a06dc`) - `.github/workflows/Test-Module.yml`: Updated Test-PSModule from v3.0.8 to v3.0.10 (`8c3337136dc7cf320da39eeb50e776d04bc9ac73`) - `.github/workflows/Test-SourceCode.yml`: Updated Test-PSModule from v3.0.8 to v3.0.10 - `README.md`: Added "Code coverage for framework-generated code" paragraph under the Framework test section; added coverage aggregation details under the Get code coverage section; removed reference to the `$IsWindows` shim - No workflow structure changes — code coverage was already enabled in Test-Module.yml and Get-PesterCodeCoverage already aggregates all `*-CodeCoverage` artifacts
1 parent 205d193 commit 3ed96da

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

‎.github/workflows/Build-Module.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
fetch-depth: 0
3131

3232
- name: Build module
33-
uses: PSModule/Build-PSModule@7a3ae1be38587e8051833d85ffa53c348de3cd0d # v4.0.13
33+
uses: PSModule/Build-PSModule@345728124d201f371a8b0f1aacb98f89000a06dc # v4.0.14
3434
with:
3535
Name: ${{ fromJson(inputs.Settings).Name }}
3636
ArtifactName: ${{ inputs.ArtifactName }}

‎.github/workflows/Test-Module.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ jobs:
6363
path: ${{ fromJson(inputs.Settings).WorkingDirectory }}/outputs/module
6464

6565
- name: Test-Module
66-
uses: PSModule/Test-PSModule@d4d6d1d2ac1d243ca82c9c199371533e8d2220ef # v3.0.8
66+
uses: PSModule/Test-PSModule@8c3337136dc7cf320da39eeb50e776d04bc9ac73 # v3.0.10
6767
with:
6868
Name: ${{ fromJson(inputs.Settings).Name }}
6969
Debug: ${{ fromJson(inputs.Settings).Debug }}

‎.github/workflows/Test-SourceCode.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
fetch-depth: 0
2828

2929
- name: Test-SourceCode
30-
uses: PSModule/Test-PSModule@d4d6d1d2ac1d243ca82c9c199371533e8d2220ef # v3.0.8
30+
uses: PSModule/Test-PSModule@8c3337136dc7cf320da39eeb50e776d04bc9ac73 # v3.0.10
3131
with:
3232
Debug: ${{ fromJson(inputs.Settings).Debug }}
3333
Prerelease: ${{ fromJson(inputs.Settings).Prerelease }}

‎README.md‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,14 @@ The [PSModule - SourceCode tests](./scripts/tests/SourceCode/PSModule/PSModule.T
163163
- [PSModule framework settings for style and standards for modules](https://github.com/PSModule/Test-PSModule?tab=readme-ov-file#module-tests)
164164
- [PSScriptAnalyzer rules](https://github.com/PSModule/Invoke-ScriptAnalyzer)
165165
- This produces a JSON-based report that is used by [Get-PesterTestResults](#get-test-results) evaluate the results of the tests.
166+
- **Code coverage for framework-generated code**: This step collects code coverage for framework-generated
167+
boilerplate. During the [build step](#build-module), [Build-PSModule](https://github.com/PSModule/Build-PSModule)
168+
injects boilerplate code into the compiled `.psm1` file — including type accelerator registration for public classes
169+
and enums, and the `OnRemove` cleanup hook. The framework tests in
170+
[Test-PSModule](https://github.com/PSModule/Test-PSModule) exercise these code paths and produce coverage artifacts
171+
that are aggregated with coverage from [Test-ModuleLocal](#test-module) in the
172+
[Get code coverage](#get-code-coverage) step. This keeps framework-generated lines from counting against the module
173+
author's coverage report.
166174

167175
### Test module
168176

@@ -299,6 +307,9 @@ The [PSModule - Module tests](./scripts/tests/Module/PSModule/PSModule.Tests.ps1
299307

300308
[workflow](./.github/workflows/Get-CodeCoverage.yml)
301309
- Gathers the code coverage from the previous steps and creates a summary of the results.
310+
- Aggregates coverage from the [Framework test](#framework-test) step (framework-generated boilerplate) and the
311+
[Test module](#test-module) step (module author code). A command executed in either step counts as covered, so
312+
framework-generated lines do not count against the module author's coverage target.
302313
- If the code coverage is below the target, the workflow will fail here.
303314

304315
### Publish module

0 commit comments

Comments
 (0)