-
Notifications
You must be signed in to change notification settings - Fork 144
212 lines (173 loc) · 8.24 KB
/
Copy pathprobe-winget-arm64.yml
File metadata and controls
212 lines (173 loc) · 8.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
name: Probe WinGet ARM64 Store Download
on:
workflow_dispatch:
push:
branches:
- codex/probe-winget-arm64
permissions:
contents: read
jobs:
probe:
name: Probe WinGet ARM64 download
runs-on: windows-latest
timeout-minutes: 45
steps:
- uses: actions/checkout@v6
- name: Download Codex ARM64 via WinGet
id: winget
shell: pwsh
run: |
$ErrorActionPreference = "Continue"
$ProgressPreference = "SilentlyContinue"
New-Item -ItemType Directory -Force -Path winget-output, winget-logs | Out-Null
$outputDir = (Resolve-Path "winget-output").Path
$logDir = (Resolve-Path "winget-logs").Path
$resultPath = Join-Path $logDir "result.txt"
"timestamp=$((Get-Date).ToUniversalTime().ToString("o"))" | Set-Content -Encoding utf8 -Path $resultPath
"runner_os=$env:RUNNER_OS" | Add-Content -Encoding utf8 -Path $resultPath
"processor_architecture=$env:PROCESSOR_ARCHITECTURE" | Add-Content -Encoding utf8 -Path $resultPath
$wingetCommand = Get-Command winget -ErrorAction SilentlyContinue
if (-not $wingetCommand) {
"winget_available=false" | Add-Content -Encoding utf8 -Path $resultPath
"exitCode=127" | Add-Content -Encoding utf8 -Path $resultPath
"arm64PackageCount=0" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
exit 0
}
"winget_available=true" | Add-Content -Encoding utf8 -Path $resultPath
$wingetCommand | Format-List * | Out-File -Encoding utf8 -FilePath (Join-Path $logDir "winget-command.txt")
function Write-ProbeLog {
param(
[Parameter(Mandatory = $true)]
[string] $Path,
[Parameter(Mandatory = $true)]
[string] $Message
)
$Message | Add-Content -Encoding utf8 -Path $Path
Write-Host $Message
}
function Invoke-WinGetLogged {
param(
[Parameter(Mandatory = $true)]
[string[]] $Arguments,
[Parameter(Mandatory = $true)]
[string] $LogName,
[Parameter(Mandatory = $true)]
[int] $TimeoutSeconds
)
$logPath = Join-Path $logDir $LogName
$startedAt = Get-Date
Write-ProbeLog -Path $logPath -Message "command=winget $($Arguments -join ' ')"
Write-ProbeLog -Path $logPath -Message "startedAt=$($startedAt.ToUniversalTime().ToString("o"))"
Write-ProbeLog -Path $logPath -Message "timeoutSeconds=$TimeoutSeconds"
try {
$startInfo = [System.Diagnostics.ProcessStartInfo]::new()
$startInfo.FileName = $wingetCommand.Source
foreach ($argument in $Arguments) {
[void] $startInfo.ArgumentList.Add($argument)
}
$startInfo.RedirectStandardOutput = $true
$startInfo.RedirectStandardError = $true
$startInfo.UseShellExecute = $false
$startInfo.CreateNoWindow = $true
$process = [System.Diagnostics.Process]::new()
$process.StartInfo = $startInfo
[void] $process.Start()
$stdoutTask = $process.StandardOutput.ReadToEndAsync()
$stderrTask = $process.StandardError.ReadToEndAsync()
$timedOut = -not $process.WaitForExit($TimeoutSeconds * 1000)
if ($timedOut) {
Write-ProbeLog -Path $logPath -Message "timedOut=true"
try {
$process.Kill($true)
} catch {
Write-ProbeLog -Path $logPath -Message "killException=$($_.Exception.Message)"
}
$process.WaitForExit()
}
$stdout = $stdoutTask.GetAwaiter().GetResult()
$stderr = $stderrTask.GetAwaiter().GetResult()
if (-not [string]::IsNullOrEmpty($stdout)) {
Write-ProbeLog -Path $logPath -Message "stdout:"
Write-ProbeLog -Path $logPath -Message $stdout
}
if (-not [string]::IsNullOrEmpty($stderr)) {
Write-ProbeLog -Path $logPath -Message "stderr:"
Write-ProbeLog -Path $logPath -Message $stderr
}
$elapsedSeconds = [int] ((Get-Date) - $startedAt).TotalSeconds
Write-ProbeLog -Path $logPath -Message "elapsedSeconds=$elapsedSeconds"
if ($timedOut) {
Write-ProbeLog -Path $logPath -Message "exitCode=124"
return 124
}
Write-ProbeLog -Path $logPath -Message "exitCode=$($process.ExitCode)"
return $process.ExitCode
} catch {
Write-ProbeLog -Path $logPath -Message "exception=$($_.Exception.Message)"
return 125
}
}
$infoExitCode = Invoke-WinGetLogged -Arguments @("--info") -LogName "winget-info.log" -TimeoutSeconds 60
"infoExitCode=$infoExitCode" | Add-Content -Encoding utf8 -Path $resultPath
$sourceListExitCode = Invoke-WinGetLogged -Arguments @("source", "list") -LogName "winget-source-list.log" -TimeoutSeconds 120
"sourceListExitCode=$sourceListExitCode" | Add-Content -Encoding utf8 -Path $resultPath
$sourceUpdateExitCode = Invoke-WinGetLogged -Arguments @("source", "update") -LogName "winget-source-update.log" -TimeoutSeconds 180
"sourceUpdateExitCode=$sourceUpdateExitCode" | Add-Content -Encoding utf8 -Path $resultPath
$downloadArgs = @(
"download",
"--id", "9PLM9XGG6VKS",
"--source", "msstore",
"--architecture", "arm64",
"--platform", "Windows.Desktop",
"--skip-license",
"--accept-source-agreements",
"--accept-package-agreements",
"--verbose-logs",
"--download-directory", $outputDir
)
"winget $($downloadArgs -join ' ')" |
Set-Content -Encoding utf8 -Path (Join-Path $logDir "winget-download-command.txt")
$downloadExitCode = Invoke-WinGetLogged -Arguments $downloadArgs -LogName "winget-download-arm64.log" -TimeoutSeconds 600
"exitCode=$downloadExitCode" | Add-Content -Encoding utf8 -Path $resultPath
$files = @(Get-ChildItem -LiteralPath $outputDir -Recurse -File -ErrorAction SilentlyContinue)
$files |
Select-Object FullName, Name, Length, LastWriteTimeUtc |
ConvertTo-Json -Depth 3 |
Set-Content -Encoding utf8 -Path (Join-Path $logDir "downloaded-files.json")
if ($files.Count -gt 0) {
Get-FileHash -Algorithm SHA256 -LiteralPath $files.FullName |
Select-Object Algorithm, Hash, Path |
ConvertTo-Json -Depth 3 |
Set-Content -Encoding utf8 -Path (Join-Path $logDir "downloaded-file-hashes.json")
}
$arm64Packages = @(
$files | Where-Object {
$_.Name -match '^OpenAI\.Codex_.*_arm64__.*\.(Msix|msix|Appx|appx|MsixBundle|msixbundle|AppxBundle|appxbundle)$'
}
)
"arm64PackageCount=$($arm64Packages.Count)" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
"arm64PackageCount=$($arm64Packages.Count)" | Add-Content -Encoding utf8 -Path $resultPath
if ($arm64Packages.Count -gt 0) {
"arm64Packages=$($arm64Packages.Name -join ',')" | Add-Content -Encoding utf8 -Path $resultPath
}
exit 0
- name: Upload WinGet probe logs
if: always()
uses: actions/upload-artifact@v7
with:
name: winget-arm64-probe-logs
path: winget-logs
if-no-files-found: warn
- name: Fail when ARM64 package was not downloaded
if: always()
shell: pwsh
run: |
$resultPath = "winget-logs/result.txt"
if (Test-Path -LiteralPath $resultPath) {
Get-Content -LiteralPath $resultPath
}
if ("${{ steps.winget.outputs.arm64PackageCount }}" -ne "0") {
exit 0
}
Write-Error "WinGet did not download an OpenAI Codex ARM64 Store package."
exit 1