From 1e0896ae866e0b9a186b7ddf778e7b9c7cfabe01 Mon Sep 17 00:00:00 2001 From: Leo Fang Date: Mon, 25 Nov 2024 05:19:40 +0000 Subject: [PATCH] improve gh path handling; fix cl version check; fix pytest_tests; fix emptu output param --- .github/workflows/windows.yml | 9 +++++---- .pfnci/windows/GHA-test.ps1 | 16 +++++++++------- .pfnci/windows/_error_handler.ps1 | 5 +++-- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 11f3798fd05..443d1743fc6 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -45,9 +45,11 @@ jobs: run: | Invoke-WebRequest -Uri "$env:GH_MSI_URL" -OutFile "gh_installer.msi" Start-Process msiexec.exe -Wait -Verbose -ArgumentList '/i "gh_installer.msi" /qn' - $env:GH_POSSIBLE_PATHS = "C:\\Program Files\\GitHub CLI;C:\\Program Files (x86)\\GitHub CLI" - echo "GH_POSSIBLE_PATHS=$env:GH_POSSIBLE_PATHS" >> $env:GITHUB_ENV - $env:Path += ";$env:GH_POSSIBLE_PATHS" + $GH_POSSIBLE_PATHS = "C:\\Program Files\\GitHub CLI", "C:\\Program Files (x86)\\GitHub CLI" + foreach ($p in $GH_POSSIBLE_PATHS) { + echo "$p" >> $env:GITHUB_PATH + $env:Path += ";$p" + } gh --version - name: Check system @@ -139,7 +141,6 @@ jobs: # TODO: this is dangerous because we're overwriting the global GHA cache! # We should have another workflow that updates the global cache upon PR merge. - $env:Path += ";$env:GH_POSSIBLE_PATHS" if ((gh cache list | Select-String -Pattern ${{ env.CACHE_KEY }}).Count -eq 1) { gh cache delete ${{ env.CACHE_KEY }} } diff --git a/.pfnci/windows/GHA-test.ps1 b/.pfnci/windows/GHA-test.ps1 index dd9e0b8070b..a9dacab820a 100644 --- a/.pfnci/windows/GHA-test.ps1 +++ b/.pfnci/windows/GHA-test.ps1 @@ -23,11 +23,13 @@ function FindAndCheckMSVC { -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 ` -property installationPath $clPath = Join-Path $vsPath "VC\Tools\MSVC\*\bin\Hostx64\x64\cl.exe" - $clPath = Get-ChildItem $clPath - - $CL_VERSION_STRING = & $clPath /? - if ($CL_VERSION_STRING -match "Version (\d+\.\d+)\.\d+") { - $CL_VERSION = [version]$matches[1] + $clPath = (Get-ChildItem $clPath).FullName + echo "found cl.exe: $clPath" + # For some reason below just doesn't work in the CI... + Start-Process -NoNewWindow -RedirectStandardError cl.out -FilePath "$clPath" + $CL_VERSION_STRING = & type cl.out + if (($CL_VERSION_STRING -join " ") -match "Version (\d+\.\d+)\.\d+") { + $CL_VERSION = $matches[1] echo "Detected cl.exe version: $CL_VERSION" } } @@ -105,9 +107,9 @@ function Main { echo "CuPy Configuration:" RunOrDie python -c "import cupy; print(cupy); cupy.show_config()" echo "Running test..." - $pytest_tests = "cupy_tests/core_tests/test*.py" # TODO: remove me + $pytest_tests = @("cupy_tests/core_tests/test*.py") # TODO: remove me # TODO: pass timeout as a function argument? - $test_retval = RunWithTimeout -timeout 18000 -- python -m pytest -rfEX @pytest_opts @pytest_tests + $test_retval = RunWithTimeout -timeout 18000 -output "" -- python -m pytest -rfEX @pytest_opts --maxfail=10 @pytest_tests popd if ($test_retval -ne 0) { diff --git a/.pfnci/windows/_error_handler.ps1 b/.pfnci/windows/_error_handler.ps1 index 79f895d1e1d..435db520cf1 100644 --- a/.pfnci/windows/_error_handler.ps1 +++ b/.pfnci/windows/_error_handler.ps1 @@ -18,14 +18,15 @@ function RunWithTimeout { param( [Parameter(Mandatory=$true)] [int]$timeout, - [Parameter(Mandatory=$false)] + [Parameter(Mandatory=$true)] + [AllowEmptyString()] [string]$output, [Parameter(Mandatory=$true)] [string]$command, [Parameter(Mandatory=$true, ValueFromRemainingArguments=$true)] [string[]]$params ) - if ($PSBoundParameters.ContainsKey('output')) { + if ($output) { $process = Start-Process -PassThru -NoNewWindow -RedirectStandardOutput $output -FilePath $command -ArgumentList $params } else { $process = Start-Process -PassThru -NoNewWindow -FilePath $command -ArgumentList $params