From 90c773488c59e57c19ecca5635c1ae7f70e56076 Mon Sep 17 00:00:00 2001 From: John Parent Date: Tue, 25 Jan 2022 17:29:17 -0500 Subject: Add Github Actions for Windows (#24504) Setup Installer CI (#25184), (#25191) Co-authored-by: Zack Galbreath Co-authored-by: lou.lawrence@kitware.com Co-authored-by: Betsy McPhail --- .github/workflows/execute_installer.ps1 | 7 + .github/workflows/setup_git.ps1 | 16 ++ .github/workflows/system_shortcut_check.ps1 | 4 + .github/workflows/windows_python.yml | 185 +++++++++++++++++++++++ bin/spack.bat | 4 +- bin/spack_cmd.bat | 8 +- share/spack/qa/configuration/windows_config.yaml | 8 + share/spack/qa/setup_spack.ps1 | 3 + share/spack/qa/vcvarsall.ps1 | 14 ++ share/spack/qa/windows_test_setup.ps1 | 11 ++ share/spack/spack-completion.bash | 10 +- 11 files changed, 262 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/execute_installer.ps1 create mode 100644 .github/workflows/setup_git.ps1 create mode 100644 .github/workflows/system_shortcut_check.ps1 create mode 100644 .github/workflows/windows_python.yml create mode 100644 share/spack/qa/configuration/windows_config.yaml create mode 100644 share/spack/qa/setup_spack.ps1 create mode 100644 share/spack/qa/vcvarsall.ps1 create mode 100644 share/spack/qa/windows_test_setup.ps1 diff --git a/.github/workflows/execute_installer.ps1 b/.github/workflows/execute_installer.ps1 new file mode 100644 index 0000000000..9d9f5cfbeb --- /dev/null +++ b/.github/workflows/execute_installer.ps1 @@ -0,0 +1,7 @@ +$ proc = Start-Process ${{ env.spack_installer }}\spack.exe "/install /quiet" -Passthru +$handle = $proc.Handle # cache proc.Handle +$proc.WaitForExit(); + +if ($proc.ExitCode -ne 0) { + Write-Warning "$_ exited with status code $($proc.ExitCode)" +} diff --git a/.github/workflows/setup_git.ps1 b/.github/workflows/setup_git.ps1 new file mode 100644 index 0000000000..19d3b81b97 --- /dev/null +++ b/.github/workflows/setup_git.ps1 @@ -0,0 +1,16 @@ +# (c) 2021 Lawrence Livermore National Laboratory + +Set-Location spack + +git config --global user.email "spack@example.com" +git config --global user.name "Test User" + +if ($(git branch --show-current) -ne "develop") +{ + git branch develop origin/develop +} + +if ($(git branch --show-current) -ne "features/windows-support") +{ + git branch features/windows-support origin/features/windows-support +} diff --git a/.github/workflows/system_shortcut_check.ps1 b/.github/workflows/system_shortcut_check.ps1 new file mode 100644 index 0000000000..03b3a236f1 --- /dev/null +++ b/.github/workflows/system_shortcut_check.ps1 @@ -0,0 +1,4 @@ +param ($systemFolder, $shortcut) + +$start = [System.Environment]::GetFolderPath("$systemFolder") +Invoke-Item "$start\Programs\Spack\$shortcut" diff --git a/.github/workflows/windows_python.yml b/.github/workflows/windows_python.yml new file mode 100644 index 0000000000..7549273628 --- /dev/null +++ b/.github/workflows/windows_python.yml @@ -0,0 +1,185 @@ +name: windows tests + +on: + push: + branches: + - features/windows-support + - windows-ci* + pull_request: + branches: + - features/windows-support + - windows-ci* + - develop +defaults: + run: + shell: + powershell Invoke-Expression -Command ".\share\spack\qa\windows_test_setup.ps1"; {0} +jobs: + validate: + runs-on: windows-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + with: + python-version: 3.9 + - name: Install Python Packages + run: | + python -m pip install --upgrade pip + python -m pip install --upgrade vermin + - name: vermin (Spack's Core) + run: vermin --backport argparse --backport typing -t='2.6-' -t='3.5-' -v spack/lib/spack/spack/ spack/lib/spack/llnl/ spack/bin/ + - name: vermin (Repositories) + run: vermin --backport argparse --backport typing -t='2.6-' -t='3.5-' -v spack/var/spack/repos + # Run style checks on the files that have been changed + style: + runs-on: windows-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - uses: actions/setup-python@v2 + with: + python-version: 3.9 + - name: Install Python packages + run: | + python -m pip install --upgrade pip six setuptools flake8 isort>=4.3.5 mypy>=0.800 black pywin32 types-python-dateutil + - name: Create local develop + run: | + .\spack\.github\workflows\setup_git.ps1 + - name: Run style tests + run: | + spack style + - name: Verify license headers + run: | + python spack\bin\spack license verify + unittest: + runs-on: windows-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - uses: actions/setup-python@v2 + with: + python-version: 3.9 + - name: Install Python packages + run: | + python -m pip install --upgrade pip six pywin32 setuptools codecov coverage + - name: Create local develop + run: | + .\spack\.github\workflows\setup_git.ps1 + - name: Unit Test + run: | + echo F|xcopy .\spack\share\spack\qa\configuration\windows_config.yaml $env:USERPROFILE\.spack\windows\config.yaml + spack unit-test -x --verbose --ignore=lib/spack/spack/test/cmd + unittest-cmd: + runs-on: windows-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - uses: actions/setup-python@v2 + with: + python-version: 3.9 + - name: Install Python packages + run: | + python -m pip install --upgrade pip six pywin32 setuptools codecov coverage + - name: Create local develop + run: | + .\spack\.github\workflows\setup_git.ps1 + - name: Command Unit Test + run: | + echo F|xcopy .\spack\share\spack\qa\configuration\windows_config.yaml $env:USERPROFILE\.spack\windows\config.yaml + spack unit-test lib/spack/spack/test/cmd -x --verbose + buildtest: + runs-on: windows-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - uses: actions/setup-python@v2 + with: + python-version: 3.9 + - name: Install Python packages + run: | + python -m pip install --upgrade pip six pywin32 setuptools codecov coverage + - name: Build Test + run: | + spack compiler find + echo F|xcopy .\spack\share\spack\qa\configuration\windows_config.yaml $env:USERPROFILE\.spack\windows\config.yaml + spack external find cmake + spack external find ninja + spack install abseil-cpp + generate-installer-test: + runs-on: windows-latest + steps: + - name: Disable Windows Symlinks + run: | + git config --global core.symlinks false + shell: + powershell + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - uses: actions/setup-python@v2 + with: + python-version: 3.9 + - name: Install Python packages + run: | + python -m pip install --upgrade pip six pywin32 setuptools codecov coverage + - name: Add Light and Candle to Path + run: | + $env:WIX >> $GITHUB_PATH + - name: Run Installer + run: | + .\spack\share\spack\qa\setup_spack.ps1 + spack make-installer -s spack -g SILENT pkg + echo "installer_root=$((pwd).Path)" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append + env: + ProgressPreference: SilentlyContinue + - uses: actions/upload-artifact@v2 + with: + name: Windows Spack Installer Bundle + path: ${{ env.installer_root }}\pkg\Spack.exe + - uses: actions/upload-artifact@v2 + with: + name: Windows Spack Installer + path: ${{ env.installer_root}}\pkg\Spack.msi + execute-installer: + needs: generate-installer-test + runs-on: windows-latest + defaults: + run: + shell: pwsh + steps: + - uses: actions/setup-python@v2 + with: + python-version: 3.9 + - name: Install Python packages + run: | + python -m pip install --upgrade pip six pywin32 setuptools codecov coverage + - name: Setup installer directory + run: | + mkdir -p spack_installer + echo "spack_installer=$((pwd).Path)\spack_installer" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append + - uses: actions/download-artifact@v2 + with: + name: Windows Spack Installer Bundle + path: ${{ env.spack_installer }} + - name: Execute Bundled Installer + run: | + $proc = Start-Process ${{ env.spack_installer }}\spack.exe "/install /quiet" -Passthru + $handle = $proc.Handle # cache proc.Handle + $proc.WaitForExit(); + $LASTEXITCODE + env: + ProgressPreference: SilentlyContinue + - uses: actions/download-artifact@v2 + with: + name: Windows Spack Installer + path: ${{ env.spack_installer }} + - name: Execute MSI + run: | + $proc = Start-Process ${{ env.spack_installer }}\spack.msi "/quiet" -Passthru + $handle = $proc.Handle # cache proc.Handle + $proc.WaitForExit(); + $LASTEXITCODE \ No newline at end of file diff --git a/bin/spack.bat b/bin/spack.bat index 3b6b7905a4..4781c42702 100644 --- a/bin/spack.bat +++ b/bin/spack.bat @@ -187,7 +187,7 @@ python "%spack%" %_sp_flags% %_sp_subcommand% %_sp_args% goto :end_switch :end_switch -exit /B 0 +exit /B %ERRORLEVEL% ::######################################################################## @@ -220,4 +220,4 @@ for %%I in (%~2) do ( :pathadd "%~1" "%%I\%%Z" ) ) -exit /B 0 \ No newline at end of file +exit /B %ERRORLEVEL% \ No newline at end of file diff --git a/bin/spack_cmd.bat b/bin/spack_cmd.bat index 6d851d5311..5ba685fa46 100644 --- a/bin/spack_cmd.bat +++ b/bin/spack_cmd.bat @@ -14,8 +14,9 @@ popd :: Check if Python is on the PATH +if not defined python_pf_ver ( (for /f "delims=" %%F in ('where python.exe') do (set python_pf_ver=%%F) ) 2> NUL - +) if not defined python_pf_ver ( :: If not, look for Python from the Spack installer :get_builtin @@ -58,4 +59,9 @@ DOSKEY spacktivate=spack env activate $* @echo ** Spack Package Manager @echo ********************************************************************** +IF "%1"=="" GOTO CONTINUE +set +GOTO:EOF + +:continue %comspec% /k diff --git a/share/spack/qa/configuration/windows_config.yaml b/share/spack/qa/configuration/windows_config.yaml new file mode 100644 index 0000000000..fb90000223 --- /dev/null +++ b/share/spack/qa/configuration/windows_config.yaml @@ -0,0 +1,8 @@ +config: + locks: false + install_tree: + root: $spack\opt\spack + projections: + all: '${ARCHITECTURE}\${COMPILERNAME}-${COMPILERVER}\${PACKAGE}-${VERSION}-${HASH}' + build_stage: + - ~/.spack/stage \ No newline at end of file diff --git a/share/spack/qa/setup_spack.ps1 b/share/spack/qa/setup_spack.ps1 new file mode 100644 index 0000000000..6b462916fa --- /dev/null +++ b/share/spack/qa/setup_spack.ps1 @@ -0,0 +1,3 @@ +spack compiler find +echo F|xcopy .\spack\share\spack\qa\configuration\windows_config.yaml $env:USERPROFILE\.spack\windows\config.yaml +spack external find cmake \ No newline at end of file diff --git a/share/spack/qa/vcvarsall.ps1 b/share/spack/qa/vcvarsall.ps1 new file mode 100644 index 0000000000..8172bcd69a --- /dev/null +++ b/share/spack/qa/vcvarsall.ps1 @@ -0,0 +1,14 @@ +$erroractionpreference = "stop" + +$VCVARSALL="C:\\Program Files (x86)\\MicroSoft Visual Studio\\2019\\Enterprise\\VC\\Auxiliary\\Build\\vcvars64.bat" +$VCVARSPLATFORM="x64" +$VCVARSVERSION="14.29.30038" + + +cmd /c "`"$VCVARSALL`" $VCVARSPLATFORM -vcvars_ver=$VCVARSVERSION & set" | +foreach { + if ($_ -match "=") { + $v = $_.split("=") + [Environment]::SetEnvironmentVariable($v[0], $v[1]) + } +} diff --git a/share/spack/qa/windows_test_setup.ps1 b/share/spack/qa/windows_test_setup.ps1 new file mode 100644 index 0000000000..eebd0b7480 --- /dev/null +++ b/share/spack/qa/windows_test_setup.ps1 @@ -0,0 +1,11 @@ +Set-Location ../ + +$env:python_pf_ver="C:\hostedtoolcache\windows\Python\3.9.5\x64\python.exe" + +cmd /c "`"spack\bin\spack_cmd.bat`" print " | +foreach { + if ($_ -match "=") { + $v = $_.split("=") + [Environment]::SetEnvironmentVariable($v[0], $v[1]) + } +} \ No newline at end of file diff --git a/share/spack/spack-completion.bash b/share/spack/spack-completion.bash index 3045052ecd..99572bea14 100755 --- a/share/spack/spack-completion.bash +++ b/share/spack/spack-completion.bash @@ -919,14 +919,14 @@ _spack_env() { _spack_env_activate() { if $list_options then - SPACK_COMPREPLY="-h --help --sh --csh --fish -v --with-view -V --without-view -p --prompt --temp -d --dir" + SPACK_COMPREPLY="-h --help --sh --csh --fish --bat -v --with-view -V --without-view -p --prompt --temp -d --dir" else _environments fi } _spack_env_deactivate() { - SPACK_COMPREPLY="-h --help --sh --csh --fish" + SPACK_COMPREPLY="-h --help --sh --csh --fish --bat" } _spack_env_create() { @@ -1205,7 +1205,7 @@ _spack_list() { _spack_load() { if $list_options then - SPACK_COMPREPLY="-h --help --sh --csh --fish --first --only --list" + SPACK_COMPREPLY="-h --help --sh --csh --fish --bat --first --only --list" else _installed_packages fi @@ -1241,7 +1241,7 @@ _spack_maintainers() { _spack_make_installer() { if $list_options then - SPACK_COMPREPLY="-h --help -v --spack_version -s --spack_source" + SPACK_COMPREPLY="-h --help -v --spack_version -s --spack_source -g --git-installer-verbosity" else SPACK_COMPREPLY="" fi @@ -1809,7 +1809,7 @@ _spack_unit_test() { _spack_unload() { if $list_options then - SPACK_COMPREPLY="-h --help --sh --csh --fish -a --all" + SPACK_COMPREPLY="-h --help --sh --csh --fish --bat -a --all" else _installed_packages fi -- cgit v1.2.3-70-g09d2