Skip to content
This repository has been archived by the owner on Jan 5, 2024. It is now read-only.

Commit

Permalink
feat(inputs): support visual studio integration
Browse files Browse the repository at this point in the history
  • Loading branch information
wpbonelli committed Sep 21, 2023
1 parent 45b618d commit 86d071e
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 6 deletions.
64 changes: 64 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,70 @@ jobs:
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: [ windows-2019, windows-2022 ]
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install compilers
if: matrix.os == 'windows-2019'
uses: ./
with:
setvars: 'true'
vs2019: 'true'

- name: Install compilers
if: matrix.os == 'windows-2022'
uses: ./
with:
setvars: 'true'
vs2022: 'true'

# 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 (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 (pwsh)
if: runner.os == 'Windows'
shell: pwsh
run: ./test/test.ps1 "${{ env.TEST_BINDIR }}"

- name: Test compilers (cmd)
if: runner.os == 'Windows'
shell: cmd
run: call "./test/test.bat"
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ An action to install and cache [Intel OneAPI](https://www.intel.com/content/www/
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->


- [Overview](#overview)
- [Usage](#usage)
- [Environment variables](#environment-variables)
Expand All @@ -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)
Expand Down Expand Up @@ -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:
Expand Down
42 changes: 37 additions & 5 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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/[email protected]

# - name: Find VS versions
# id: find-vcvars
# if: runner.os == 'Windows'
Expand Down
2 changes: 1 addition & 1 deletion scripts/install_windows.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down

0 comments on commit 86d071e

Please sign in to comment.