diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 30730141c7b..7d194f7e77e 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -104,10 +104,14 @@ jobs: CUPY_CACHE_DIR: "${{ env.CACHE_DIR }}\\.cupy" GPU: 1 run: | - echo "test" - ni -force -ItemType File -Path "$env:CUPY_CACHE_DIR\\abc" + #echo "test" + #ni -force -ItemType File -Path "$env:CUPY_CACHE_DIR\\abc" + # The next step requires this environment variable to be visible echo "CUPY_CACHE_DIR=$env:CUPY_CACHE_DIR" >> $env:GITHUB_ENV - #.pfnci\windows\run.bat 12.0 3.10 test + # FIXME: get the version strings from a test matrix + .pfnci\windows\GHA-test.ps1 -stage setup -python 3.10 -cuda 12.6 + .pfnci\windows\GHA-test.ps1 -stage build + .pfnci\windows\GHA-test.ps1 -stage test - name: Prepare cache id: prepare-cache diff --git a/.pfnci/windows/GHA-test.ps1 b/.pfnci/windows/GHA-test.ps1 new file mode 100644 index 00000000000..2d203f2a69d --- /dev/null +++ b/.pfnci/windows/GHA-test.ps1 @@ -0,0 +1,94 @@ +Param( + [Parameter(Mandatory=$true)] + [String]$stage, + [Parameter(Mandatory=$false)] + [String]$python, + [Parameter(Mandatory=$false)] + [String]$cuda +) + +$ErrorActionPreference = "Stop" +. "$PSScriptRoot\_error_handler.ps1" + +. "$PSScriptRoot\_flexci.ps1" + + +function Main { + # Setup environment + if ($stage -eq "setup") { + echo "Using CUDA $cuda and Python $python" + ActivateCUDA $cuda + if ($cuda -eq "10.2") { + ActivateCuDNN "8.6" $cuda + } else { + ActivateCuDNN "8.8" $cuda + } + ActivateNVTX1 + ActivatePython $python + echo "Setting up test environment" + RunOrDie python -V + RunOrDie python -m pip install -U pip setuptools wheel + RunOrDie python -m pip freeze + + return + } + elseif ($stage -eq "build") { + # Setup build environment variables + $Env:CUPY_NUM_BUILD_JOBS = "16" + $Env:CUPY_NVCC_GENERATE_CODE = "current" + echo "Environment:" + RunOrDie cmd.exe /C set + + echo "Building..." + $build_retval = 0 + RunOrDie python -m pip install -U "numpy" "scipy==1.12.*" + python -m pip install ".[all,test]" -v + if (-not $?) { + $build_retval = $LastExitCode + } + + if ($build_retval -ne 0) { + throw "Build failed with status $build_retval" + } + + return + } + elseif ($stage -eq "test") { + $pytest_opts = "-m", '"not slow"' + } + elseif ($stage -eq "slow") { + $pytest_opts = "-m", "slow" + } + else { + throw "Unsupported stage: $stage" + } + + $Env:CUPY_TEST_GPU_LIMIT = $Env:GPU + $Env:CUPY_DUMP_CUDA_SOURCE_ON_ERROR = "1" + + # # TODO: update this function? + # $is_pull_request = IsPullRequestTest + # if (-Not $is_pull_request) { + # $Env:CUPY_TEST_FULL_COMBINATION = "1" + # } + + # # TODO: do we still need zlib these days? + # # Install dependency for cuDNN 8.3+ + # echo ">> Installing zlib" + # InstallZLIB + + pushd tests + 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 + # TODO: pass timeout as a function argument? + $test_retval = RunWithTimeout -timeout 18000 -- python -m pytest -rfEX @pytest_opts @pytest_tests + popd + + if ($test_retval -ne 0) { + throw "Test failed with status $test_retval" + } +} + +Main diff --git a/.pfnci/windows/_error_handler.ps1 b/.pfnci/windows/_error_handler.ps1 index 5750a59e014..79f895d1e1d 100644 --- a/.pfnci/windows/_error_handler.ps1 +++ b/.pfnci/windows/_error_handler.ps1 @@ -18,14 +18,18 @@ function RunWithTimeout { param( [Parameter(Mandatory=$true)] [int]$timeout, - [Parameter(Mandatory=$true)] + [Parameter(Mandatory=$false)] [string]$output, [Parameter(Mandatory=$true)] [string]$command, [Parameter(Mandatory=$true, ValueFromRemainingArguments=$true)] [string[]]$params ) - $process = Start-Process -PassThru -NoNewWindow -RedirectStandardOutput $output -FilePath $command -ArgumentList $params + if ($PSBoundParameters.ContainsKey('output')) { + $process = Start-Process -PassThru -NoNewWindow -RedirectStandardOutput $output -FilePath $command -ArgumentList $params + } else { + $process = Start-Process -PassThru -NoNewWindow -FilePath $command -ArgumentList $params + } try { $process | Wait-Process -Timeout $timeout } catch [TimeoutException] {