@@ -49,3 +49,118 @@ jobs:
4949 TestType : outputs
5050 Path : tests/outputTestRepo/outputs/modules/PSModuleTest
5151 Settings : Module
52+
53+
54+ CatchJob :
55+ name : " Catch Job - Aggregate Status"
56+ needs :
57+ - ActionTestSrcSourceCode
58+ - ActionTestSrcCustom
59+ - ActionTestSrcWithManifest
60+ - ActionTestOutputs
61+ if : always()
62+ runs-on : ubuntu-latest
63+ steps :
64+ - name : Display Aggregated Results as a Table
65+ uses : PSModule/Github-Script@v1
66+ with :
67+ Script : |
68+ Install-PSResource -Name Markdown -Repository PSGallery -TrustRepository
69+
70+ # Build an array of objects for each job
71+ $ActionTestSrcSourceCodeOutcome = ${{ needs.ActionTestSrcSourceCode.outputs.Outcome }}
72+ $ActionTestSrcSourceCodeExpectedOutcome = "success"
73+ $ActionTestSrcSourceCodeOutcomeResult = $ActionTestSrcSourceCodeOutcome -eq $ActionTestSrcSourceCodeExpectedOutcome
74+ $ActionTestSrcSourceCodeConclusion = ${{ needs.ActionTestSrcSourceCode.outputs.Conclusion }}
75+ $ActionTestSrcSourceCodeExpectedConclusion = "success"
76+ $ActionTestSrcSourceCodeConclusionResult = $ActionTestSrcSourceCodeConclusion -eq $ActionTestSrcSourceCodeExpectedConclusion
77+
78+ $ActionTestSrcCustomOutcome = ${{ needs.ActionTestSrcCustom.outputs.Outcome }}
79+ $ActionTestSrcCustomExpectedOutcome = "success"
80+ $ActionTestSrcCustomOutcomeResult = $ActionTestSrcCustomOutcome -eq $ActionTestSrcCustomExpectedOutcome
81+ $ActionTestSrcCustomConclusion = ${{ needs.ActionTestSrcCustom.outputs.Conclusion }}
82+ $ActionTestSrcCustomExpectedConclusion = "success"
83+ $ActionTestSrcCustomConclusionResult = $ActionTestSrcCustomConclusion -eq $ActionTestSrcCustomExpectedConclusion
84+
85+ $ActionTestSrcWithManifestOutcome = ${{ needs.ActionTestSrcWithManifest.outputs.Outcome }}
86+ $ActionTestSrcWithManifestExpectedOutcome = "failure"
87+ $ActionTestSrcWithManifestOutcomeResult = $ActionTestSrcWithManifestOutcome -eq $ActionTestSrcWithManifestExpectedOutcome
88+ $ActionTestSrcWithManifestConclusion = ${{ needs.ActionTestSrcWithManifest.outputs.Conclusion }}
89+ $ActionTestSrcWithManifestExpectedConclusion = "success"
90+ $ActionTestSrcWithManifestConclusionResult = $ActionTestSrcWithManifestConclusion -eq $ActionTestSrcWithManifestExpectedConclusion
91+
92+ $ActionTestOutputsOutcome = ${{ needs.ActionTestOutputs.outputs.Outcome }}
93+ $ActionTestOutputsExpectedOutcome = "success"
94+ $ActionTestOutputsOutcomeResult = $ActionTestOutputsOutcome -eq $ActionTestOutputsExpectedOutcome
95+ $ActionTestOutputsConclusion = ${{ needs.ActionTestOutputs.outputs.Conclusion }}
96+ $ActionTestOutputsExpectedConclusion = "success"
97+ $ActionTestOutputsConclusionResult = $ActionTestOutputsConclusion -eq $ActionTestOutputsExpectedConclusion
98+
99+ $jobs = @(
100+ [PSCustomObject]@{
101+ Name = "Action-Test - [Src-SourceCode]"
102+ Outcome = $ActionTestSrcSourceCodeOutcome
103+ ExpectedOutcome = $ActionTestSrcSourceCodeExpectedOutcome
104+ PassedOutcome = $ActionTestSrcSourceCodeOutcomeResult
105+ Conclusion = $ActionTestSrcSourceCodeConclusion
106+ ExpectedConclusion = $ActionTestSrcSourceCodeExpectedConclusion
107+ PassedConclusion = $ActionTestSrcSourceCodeConclusionResult
108+ },
109+ [PSCustomObject]@{
110+ Name = "Action-Test - [Src-Custom]"
111+ Outcome = $ActionTestSrcCustomOutcome
112+ ExpectedOutcome = $ActionTestSrcCustomExpectedOutcome
113+ PassedOutcome = $ActionTestSrcCustomOutcomeResult
114+ Conclusion = $ActionTestSrcCustomConclusion
115+ ExpectedConclusion = $ActionTestSrcCustomExpectedConclusion
116+ PassedConclusion = $ActionTestSrcCustomConclusionResult
117+ },
118+ [PSCustomObject]@{
119+ Name = "Action-Test - [Src-WithManifest]"
120+ Outcome = $ActionTestSrcWithManifestOutcome
121+ ExpectedOutcome = $ActionTestSrcWithManifestExpectedOutcome
122+ PassedOutcome = $ActionTestSrcWithManifestOutcomeResult
123+ Conclusion = $ActionTestSrcWithManifestConclusion
124+ ExpectedConclusion = $ActionTestSrcWithManifestExpectedConclusion
125+ PassedConclusion = $ActionTestSrcWithManifestConclusionResult
126+ },
127+ [PSCustomObject]@{
128+ Name = "Action-Test - [outputs]"
129+ Outcome = $ActionTestOutputsOutcome
130+ ExpectedOutcome = $ActionTestOutputsExpectedOutcome
131+ PassedOutcome = $ActionTestOutputsOutcomeResult
132+ Conclusion = $ActionTestOutputsConclusion
133+ ExpectedConclusion = $ActionTestOutputsExpectedConclusion
134+ PassedConclusion = $ActionTestOutputsConclusionResult
135+ }
136+ )
137+
138+ # Display the table in the workflow logs
139+ $jobs | Format-List
140+
141+ $passed = $true
142+ $jobs | ForEach-Object {
143+ if (-not $_.PassedOutcome) {
144+ Write-Error "Job $($_.Name) failed with Outcome $($_.Outcome) and Expected Outcome $($_.ExpectedOutcome)"
145+ $passed = $false
146+ }
147+
148+ if (-not $_.PassedConclusion) {
149+ Write-Error "Job $($_.Name) failed with Conclusion $($_.Conclusion) and Expected Conclusion $($_.ExpectedConclusion)"
150+ $passed = $false
151+ }
152+ }
153+
154+ $icon = if ($passed) { '✅' } else { '❌' }
155+ $status = Heading 1 "$icon - GitHub Actions Status" {
156+ Table {
157+ $jobs
158+ }
159+ }
160+
161+ Set-GitHubStepSummary -Summary $status
162+
163+ if (-not $passed) {
164+ Write-GithubError "One or more jobs failed"
165+ exit 1
166+ }
0 commit comments