Skip to content

Commit 451c787

Browse files
🚀 [Feature]: Add functionality to configure the process with a settings file (#158)
## Description This pull request includes significant changes to the CI workflow configuration, primarily focusing on the introduction of a new `Get-Settings` workflow and the modification of multiple job dependencies to utilize this new workflow. The changes aim to streamline the settings management and test suite configurations. Key changes include: ### Workflow and Job Modifications: * [`.github/workflows/CI.yml`](diffhunk://#diff-3ab46ee209a127470fce3c2cf106b1a1dbadbb929a4b5b13656a4bc4ce19c0b8L35-R39): Replaced the `Get-TestSuites` job with a new `Get-Settings` job, and updated all subsequent job dependencies and inputs to use the outputs from `Get-Settings`. This includes changes to job conditions, matrix configurations, and input parameters. [[1]](diffhunk://#diff-3ab46ee209a127470fce3c2cf106b1a1dbadbb929a4b5b13656a4bc4ce19c0b8L35-R39) [[2]](diffhunk://#diff-3ab46ee209a127470fce3c2cf106b1a1dbadbb929a4b5b13656a4bc4ce19c0b8L62-R62) [[3]](diffhunk://#diff-3ab46ee209a127470fce3c2cf106b1a1dbadbb929a4b5b13656a4bc4ce19c0b8L72-R95) [[4]](diffhunk://#diff-3ab46ee209a127470fce3c2cf106b1a1dbadbb929a4b5b13656a4bc4ce19c0b8R104-R107) [[5]](diffhunk://#diff-3ab46ee209a127470fce3c2cf106b1a1dbadbb929a4b5b13656a4bc4ce19c0b8R116-R199) ### New Workflow: * [`.github/workflows/Get-Settings.yml`](diffhunk://#diff-68f351d419a9b4db4797434891d5dfad44d83de65bfee7ba1c60badae369dbefR1-R338): Added a new workflow, `Get-Settings`, which processes the settings file and outputs necessary configurations for subsequent jobs. This includes reading settings from various file formats (JSON, YAML, PSD1) and determining test suites to run based on the settings. ### Additional Inputs: * [`.github/workflows/Get-CodeCoverage.yml`](diffhunk://#diff-261187083ecd8c20f585c08962cc876f48b4da8453718d673165a1a9cec9eecaR6-R15): Added new inputs `StepSummary_Mode` and `CodeCoveragePercentTarget` to control the GitHub step summary sections and set a target for code coverage. These inputs are used in the `Get-CodeCoverage` job. [[1]](diffhunk://#diff-261187083ecd8c20f585c08962cc876f48b4da8453718d673165a1a9cec9eecaR6-R15) [[2]](diffhunk://#diff-261187083ecd8c20f585c08962cc876f48b4da8453718d673165a1a9cec9eecaR54-R55) ## Type of change <!-- Use the check-boxes [x] on the options that are relevant. --> - [ ] 📖 [Docs] - [ ] 🪲 [Fix] - [ ] 🩹 [Patch] - [ ] ⚠️ [Security fix] - [x] 🚀 [Feature] - [ ] 🌟 [Breaking change] ## Checklist <!-- Use the check-boxes [x] on the options that are relevant. --> - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas
1 parent 59fe203 commit 451c787

18 files changed

+519
-271
lines changed

.github/workflows/CI.yml

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ on:
3232
type: string
3333
description: The name of the module to process. Scripts default to the repository name if nothing is specified.
3434
required: false
35-
SkipTests:
35+
SettingsPath:
3636
type: string
37-
description: Defines what types of tests to skip. Allowed values are 'All', 'SourceCode', 'Module', 'None', 'macOS', 'Windows', 'Linux'.
37+
description: The path to the settings file. Settings in the settings file take precedence over the action inputs.
3838
required: false
39-
default: None
39+
default: .github/PSModule.psd1
4040
Debug:
4141
type: boolean
4242
description: Enable debug output.
@@ -59,7 +59,7 @@ on:
5959
default: false
6060
WorkingDirectory:
6161
type: string
62-
description: The working directory where the script will run from.
62+
description: The path to the root of the repo.
6363
required: false
6464
default: '.'
6565

@@ -69,29 +69,30 @@ permissions:
6969
statuses: write # to update the status of the workflow from linter
7070

7171
jobs:
72-
Get-TestSuites:
73-
uses: ./.github/workflows/Get-TestSuites.yml
72+
Get-Settings:
73+
uses: ./.github/workflows/Get-Settings.yml
7474
with:
75-
SkipTests: ${{ inputs.SkipTests }}
75+
Name: ${{ inputs.Name }}
76+
SettingsPath: ${{ inputs.SettingsPath }}
7677
Debug: ${{ inputs.Debug }}
7778
Prerelease: ${{ inputs.Prerelease }}
7879
Verbose: ${{ inputs.Verbose }}
7980
Version: ${{ inputs.Version }}
8081
WorkingDirectory: ${{ inputs.WorkingDirectory }}
8182

8283
Test-SourceCode:
83-
if: ${{ needs.Get-TestSuites.outputs.SourceCodeTestSuites != '[]' }}
84+
if: ${{ needs.Get-Settings.outputs.SourceCodeTestSuites != '[]' }}
8485
needs:
85-
- Get-TestSuites
86+
- Get-Settings
8687
strategy:
8788
fail-fast: false
8889
matrix:
89-
include: ${{ fromJson(needs.Get-TestSuites.outputs.SourceCodeTestSuites) }}
90+
include: ${{ fromJson(needs.Get-Settings.outputs.SourceCodeTestSuites) }}
9091
uses: ./.github/workflows/Test-SourceCode.yml
9192
with:
9293
RunsOn: ${{ matrix.RunsOn }}
9394
OS: ${{ matrix.OSName }}
94-
Name: ${{ inputs.Name }}
95+
Name: ${{ fromJson(needs.Get-Settings.outputs.Settings).Name }}
9596
Debug: ${{ inputs.Debug }}
9697
Prerelease: ${{ inputs.Prerelease }}
9798
Verbose: ${{ inputs.Verbose }}
@@ -100,8 +101,10 @@ jobs:
100101

101102
Build-Module:
102103
uses: ./.github/workflows/Build-Module.yml
104+
needs:
105+
- Get-Settings
103106
with:
104-
Name: ${{ inputs.Name }}
107+
Name: ${{ fromJson(needs.Get-Settings.outputs.Settings).Name }}
105108
Debug: ${{ inputs.Debug }}
106109
Prerelease: ${{ inputs.Prerelease }}
107110
Verbose: ${{ inputs.Verbose }}
@@ -110,83 +113,90 @@ jobs:
110113

111114
Build-Docs:
112115
needs:
116+
- Get-Settings
113117
- Build-Module
114118
uses: ./.github/workflows/Build-Docs.yml
115119
with:
116-
Name: ${{ inputs.Name }}
120+
Name: ${{ fromJson(needs.Get-Settings.outputs.Settings).Name }}
117121
Debug: ${{ inputs.Debug }}
118122
Prerelease: ${{ inputs.Prerelease }}
119123
Verbose: ${{ inputs.Verbose }}
120124
Version: ${{ inputs.Version }}
121125
WorkingDirectory: ${{ inputs.WorkingDirectory }}
122126

123127
Test-Module:
124-
if: ${{ needs.Build-Module.result == 'success' && !cancelled() && needs.Get-TestSuites.outputs.ModuleTestSuites != '[]' }}
128+
if: ${{ needs.Build-Module.result == 'success' && !cancelled() && needs.Get-Settings.outputs.PSModuleTestSuites != '[]' }}
125129
needs:
126130
- Build-Module
127-
- Get-TestSuites
131+
- Get-Settings
128132
strategy:
129133
fail-fast: false
130134
matrix:
131-
include: ${{ fromJson(needs.Get-TestSuites.outputs.ModuleTestSuites) }}
135+
include: ${{ fromJson(needs.Get-Settings.outputs.PSModuleTestSuites) }}
132136
uses: ./.github/workflows/Test-Module.yml
133137
secrets: inherit
134138
with:
135139
RunsOn: ${{ matrix.RunsOn }}
136140
OS: ${{ matrix.OSName }}
137-
Name: ${{ inputs.Name }}
141+
Name: ${{ fromJson(needs.Get-Settings.outputs.Settings).Name }}
138142
Debug: ${{ inputs.Debug }}
139143
Prerelease: ${{ inputs.Prerelease }}
140144
Verbose: ${{ inputs.Verbose }}
141145
Version: ${{ inputs.Version }}
142146
WorkingDirectory: ${{ inputs.WorkingDirectory }}
143147

144148
Test-ModuleLocal:
145-
if: ${{ needs.Build-Module.result == 'success' && !cancelled() && needs.Get-TestSuites.outputs.ModuleLocalTestSuites != '[]' }}
149+
if: ${{ needs.Build-Module.result == 'success' && !cancelled() && needs.Get-Settings.outputs.ModuleTestSuites != '[]' }}
146150
needs:
147151
- Build-Module
148-
- Get-TestSuites
152+
- Get-Settings
149153
strategy:
150154
fail-fast: false
151155
matrix:
152-
include: ${{ fromJson(needs.Get-TestSuites.outputs.ModuleLocalTestSuites) }}
156+
include: ${{ fromJson(needs.Get-Settings.outputs.ModuleTestSuites) }}
153157
uses: ./.github/workflows/Test-ModuleLocal.yml
154158
secrets: inherit
155159
with:
156160
RunsOn: ${{ matrix.RunsOn }}
157161
OS: ${{ matrix.OSName }}
158-
Name: ${{ inputs.Name }}
159162
TestPath: ${{ matrix.TestPath }}
160163
TestName: ${{ matrix.TestName }}
164+
Name: ${{ fromJson(needs.Get-Settings.outputs.Settings).Name }}
161165
Debug: ${{ inputs.Debug }}
162166
Prerelease: ${{ inputs.Prerelease }}
163167
Verbose: ${{ inputs.Verbose }}
164168
Version: ${{ inputs.Version }}
165169
WorkingDirectory: ${{ inputs.WorkingDirectory }}
166170

167171
Get-TestResults:
168-
if: always() && !cancelled()
172+
if: needs.Get-Settings.result == 'success' && (always() && !cancelled())
169173
needs:
174+
- Get-Settings
170175
- Test-SourceCode
171176
- Test-Module
172177
- Test-ModuleLocal
173178
uses: ./.github/workflows/Get-TestResults.yml
174179
secrets: inherit
175180
with:
181+
ModuleTestSuites: ${{ needs.Get-Settings.outputs.ModuleTestSuites }}
182+
SourceCodeTestSuites: ${{ needs.Get-Settings.outputs.SourceCodeTestSuites }}
183+
PSModuleTestSuites: ${{ needs.Get-Settings.outputs.PSModuleTestSuites }}
176184
Debug: ${{ inputs.Debug }}
177185
Prerelease: ${{ inputs.Prerelease }}
178186
Verbose: ${{ inputs.Verbose }}
179187
Version: ${{ inputs.Version }}
180188

181189
Get-CodeCoverage:
182-
if: always() && !cancelled()
190+
if: needs.Get-Settings.result == 'success' && (always() && !cancelled())
183191
needs:
184-
- Test-SourceCode
192+
- Get-Settings
185193
- Test-Module
186194
- Test-ModuleLocal
187195
uses: ./.github/workflows/Get-CodeCoverage.yml
188196
secrets: inherit
189197
with:
198+
CodeCoveragePercentTarget: ${{ fromJson(needs.Get-Settings.outputs.Settings).Test.CodeCoverage.PercentTarget }}
199+
StepSummary_Mode: ${{ fromJson(needs.Get-Settings.outputs.Settings).Test.CodeCoverage.StepSummaryMode }}
190200
Debug: ${{ inputs.Debug }}
191201
Prerelease: ${{ inputs.Prerelease }}
192202
Verbose: ${{ inputs.Verbose }}

.github/workflows/Get-CodeCoverage.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@ name: Get-CodeCoverage
33
on:
44
workflow_call:
55
inputs:
6+
StepSummary_Mode:
7+
type: string
8+
description: |
9+
Controls which sections to show in the GitHub step summary.
10+
Use 'Full' for all sections, 'None' to disable, or a comma-separated list of 'Missed, Executed, Files'.
11+
required: false
12+
default: Missed, Files
13+
CodeCoveragePercentTarget:
14+
type: number
15+
description: The target for code coverage.
616
Debug:
717
type: boolean
818
description: Enable debug output.
@@ -41,6 +51,8 @@ jobs:
4151
uses: PSModule/Get-PesterCodeCoverage@v1
4252
id: Get-CodeCoverage
4353
with:
54+
CodeCoveragePercentTarget: ${{ inputs.CodeCoveragePercentTarget }}
55+
StepSummary_Mode: ${{ inputs.StepSummary_Mode }}
4456
Debug: ${{ inputs.Debug }}
4557
Prerelease: ${{ inputs.Prerelease }}
4658
Verbose: ${{ inputs.Verbose }}

0 commit comments

Comments
 (0)