MegaBites-AI/Windows-powershell
0372
1name: nix_test2description: 'Test PowerShell on non-Windows platforms'3 4inputs:5 purpose:6 required: false7 default: ''8 type: string9 tagSet:10 required: false11 default: CI12 type: string13 ctrfFolder:14 required: false15 default: ctrf16 type: string17 GITHUB_TOKEN:18 description: 'GitHub token for API authentication'19 required: true20 21runs:22 using: composite23 steps:24 - name: Capture Environment25 if: success() || failure()26 run: |-27 Import-Module ./tools/ci.psm128 Show-Environment29 shell: pwsh30 31 - name: Download Build Artifacts32 uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.033 with:34 path: "${{ github.workspace }}"35 36 - name: Capture Artifacts Directory37 continue-on-error: true38 run: |-39 Import-Module ./build.psm140 Write-LogGroupStart -Title 'Artifacts Directory'41 Get-ChildItem "${{ github.workspace }}/build/*" -Recurse42 Write-LogGroupEnd -Title 'Artifacts Directory'43 shell: pwsh44 45 - uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 # v4.3.146 with:47 global-json-file: ./global.json48 49 - name: Set Package Name by Platform50 id: set_package_name51 shell: pwsh52 run: |-53 Import-Module ./.github/workflows/GHWorkflowHelper/GHWorkflowHelper.psm154 $platform = $env:RUNNER_OS55 Write-Host "Runner platform: $platform"56 if ($platform -eq 'Linux') {57 $packageName = 'DSC-*-x86_64-linux.tar.gz'58 } elseif ($platform -eq 'macOS') {59 $packageName = 'DSC-*-x86_64-apple-darwin.tar.gz'60 } else {61 throw "Unsupported platform: $platform"62 }63 64 Set-GWVariable -Name "DSC_PACKAGE_NAME" -Value $packageName65 66 - name: Get Latest DSC Package Version67 shell: pwsh68 run: |-69 Import-Module ./.github/workflows/GHWorkflowHelper/GHWorkflowHelper.psm170 $headers = @{71 Authorization = "Bearer ${{ inputs.GITHUB_TOKEN }}"72 }73 $releases = Invoke-RestMethod -Uri "https://api.github.com/repos/PowerShell/Dsc/releases" -Headers $headers74 $latestRelease = $releases | Where-Object { $v = $_.name.trim("v"); $semVer = [System.Management.Automation.SemanticVersion]::new($v); if ($semVer.Major -eq 3 -and $semVer.Minor -ge 2) { $_ } } | Select-Object -First 175 $latestVersion = $latestRelease.tag_name.TrimStart("v")76 Write-Host "Latest DSC Version: $latestVersion"77 78 $packageName = "$env:DSC_PACKAGE_NAME"79 80 Write-Host "Package Name: $packageName"81 82 $downloadUrl = $latestRelease.assets | Where-Object { $_.name -like "*$packageName*" } | Select-Object -First 1 | Select-Object -ExpandProperty browser_download_url83 Write-Host "Download URL: $downloadUrl"84 85 $tempPath = Get-GWTempPath86 87 Invoke-RestMethod -Uri $downloadUrl -OutFile "$tempPath/DSC.tar.gz" -Verbose -Headers $headers88 New-Item -ItemType Directory -Path "$tempPath/DSC" -Force -Verbose89 tar xvf "$tempPath/DSC.tar.gz" -C "$tempPath/DSC"90 $dscRoot = "$tempPath/DSC"91 Write-Host "DSC Root: $dscRoot"92 Set-GWVariable -Name "DSC_ROOT" -Value $dscRoot93 94 - name: Bootstrap95 shell: pwsh96 run: |-97 Import-Module ./build.psm198 Write-LogGroupStart -Title 'Bootstrap'99 Import-Module ./tools/ci.psm1100 Invoke-CIInstall -SkipUser101 Write-LogGroupEnd -Title 'Bootstrap'102 103 - name: Extract Files104 uses: actions/github-script@e69ef5462fd455e02edcaf4dd7708eda96b9eda0 # v7.0.0105 env:106 DESTINATION_FOLDER: "${{ github.workspace }}/bins"107 ARCHIVE_FILE_PATTERNS: "${{ github.workspace }}/build/build.zip"108 with:109 script: |-110 const fs = require('fs').promises111 const path = require('path')112 const target = path.resolve(process.env.DESTINATION_FOLDER)113 const patterns = process.env.ARCHIVE_FILE_PATTERNS114 const globber = await glob.create(patterns)115 await io.mkdirP(path.dirname(target))116 for await (const file of globber.globGenerator()) {117 if ((await fs.lstat(file)).isDirectory()) continue118 await exec.exec(`7z x ${file} -o${target} -aoa`)119 }120 121 - name: Fix permissions122 continue-on-error: true123 run: |-124 find "${{ github.workspace }}/bins" -type d -exec chmod +rwx {} \;125 find "${{ github.workspace }}/bins" -type f -exec chmod +rw {} \;126 shell: bash127 128 - name: Capture Extracted Build ZIP129 continue-on-error: true130 run: |-131 Import-Module ./build.psm1132 Write-LogGroupStart -Title 'Extracted Build ZIP'133 Get-ChildItem "${{ github.workspace }}/bins/*" -Recurse -ErrorAction SilentlyContinue134 Write-LogGroupEnd -Title 'Extracted Build ZIP'135 shell: pwsh136 137 - name: Test138 if: success()139 run: |-140 Import-Module ./tools/ci.psm1141 Restore-PSOptions -PSOptionsPath '${{ github.workspace }}/build/psoptions.json'142 $options = (Get-PSOptions)143 $rootPath = '${{ github.workspace }}/bins'144 $originalRootPath = Split-Path -path $options.Output145 $path = Join-Path -path $rootPath -ChildPath (split-path -leaf -path $originalRootPath)146 $pwshPath = Join-Path -path $path -ChildPath 'pwsh'147 chmod a+x $pwshPath148 $options.Output = $pwshPath149 Set-PSOptions $options150 Invoke-CITest -Purpose '${{ inputs.purpose }}' -TagSet '${{ inputs.tagSet }}' -TitlePrefix '${{ inputs.buildName }}' -OutputFormat NUnitXml151 shell: pwsh152 153 - name: Convert, Publish, and Upload Pester Test Results154 uses: "./.github/actions/test/process-pester-results"155 with:156 name: "${{ inputs.purpose }}-${{ inputs.tagSet }}"157 testResultsFolder: "${{ runner.workspace }}/testResults"158 ctrfFolder: "${{ inputs.ctrfFolder }}"159 