|
| 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 | +
|
0 commit comments