diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 16c61ca..bd0b064 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,80 +13,148 @@ on: paths-ignore: - '**.md' jobs: - test: - name: Test + # test: + # name: Test + # runs-on: ${{ matrix.os }} + # strategy: + # fail-fast: false + # matrix: + # os: [ ubuntu-20.04, ubuntu-22.04, macos-11, macos-12, windows-2019, windows-2022 ] + # path: [ absolute, relative, tilde, default ] + # setvars: [ 'true', 'false' ] + # steps: + + # - name: Checkout + # uses: actions/checkout@v3 + + # - name: Set bin path + # if: runner.os != 'Windows' + # run: | + # if [ "${{ matrix.path }}" == "absolute" ]; then + # bindir="$HOME/.local/bin" + # elif [ "${{ matrix.path }}" == "relative" ]; then + # bindir="bin" + # elif [ "${{ matrix.path }}" == "tilde" ]; then + # bindir="~/.local/bin" + # else + # # action's default location + # bindir="~/.local/bin/ifort" + # fi + + # echo "TEST_BINDIR=$bindir" >> $GITHUB_ENV + + # - name: Set bin path (Windows) + # if: runner.os == 'Windows' + # shell: pwsh + # run: | + # if ("${{ matrix.path }}" -eq "absolute") { + # # $bindir = "C:\Users\runneradmin\.local\bin" + # $bindir = "C:\Program Files (x86)\Intel\oneAPI" + # } elseif ("${{ matrix.path }}" -eq "relative") { + # $bindir = "bin" + # } elseif ("${{ matrix.path }}" -eq "tilde") { + # $bindir = "~/.local/bin" + # } else { + # # actions's default location + # $bindir = "~/.local/bin/ifort" + # } + + # echo "TEST_BINDIR=$bindir" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + + # - name: Install compilers + # if: matrix.path != 'default' + # uses: ./ + # with: + # path: ${{ env.TEST_BINDIR }} + # setvars: ${{ matrix.setvars }} + + # - name: Install compilers + # if: matrix.path == 'default' + # uses: ./ + # with: + # setvars: ${{ matrix.setvars }} + + # - name: Set environment variables + # if: runner.os != 'Windows' && matrix.setvars != 'true' + # shell: bash + # run: | + # source "$INTEL_HPCKIT_INSTALL_PATH/setvars.sh" + # env | grep oneapi >> $GITHUB_ENV + + # - name: Set environment variables + # if: runner.os == 'Windows' && matrix.setvars != 'true' + # shell: cmd + # run: | + # call "%INTEL_HPCKIT_INSTALL_PATH%\compiler\%INTEL_COMPILER_VERSION%\env\vars.bat" + # set | findstr /c:"oneAPI" >> "%GITHUB_ENV%" + + # # not needed atm, but just in case any future tests require this + # - name: Set SETVARS_COMPLETED + # if: matrix.setvars != 'true' + # shell: bash + # run: echo "SETVARS_COMPLETED=1" >> $GITHUB_ENV + + # - name: Test compilers (Linux & Mac) + # if: runner.os != 'Windows' + # run: ./test/test.sh ${{ env.TEST_BINDIR }} + + # - name: Test compilers (Windows bash) + # if: runner.os == 'Windows' + # shell: bash + # run: | + # if command -v ifort &> /dev/null + # then + # echo "ifort found" + # else + # echo "ifort not available" + # exit 1 + # fi + + # ifort test/hw.f90 -o hw + # output=$(./hw '2>&1') + # if [[ "$output" == *"hello world"* ]] + # then + # echo "compile succeeded" + # echo "$output" + # else + # echo "unexpected output: $output" + # exit 1 + # fi + + # - name: Test compilers (Windows pwsh) + # if: runner.os == 'Windows' + # shell: pwsh + # run: ./test/test.ps1 "${{ env.TEST_BINDIR }}" + + # - name: Test compilers (Windows cmd) + # if: runner.os == 'Windows' + # shell: cmd + # run: call "./test/test.bat" + + test_vs_integration: + name: Test VS integration runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: - os: [ ubuntu-20.04, ubuntu-22.04, macos-11, macos-12, windows-2019, windows-2022 ] - path: [ absolute, relative, tilde, default ] - setvars: [ 'true', 'false' ] + os: [ windows-2019, windows-2022 ] steps: - - name: Checkout uses: actions/checkout@v3 - - name: Set bin path - if: runner.os != 'Windows' - run: | - if [ "${{ matrix.path }}" == "absolute" ]; then - bindir="$HOME/.local/bin" - elif [ "${{ matrix.path }}" == "relative" ]; then - bindir="bin" - elif [ "${{ matrix.path }}" == "tilde" ]; then - bindir="~/.local/bin" - else - # action's default location - bindir="~/.local/bin/ifort" - fi - - echo "TEST_BINDIR=$bindir" >> $GITHUB_ENV - - - name: Set bin path (Windows) - if: runner.os == 'Windows' - shell: pwsh - run: | - if ("${{ matrix.path }}" -eq "absolute") { - # $bindir = "C:\Users\runneradmin\.local\bin" - $bindir = "C:\Program Files (x86)\Intel\oneAPI" - } elseif ("${{ matrix.path }}" -eq "relative") { - $bindir = "bin" - } elseif ("${{ matrix.path }}" -eq "tilde") { - $bindir = "~/.local/bin" - } else { - # actions's default location - $bindir = "~/.local/bin/ifort" - } - - echo "TEST_BINDIR=$bindir" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - - name: Install compilers - if: matrix.path != 'default' + if: matrix.os == 'windows-2019' uses: ./ with: - path: ${{ env.TEST_BINDIR }} - setvars: ${{ matrix.setvars }} - + setvars: 'true' + vs2019: 'true' + - name: Install compilers - if: matrix.path == 'default' + if: matrix.os == 'windows-2022' uses: ./ with: - setvars: ${{ matrix.setvars }} - - - name: Set environment variables - if: runner.os != 'Windows' && matrix.setvars != 'true' - shell: bash - run: | - source "$INTEL_HPCKIT_INSTALL_PATH/setvars.sh" - env | grep oneapi >> $GITHUB_ENV - - - name: Set environment variables - if: runner.os == 'Windows' && matrix.setvars != 'true' - shell: cmd - run: | - call "%INTEL_HPCKIT_INSTALL_PATH%\compiler\%INTEL_COMPILER_VERSION%\env\vars.bat" - set | findstr /c:"oneAPI" >> "%GITHUB_ENV%" + setvars: 'true' + vs2022: 'true' # not needed atm, but just in case any future tests require this - name: Set SETVARS_COMPLETED @@ -94,11 +162,7 @@ jobs: shell: bash run: echo "SETVARS_COMPLETED=1" >> $GITHUB_ENV - - name: Test compilers (Linux & Mac) - if: runner.os != 'Windows' - run: ./test/test.sh ${{ env.TEST_BINDIR }} - - - name: Test compilers (Windows bash) + - name: Test compilers (bash) if: runner.os == 'Windows' shell: bash run: | @@ -121,12 +185,12 @@ jobs: exit 1 fi - - name: Test compilers (Windows pwsh) + - name: Test compilers (pwsh) if: runner.os == 'Windows' shell: pwsh run: ./test/test.ps1 "${{ env.TEST_BINDIR }}" - - name: Test compilers (Windows cmd) + - name: Test compilers (cmd) if: runner.os == 'Windows' shell: cmd run: call "./test/test.bat" \ No newline at end of file diff --git a/README.md b/README.md index 3cfdf0e..c00c034 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,7 @@ An action to install and cache [Intel OneAPI](https://www.intel.com/content/www/ + - [Overview](#overview) - [Usage](#usage) - [Environment variables](#environment-variables) @@ -20,6 +21,7 @@ An action to install and cache [Intel OneAPI](https://www.intel.com/content/www/ - [Setting oneAPI variables on Linux/macOS](#setting-oneapi-variables-on-linuxmacos) - [Setting oneAPI variables on Windows](#setting-oneapi-variables-on-windows) - [`cache`](#cache) + - [`vs20xx`](#vs20xx) - [Outputs](#outputs) - [`cache-hit`](#cache-hit) - [Windows caveats](#windows-caveats) @@ -106,6 +108,10 @@ The `cache` input is a boolean that controls whether the action caches the oneAP **Note:** installation on Windows can take a long time (~30 minutes) so caching is recommended, however an [outstanding cache reservation bug in `actions/cache`](https://github.com/actions/cache/issues/144) can cause the cache to [fail to restore while simultaneously rejecting new saves](https://github.com/MODFLOW-USGS/modflow6/actions/runs/3624583228/jobs/6111766806#step:6:152). The [GitHub-endorsed workaround for this issue](https://github.com/actions/cache/issues/144#issuecomment-579323937) is currently to change keys, so this action rotates the cache key once daily. You may want to run a job in the early hours of the morning to warm up the cache on your repository's default branch, so PR/feature branches can restore from it throughout the day. +### `vs20xx` + +The `vs2017`, `vs2019`, and `vs2022` inputs toggle whether to integrate with Visual Studio 2017, 2019, and 2022, respectively, corresponding to the `NEED_VS20xx_INTEGRATION` installer options. + ## Outputs The action has the following outputs: diff --git a/action.yml b/action.yml index a9476ba..5944102 100644 --- a/action.yml +++ b/action.yml @@ -13,6 +13,18 @@ inputs: description: Whether to cache the installation required: false default: 'true' + vs2017: + description: Whether to integrate with Visual Studio 2017. + required: false + default: 'false' + vs2019: + description: Whether to integrate with Visual Studio 2019. + required: false + default: 'false' + vs2022: + description: Whether to integrate with Visual Studio 2022. + required: false + default: 'false' outputs: cache-hit: description: Whether the installation was restored from cache @@ -74,6 +86,30 @@ runs: echo "using HPC kit version $version" echo "INTEL_HPCKIT_VERSION=$version" >> $GITHUB_ENV + - name: Set VS integration variables (Windows) + if: runner.os == 'Windows' + id: vs-int + shell: bash + run: | + if [[ "${{ inputs.vs2017 }}" == "true" ]]; then + vs2017=1 + else + vs2017=0 + fi + if [[ "${{ inputs.vs2019 }}" == "true" ]]; then + vs2019=1 + else + vs2019=0 + fi + if [[ "${{ inputs.vs2022 }}" == "true" ]]; then + vs2022=1 + else + vs2022=0 + fi + echo "vs2017=$vs2017" >> $GITHUB_OUTPUT + echo "vs2019=$vs2019" >> $GITHUB_OUTPUT + echo "vs2022=$vs2022" >> $GITHUB_OUTPUT + # GNU tar can't handle symlinks on Windows, hide it so default Windows tar is used to restore cache - name: Hide GNU tar if: runner.os == 'windows' && inputs.cache == 'true' @@ -113,7 +149,7 @@ runs: shell: cmd run: | echo downloading and running HPC kit installer - call "%GITHUB_ACTION_PATH%\scripts\install_windows.bat" "${{ env.INTEL_HPCKIT_INSTALL_PATH }}" "${{ env.INTEL_HPCKIT_INSTALLER_URL }}" "${{ env.INTEL_HPCKIT_COMPONENTS }}" + call "%GITHUB_ACTION_PATH%\scripts\install_windows.bat" "${{ env.INTEL_HPCKIT_INSTALL_PATH }}" "${{ env.INTEL_HPCKIT_INSTALLER_URL }}" "${{ env.INTEL_HPCKIT_COMPONENTS }}" "${{ steps.vs-int.outputs.vs2017 }}" "${{ steps.vs-int.outputs.vs2019 }}" "${{ steps.vs-int.outputs.vs2022 }}" - name: Save cache if: inputs.cache == 'true' && steps.cache-ifort.outputs.cache-hit != 'true' @@ -192,10 +228,6 @@ runs: source "$INTEL_HPCKIT_INSTALL_PATH/setvars.sh" env | grep oneapi >> $GITHUB_ENV - # - name: Setup MSBuild - # if: runner.os == 'Windows' - # uses: microsoft/setup-msbuild@v1.1 - # - name: Find VS versions # id: find-vcvars # if: runner.os == 'Windows' diff --git a/scripts/install_windows.bat b/scripts/install_windows.bat index 719e1a0..a5d3de1 100755 --- a/scripts/install_windows.bat +++ b/scripts/install_windows.bat @@ -2,7 +2,7 @@ curl.exe --output %TEMP%\webimage.exe --url %2 --retry 5 --retry-delay 5 start /b /wait %TEMP%\webimage.exe -s -x -f webimage_extracted --log extract.log del %TEMP%\webimage.exe if "%3"=="" ( - webimage_extracted\bootstrapper.exe -s --action install --eula=accept -p=NEED_VS2017_INTEGRATION=0 -p=NEED_VS2019_INTEGRATION=0 -p=NEED_VS2022_INTEGRATION=0 --log-dir=. --install-dir %1 + webimage_extracted\bootstrapper.exe -s --action install --eula=accept -p=NEED_VS2017_INTEGRATION=%4 -p=NEED_VS2019_INTEGRATION=%5 -p=NEED_VS2022_INTEGRATION=%6 --log-dir=. --install-dir %1 ) else ( webimage_extracted\bootstrapper.exe -s --action install --components=default:%3 --eula=accept -p=NEED_VS2017_INTEGRATION=0 -p=NEED_VS2019_INTEGRATION=0 -p=NEED_VS2022_INTEGRATION=0 --log-dir=. --install-dir %1 )