Skip to content

Commit 1ea7523

Browse files
🌟 [Major]: Cleanup outputs + Bump and align with Invoke-Pester@v3 (#3)
## Description This pull request introduces significant changes to the GitHub Actions workflows and some configuration files. The main objective is to consolidate multiple workflow files into a single file and update the configurations accordingly. Here are the most important changes: ### The action itself * `action.yml`: * Updated to use `PSModule/Invoke-Pester@v3` instead of `PSModule/Invoke-Pester@v2` * Removed the `outputs` section🌟. ### Consolidation of Workflows * [`.github/workflows/Action-Test.yml`](diffhunk://#diff-a12ae5c885b0673c0ff6f70c2670886907590d624626e07da4c52e01aeaf56a4R1-R228): Added a new workflow file that consolidates multiple workflows into one, handling different test types such as `Src-SourceCode`, `Src-Custom`, `Src-WithManifest`, and `outputs`. This file also includes a new job `CatchJob` to aggregate the status of all tests. ### Removal of Redundant Workflow Files: * Removed the following workflow files as they are consolidated into the `Action-Test.yml` * `.github/workflows/Action-Test-Src-Default-Custom.yml` * `.github/workflows/Action-Test-Src-Default.yml` * `.github/workflows/Action-Test-Src-WithManifest.yml` * `.github/workflows/Action-Test-outputs.yml` ### Test and Script Updates * `scripts/tests/PSScriptAnalyzer/PSScriptAnalyzer.Tests.ps1`: * Refactored the script to improve readability and logging, including changes to how paths are resolved and how test results are logged. * Added a failing test to see that the action actually will detect failures. * Removed the `SuppressMessageAttribute` for the `Set-PSModuleTest` function in `tests/srcWithManifestTestRepo/src/functions/public/SomethingElse/Set-PSModuleTest.ps1`. ## Type of change <!-- Use the check-boxes [x] on the options that are relevant. --> - [ ] 📖 [Docs] - [ ] 🪲 [Fix] - [ ] 🩹 [Patch] - [ ] ⚠️ [Security fix] - [ ] 🚀 [Feature] - [x] 🌟 [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 f741c1e commit 1ea7523

File tree

13 files changed

+282
-172
lines changed

13 files changed

+282
-172
lines changed

.github/linters/.jscpd.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"consoleFull"
55
],
66
"ignore": [
7-
"**/tests/**"
7+
"**/tests/**",
8+
"**/.github/workflows/Action-Test.yml"
89
],
910
"absolute": true
1011
}

.github/workflows/Action-Test-Src-Default-Custom.yml

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

.github/workflows/Action-Test-Src-Default.yml

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

.github/workflows/Action-Test-Src-WithManifest.yml

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

.github/workflows/Action-Test-outputs.yml

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

.github/workflows/Action-Test.yml

Lines changed: 228 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,228 @@
1+
name: Action-Test
2+
3+
run-name: "Action-Test - [${{ github.event.pull_request.title }} #${{ github.event.pull_request.number }}] by @${{ github.actor }}"
4+
5+
on:
6+
workflow_dispatch:
7+
pull_request:
8+
schedule:
9+
- cron: '0 0 * * *'
10+
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.ref }}
13+
cancel-in-progress: true
14+
15+
permissions:
16+
contents: read
17+
pull-requests: read
18+
19+
jobs:
20+
ActionTestSrcSourceCode:
21+
name: Action-Test - [Src-SourceCode]
22+
runs-on: ubuntu-latest
23+
outputs:
24+
Outcome: ${{ steps.action-test.outcome }}
25+
Conclusion: ${{ steps.action-test.conclusion }}
26+
steps:
27+
- name: Checkout repo
28+
uses: actions/checkout@v4
29+
30+
- name: Action-Test
31+
uses: ./
32+
id: action-test
33+
with:
34+
Path: tests/srcTestRepo/src
35+
Settings: SourceCode
36+
37+
- name: Status
38+
shell: pwsh
39+
run: |
40+
Write-Host "Outcome: ${{ steps.action-test.outcome }}"
41+
Write-Host "Conclusion: ${{ steps.action-test.conclusion }}"
42+
43+
ActionTestSrcCustom:
44+
name: Action-Test - [Src-Custom]
45+
runs-on: ubuntu-latest
46+
outputs:
47+
Outcome: ${{ steps.action-test.outcome }}
48+
Conclusion: ${{ steps.action-test.conclusion }}
49+
steps:
50+
- name: Checkout repo
51+
uses: actions/checkout@v4
52+
53+
- name: Action-Test
54+
uses: ./
55+
id: action-test
56+
with:
57+
Path: tests/srcTestRepo/src
58+
Settings: Custom
59+
SettingsFilePath: tests/srcTestRepo/tests/Custom.Settings.psd1
60+
61+
- name: Status
62+
shell: pwsh
63+
run: |
64+
Write-Host "Outcome: ${{ steps.action-test.outcome }}"
65+
Write-Host "Conclusion: ${{ steps.action-test.conclusion }}"
66+
67+
ActionTestSrcWithManifest:
68+
name: Action-Test - [Src-WithManifest]
69+
runs-on: ubuntu-latest
70+
outputs:
71+
Outcome: ${{ steps.action-test.outcome }}
72+
Conclusion: ${{ steps.action-test.conclusion }}
73+
steps:
74+
- name: Checkout repo
75+
uses: actions/checkout@v4
76+
77+
- name: Action-Test
78+
uses: ./
79+
continue-on-error: true
80+
id: action-test
81+
with:
82+
Path: tests/srcWithManifestTestRepo/src
83+
Settings: SourceCode
84+
85+
- name: Status
86+
shell: pwsh
87+
run: |
88+
Write-Host "Outcome: ${{ steps.action-test.outcome }}"
89+
Write-Host "Conclusion: ${{ steps.action-test.conclusion }}"
90+
91+
ActionTestOutputs:
92+
name: Action-Test - [outputs]
93+
runs-on: ubuntu-latest
94+
outputs:
95+
Outcome: ${{ steps.action-test.outcome }}
96+
Conclusion: ${{ steps.action-test.conclusion }}
97+
steps:
98+
- name: Checkout repo
99+
uses: actions/checkout@v4
100+
101+
- name: Action-Test
102+
uses: ./
103+
id: action-test
104+
with:
105+
Path: tests/outputTestRepo/outputs/modules/PSModuleTest
106+
Settings: Module
107+
108+
- name: Status
109+
shell: pwsh
110+
run: |
111+
Write-Host "Outcome: ${{ steps.action-test.outcome }}"
112+
Write-Host "Conclusion: ${{ steps.action-test.conclusion }}"
113+
114+
CatchJob:
115+
name: Aggregate Status
116+
needs:
117+
- ActionTestSrcSourceCode
118+
- ActionTestSrcCustom
119+
- ActionTestSrcWithManifest
120+
- ActionTestOutputs
121+
if: always()
122+
runs-on: ubuntu-latest
123+
env:
124+
ActionTestSrcSourceCodeOutcome: ${{ needs.ActionTestSrcSourceCode.outputs.Outcome }}
125+
ActionTestSrcSourceCodeConclusion: ${{ needs.ActionTestSrcSourceCode.outputs.Conclusion }}
126+
ActionTestSrcCustomOutcome: ${{ needs.ActionTestSrcCustom.outputs.Outcome }}
127+
ActionTestSrcCustomConclusion: ${{ needs.ActionTestSrcCustom.outputs.Conclusion }}
128+
ActionTestSrcWithManifestOutcome: ${{ needs.ActionTestSrcWithManifest.outputs.Outcome }}
129+
ActionTestSrcWithManifestConclusion: ${{ needs.ActionTestSrcWithManifest.outputs.Conclusion }}
130+
ActionTestOutputsOutcome: ${{ needs.ActionTestOutputs.outputs.Outcome }}
131+
ActionTestOutputsConclusion: ${{ needs.ActionTestOutputs.outputs.Conclusion }}
132+
steps:
133+
- name: Aggregated Status
134+
uses: PSModule/Github-Script@v1
135+
with:
136+
Script: |
137+
Install-PSResource -Name Markdown -Repository PSGallery -TrustRepository
138+
139+
# Build an array of objects for each job
140+
$ActionTestSrcSourceCodeExpectedOutcome = 'success'
141+
$ActionTestSrcSourceCodeOutcomeResult = $env:ActionTestSrcSourceCodeOutcome -eq $ActionTestSrcSourceCodeExpectedOutcome
142+
$ActionTestSrcSourceCodeExpectedConclusion = 'success'
143+
$ActionTestSrcSourceCodeConclusionResult = $env:ActionTestSrcSourceCodeConclusion -eq $ActionTestSrcSourceCodeExpectedConclusion
144+
145+
$ActionTestSrcCustomExpectedOutcome = 'success'
146+
$ActionTestSrcCustomOutcomeResult = $env:ActionTestSrcCustomOutcome -eq $ActionTestSrcCustomExpectedOutcome
147+
$ActionTestSrcCustomExpectedConclusion = 'success'
148+
$ActionTestSrcCustomConclusionResult = $env:ActionTestSrcCustomConclusion -eq $ActionTestSrcCustomExpectedConclusion
149+
150+
$ActionTestSrcWithManifestExpectedOutcome = 'failure'
151+
$ActionTestSrcWithManifestOutcomeResult = $env:ActionTestSrcWithManifestOutcome -eq $ActionTestSrcWithManifestExpectedOutcome
152+
$ActionTestSrcWithManifestExpectedConclusion = 'success'
153+
$ActionTestSrcWithManifestConclusionResult = $env:ActionTestSrcWithManifestConclusion -eq $ActionTestSrcWithManifestExpectedConclusion
154+
155+
$ActionTestOutputsExpectedOutcome = 'success'
156+
$ActionTestOutputsOutcomeResult = $env:ActionTestOutputsOutcome -eq $ActionTestOutputsExpectedOutcome
157+
$ActionTestOutputsExpectedConclusion = 'success'
158+
$ActionTestOutputsConclusionResult = $env:ActionTestOutputsConclusion -eq $ActionTestOutputsExpectedConclusion
159+
160+
$jobs = @(
161+
[PSCustomObject]@{
162+
Name = 'Action-Test - [Src-SourceCode]'
163+
Outcome = $env:ActionTestSrcSourceCodeOutcome
164+
ExpectedOutcome = $ActionTestSrcSourceCodeExpectedOutcome
165+
PassedOutcome = $ActionTestSrcSourceCodeOutcomeResult
166+
Conclusion = $env:ActionTestSrcSourceCodeConclusion
167+
ExpectedConclusion = $ActionTestSrcSourceCodeExpectedConclusion
168+
PassedConclusion = $ActionTestSrcSourceCodeConclusionResult
169+
},
170+
[PSCustomObject]@{
171+
Name = 'Action-Test - [Src-Custom]'
172+
Outcome = $env:ActionTestSrcCustomOutcome
173+
ExpectedOutcome = $ActionTestSrcCustomExpectedOutcome
174+
PassedOutcome = $ActionTestSrcCustomOutcomeResult
175+
Conclusion = $env:ActionTestSrcCustomConclusion
176+
ExpectedConclusion = $ActionTestSrcCustomExpectedConclusion
177+
PassedConclusion = $ActionTestSrcCustomConclusionResult
178+
},
179+
[PSCustomObject]@{
180+
Name = 'Action-Test - [Src-WithManifest]'
181+
Outcome = $env:ActionTestSrcWithManifestOutcome
182+
ExpectedOutcome = $ActionTestSrcWithManifestExpectedOutcome
183+
PassedOutcome = $ActionTestSrcWithManifestOutcomeResult
184+
Conclusion = $env:ActionTestSrcWithManifestConclusion
185+
ExpectedConclusion = $ActionTestSrcWithManifestExpectedConclusion
186+
PassedConclusion = $ActionTestSrcWithManifestConclusionResult
187+
},
188+
[PSCustomObject]@{
189+
Name = 'Action-Test - [outputs]'
190+
Outcome = $env:ActionTestOutputsOutcome
191+
ExpectedOutcome = $ActionTestOutputsExpectedOutcome
192+
PassedOutcome = $ActionTestOutputsOutcomeResult
193+
Conclusion = $env:ActionTestOutputsConclusion
194+
ExpectedConclusion = $ActionTestOutputsExpectedConclusion
195+
PassedConclusion = $ActionTestOutputsConclusionResult
196+
}
197+
)
198+
199+
# Display the table in the workflow logs
200+
$jobs | Format-List
201+
202+
$passed = $true
203+
$jobs | ForEach-Object {
204+
if (-not $_.PassedOutcome) {
205+
Write-Error "Job $($_.Name) failed with Outcome $($_.Outcome) and Expected Outcome $($_.ExpectedOutcome)"
206+
$passed = $false
207+
}
208+
209+
if (-not $_.PassedConclusion) {
210+
Write-Error "Job $($_.Name) failed with Conclusion $($_.Conclusion) and Expected Conclusion $($_.ExpectedConclusion)"
211+
$passed = $false
212+
}
213+
}
214+
215+
$icon = if ($passed) { '✅' } else { '❌' }
216+
$status = Heading 1 "$icon - GitHub Actions Status" {
217+
Table {
218+
$jobs
219+
}
220+
}
221+
222+
Set-GitHubStepSummary -Summary $status
223+
224+
if (-not $passed) {
225+
Write-GitHubError 'One or more jobs failed'
226+
exit 1
227+
}
228+

.github/workflows/ActionTestWorkflow.yml

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

.github/workflows/Linter.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,4 @@ jobs:
3030
VALIDATE_JSON_PRETTIER: false
3131
VALIDATE_MARKDOWN_PRETTIER: false
3232
VALIDATE_YAML_PRETTIER: false
33+
FILTER_REGEX_EXCLUDE: '.*Set-PSModuleTest\.ps1$'

0 commit comments

Comments
 (0)