MegaBites-AI/Windows-powershell
0372
1name: macOS-CI2 3run-name: "${{ github.ref_name }} - ${{ github.run_number }}"4 5on:6 push:7 branches:8 - master9 - release/**10 - github-mirror11 paths:12 - "**"13 - "*"14 - ".globalconfig"15 - "!.github/ISSUE_TEMPLATE/**"16 - "!.dependabot/config.yml"17 - "!.pipelines/**"18 - "!test/perf/**"19 pull_request:20 branches:21 - master22 - release/**23 - github-mirror24 - "*-feature"25# Path filters for PRs need to go into the changes job26 27concurrency:28 group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}29 cancel-in-progress: ${{ contains(github.ref, 'merge')}}30 31env:32 DOTNET_CLI_TELEMETRY_OPTOUT: 133 DOTNET_NOLOGO: 134 FORCE_FEATURE: 'False'35 FORCE_PACKAGE: 'False'36 HOMEBREW_NO_ANALYTICS: 137 NUGET_KEY: none38 POWERSHELL_TELEMETRY_OPTOUT: 139 __SuppressAnsiEscapeSequences: 140 nugetMultiFeedWarnLevel: none41 system_debug: 'false'42 43jobs:44 changes:45 name: Change Detection46 runs-on: ubuntu-latest47 if: startsWith(github.repository_owner, 'azure') || github.repository_owner == 'PowerShell'48 # Required permissions49 permissions:50 pull-requests: read51 contents: read52 53 # Set job outputs to values from filter step54 outputs:55 source: ${{ steps.filter.outputs.source }}56 buildModuleChanged: ${{ steps.filter.outputs.buildModuleChanged }}57 packagingChanged: ${{ steps.filter.outputs.packagingChanged }}58 steps:59 - name: checkout60 uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.261 62 - name: Change Detection63 id: filter64 uses: "./.github/actions/infrastructure/path-filters"65 with:66 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}67 68 ci_build:69 name: Build PowerShell70 runs-on: macos-15-large71 needs: changes72 if: ${{ needs.changes.outputs.source == 'true' || needs.changes.outputs.buildModuleChanged == 'true' }}73 steps:74 - name: checkout75 uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.276 with:77 fetch-depth: 100078 - name: Build79 uses: "./.github/actions/build/ci"80 macos_test_unelevated_ci:81 name: macos Unelevated CI82 needs:83 - ci_build84 - changes85 if: ${{ needs.changes.outputs.source == 'true' || needs.changes.outputs.buildModuleChanged == 'true' }}86 runs-on: macos-15-large87 steps:88 - name: checkout89 uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.290 with:91 fetch-depth: 100092 - name: macOS Unelevated CI93 uses: "./.github/actions/test/nix"94 with:95 purpose: UnelevatedPesterTests96 tagSet: CI97 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}98 macos_test_elevated_ci:99 name: macOS Elevated CI100 needs:101 - ci_build102 - changes103 if: ${{ needs.changes.outputs.source == 'true' || needs.changes.outputs.buildModuleChanged == 'true' }}104 runs-on: macos-15-large105 steps:106 - name: checkout107 uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2108 with:109 fetch-depth: 1000110 - name: macOS Elevated CI111 uses: "./.github/actions/test/nix"112 with:113 purpose: ElevatedPesterTests114 tagSet: CI115 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}116 macos_test_unelevated_others:117 name: macOS Unelevated Others118 needs:119 - ci_build120 - changes121 if: ${{ needs.changes.outputs.source == 'true' || needs.changes.outputs.buildModuleChanged == 'true' }}122 runs-on: macos-15-large123 steps:124 - name: checkout125 uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2126 with:127 fetch-depth: 1000128 - name: macOS Unelevated Others129 uses: "./.github/actions/test/nix"130 with:131 purpose: UnelevatedPesterTests132 tagSet: Others133 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}134 macos_test_elevated_others:135 name: macOS Elevated Others136 needs:137 - ci_build138 - changes139 if: ${{ needs.changes.outputs.source == 'true' || needs.changes.outputs.buildModuleChanged == 'true' }}140 runs-on: macos-15-large141 steps:142 - name: checkout143 uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2144 with:145 fetch-depth: 1000146 - name: macOS Elevated Others147 uses: "./.github/actions/test/nix"148 with:149 purpose: ElevatedPesterTests150 tagSet: Others151 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}152 xunit_tests:153 name: xUnit Tests154 needs:155 - changes156 if: ${{ needs.changes.outputs.source == 'true' || needs.changes.outputs.buildModuleChanged == 'true' }}157 uses: ./.github/workflows/xunit-tests.yml158 with:159 runner_os: macos-15-large160 test_results_artifact_name: testResults-xunit161 PackageMac-macos_packaging:162 name: macOS packaging and testing163 needs:164 - changes165 if: ${{ needs.changes.outputs.packagingChanged == 'true' }}166 runs-on:167 - macos-15-large168 steps:169 - name: checkout170 uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2171 with:172 fetch-depth: 1000173 - uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5.2.0174 with:175 global-json-file: ./global.json176 - name: Bootstrap packaging177 if: success()178 run: |-179 import-module ./build.psm1180 start-psbootstrap -Scenario package181 shell: pwsh182 - name: Build PowerShell and Create macOS package183 if: success()184 run: |-185 import-module ./build.psm1186 import-module ./tools/ci.psm1187 import-module ./tools/packaging/packaging.psm1188 Switch-PSNugetConfig -Source Public189 Sync-PSTags -AddRemoteIfMissing190 $releaseTag = Get-ReleaseTag191 Start-PSBuild -Configuration Release -PSModuleRestore -ReleaseTag $releaseTag192 $macOSRuntime = if ([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture -eq 'Arm64') { 'osx-arm64' } else { 'osx-x64' }193 Start-PSPackage -Type osxpkg -ReleaseTag $releaseTag -MacOSRuntime $macOSRuntime -SkipReleaseChecks194 shell: pwsh195 196 - name: Install Pester197 if: success()198 run: |-199 Import-Module ./tools/ci.psm1200 Install-CIPester201 shell: pwsh202 203 - name: Test package contents204 if: success()205 run: |-206 $env:PACKAGE_FOLDER = Get-Location207 $testResultsPath = Join-Path $env:RUNNER_WORKSPACE "testResults"208 if (-not (Test-Path $testResultsPath)) {209 New-Item -ItemType Directory -Path $testResultsPath -Force | Out-Null210 }211 Import-Module Pester212 $pesterConfig = New-PesterConfiguration213 $pesterConfig.Run.Path = './test/packaging/macos/package-validation.tests.ps1'214 $pesterConfig.Run.PassThru = $true215 $pesterConfig.Output.Verbosity = 'Detailed'216 $pesterConfig.TestResult.Enabled = $true217 $pesterConfig.TestResult.OutputFormat = 'NUnitXml'218 $pesterConfig.TestResult.OutputPath = Join-Path $testResultsPath "macOSPackage.xml"219 $result = Invoke-Pester -Configuration $pesterConfig220 if ($result.FailedCount -gt 0) {221 throw "Package validation failed with $($result.FailedCount) failed test(s)"222 }223 shell: pwsh224 - name: Publish and Upload Pester Test Results225 if: always()226 uses: "./.github/actions/test/process-pester-results"227 with:228 name: "macOSPackage"229 testResultsFolder: "${{ runner.workspace }}/testResults"230 - name: Upload package artifact231 if: always()232 uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0233 with:234 name: macos-package235 path: "*.pkg"236 ready_to_merge:237 name: macos ready to merge238 needs:239 - xunit_tests240 - PackageMac-macos_packaging241 - macos_test_elevated_ci242 - macos_test_elevated_others243 - macos_test_unelevated_ci244 - macos_test_unelevated_others245 if: always()246 uses: PowerShell/compliance/.github/workflows/ready-to-merge.yml@c8b3ad5819ad7078f3e375519b4f8c6232d1cbdf # v1.0.0247 with:248 needs_context: ${{ toJson(needs) }}249 