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

Commit db998cc

Browse files
authored
refactor: misc (#4)
* persist environment to GITHUB_ENV * exclude unused files from cache * inline install scripts * add CONTRIBUTING.md * update README.md
1 parent e0dedda commit db998cc

File tree

14 files changed

+186
-150
lines changed

14 files changed

+186
-150
lines changed

.github/workflows/commit.yml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ on:
88
branches:
99
- main
1010
- develop
11-
env:
12-
FC: ifort
1311
jobs:
1412
test:
1513
name: Test
@@ -25,8 +23,7 @@ jobs:
2523
uses: ./
2624
- name: Test
2725
run: |
28-
source /opt/intel/oneapi/setvars.sh
29-
./scripts/test/test.sh /opt/intel/oneapi
26+
./test/test.sh /opt/intel/oneapi
3027
test_windows:
3128
name: Test (Windows)
3229
runs-on: windows-latest
@@ -36,9 +33,5 @@ jobs:
3633
- name: Install
3734
uses: ./
3835
- name: Test
39-
shell: cmd
4036
run: |
41-
call "scripts/install/build_windows.bat"
42-
powershell -command "./scripts/test/test.ps1 'C:\Program Files (x86)\Intel\oneAPI'"
43-
env:
44-
VS_VER: vs2022
37+
./test/test.ps1 "C:\Program Files (x86)\Intel\oneAPI"

CONTRIBUTING.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Contributing
2+
3+
Contributions to this repository are welcome. To make a contribution we ask that you follow a few guidelines.
4+
5+
## Issues and features
6+
7+
Before filing a bug report or making a feature request, please check the issues to make sure yours isn't a duplicate.
8+
9+
## Pull requests
10+
11+
Feel free to submit pull requests to the `develop` branch with small fixes or improvements. Before implementing new features or contributing broadly-scoped changes we ask that you first open an issue or discussion.
12+
13+
Before submitting a PR, please test your changes in your own fork. Please do *not* open a pull request immediately and add to it frequently during development — this will saturate the `modflowpy` organization's CI.
14+
15+
If `develop` changes while your work is still in progress, please rebase and fix any conflicts, then force push your branch to update the pull request.
16+
17+
## Commit messages
18+
19+
To keep the repository's commit history consistent, commit messages must conform to the following formatting conventions.
20+
21+
Each commit message consists of a **header**, a **body** and a **footer**. The header includes a **type**, a **scope** and a **subject**:
22+
23+
```
24+
<type>(<scope>): <subject>
25+
<BLANK LINE>
26+
<body>
27+
<BLANK LINE>
28+
<footer>
29+
```
30+
31+
The **header** is mandatory and its **scope** is optional. The message **body** and **footer** are also optional.
32+
33+
Please keep lines under 100 characters.
34+
35+
### Type
36+
37+
Must be one of the following:
38+
39+
* **ci**: Changes to our CI configuration files and scripts (example scopes: Travis)
40+
* **docs**: Documentation only changes
41+
* **feat**: A new feature
42+
* **fix**: A bug fix
43+
* **perf**: A code change that improves performance
44+
* **refactor**: A code change that neither fixes a bug nor adds a feature
45+
* **style**: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
46+
* **test**: Adding missing tests or correcting existing tests
47+
* **revert**: Reverts a previous commit
48+
49+
### Scope
50+
The scope should be the name of the FloPy module/class affected (as perceived by the person reading the changelog generated from commit messages.
51+
52+
There are currently a few exceptions to the "use module/class name" rule:
53+
54+
* **release**: used when updating files prior to a release
55+
* **releasenotes**: used for updating the release notes
56+
* **readme**: used for updating the release notes in README.md
57+
* **changelog**: used for updating the release notes in CHANGELOG.md
58+
* none/empty string: useful for `style`, `test` and `refactor` changes that are done across all
59+
packages (e.g. `style: add missing semicolons`) and for docs changes that are not related to a
60+
specific package (e.g. `docs: fix typo in tutorial`).
61+
62+
### Subject
63+
64+
The subject contains a succinct description of the change:
65+
66+
* use the imperative, present tense: "change" not "changed" nor "changes"
67+
* don't capitalize the first letter
68+
* do not include a dot (.) at the end
69+
70+
### Body
71+
72+
Just as in the **subject**, use the imperative, present tense: "change" not "changed" nor "changes".
73+
The body should include the motivation for the change and contrast this with previous behavior.
74+
75+
### Footer
76+
77+
The footer should contain any information about **Breaking Changes** and is also the place to reference GitHub issues that this commit **Closes**.
78+
79+
**Breaking Changes** should start with the word `BREAKING CHANGE:` with a space or two newlines. The rest of the commit message is then used for this.

README.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# install-intelfortran-action
22

33
[![CI](https://github.com/modflowpy/install-intelfortran-action/actions/workflows/commit.yml/badge.svg?branch=develop)](https://github.com/modflowpy/install-intelfortran-action/actions/workflows/commit.yml)
4-
![Status](https://img.shields.io/badge/-under%20development-yellow?style=flat-square)
54

65
An action to install the [Intel OneAPI](https://www.intel.com/content/www/us/en/developer/tools/oneapi/fortran-compiler.html#gs.bksc2p) Fortran compiler.
76

@@ -31,9 +30,7 @@ To use this action, add a step like the following to your workflow:
3130

3231
```yaml
3332
- name: Install Intel Fortran
34-
uses: modflowpy/install-intelfortran-action@v0.0.1
33+
uses: modflowpy/install-intelfortran-action@v1
3534
```
3635
37-
Environment variables must be set before the compiler can be used. On Linux or MacOS runners, run `source /opt/intel/oneapi/setvars.sh`. On Windows, run `call "scripts/install/build_windows.bat"` from a step with `shell: cmd`.
38-
39-
**Note:** Environment variables are not preserved between steps, so the above must occur in the same step in which the `ifort` command is used.
36+
The action will configure [environment variables](https://www.intel.com/content/www/us/en/develop/documentation/oneapi-programming-guide/top/oneapi-development-environment-setup.html) necessary to invoke `ifort` from subsequent workflow steps. Environment variables are not preserved between steps by default &mdash; here they are persisted by [appending to the `GITHUB_ENV` environment file](https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-environment-variable).

action.yml

Lines changed: 101 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,81 +3,166 @@ description: Install & cache Intel Fortran
33
runs:
44
using: composite
55
steps:
6-
- name: Set install path (Linux & MacOS)
6+
- name: Set install path (Linux & Mac)
77
if: runner.os != 'Windows'
88
id: set-install-path
99
shell: bash
1010
run: |
1111
echo "::set-output name=install-path::/opt/intel/oneapi"
1212
1313
- name: Set resources (Linux)
14+
if: runner.os == 'Linux'
1415
id: set-resources-linux
1516
shell: bash
1617
run: |
1718
echo "::set-output name=hpckit_url::https://registrationcenter-download.intel.com/akdlm/irc_nas/18679/l_HPCKit_p_2022.2.0.191_offline.sh"
18-
echo "::set-output name=fortran::intel.oneapi.lin.ifort-compiler"
19+
echo "::set-output name=components::intel.oneapi.lin.ifort-compiler"
1920
2021
- name: Cache ifort (Linux)
2122
if: runner.os == 'Linux'
2223
id: cache-install-linux
2324
uses: actions/cache@v3
2425
with:
2526
path: ${{ steps.set-install-path.outputs.install-path }}
26-
key: ifort-${{ runner.os }}-${{ hashFiles('action.yml', '**/scripts/install/cache_exclude_linux.sh') }}
27+
key: ifort-${{ runner.os }}-${{ steps.set-resources-linux.outputs.hpckit_url }}-${{ steps.set-resources-linux.outputs.components }}
2728

2829
- name: Install ifort (Linux)
2930
if: runner.os == 'Linux' && steps.cache-install-linux.outputs.cache-hit != 'true'
3031
shell: bash
3132
run: |
32-
./scripts/install/install_linux.sh $HPCKIT_URL $FORTRAN
33+
# SPDX-FileCopyrightText: 2020 Intel Corporation
34+
# SPDX-License-Identifier: MIT
35+
curl --output webimage.sh --url "$HPCKIT_URL" --retry 5 --retry-delay 5
36+
chmod +x webimage.sh
37+
./webimage.sh -x -f webimage_extracted --log extract.log
38+
rm -rf webimage.sh
39+
WEBIMAGE_NAME=$(ls -1 webimage_extracted/)
40+
if [ -z "$COMPONENTS" ]; then
41+
sudo webimage_extracted/"$WEBIMAGE_NAME"/bootstrapper -s --action install --eula=accept --log-dir=.
42+
installer_exit_code=$?
43+
else
44+
sudo webimage_extracted/"$WEBIMAGE_NAME"/bootstrapper -s --action install --components="$COMPONENTS" --eula=accept --log-dir=.
45+
installer_exit_code=$?
46+
fi
47+
rm -rf webimage_extracted
48+
exit $installer_exit_code
3349
env:
3450
HPCKIT_URL: ${{ steps.set-resources-linux.outputs.hpckit_url }}
35-
FORTRAN: ${{ steps.set-resources-linux.outputs.fortran }}
51+
COMPONENTS: ${{ steps.set-resources-linux.outputs.components }}
52+
53+
- name: Exclude unused files from cache (Linux)
54+
shell: bash
55+
if: runner.os == 'Linux' && steps.cache-install-linux.outputs.cache-hit != 'true'
56+
run: |
57+
# SPDX-FileCopyrightText: 2020 Intel Corporation
58+
# SPDX-License-Identifier: MIT
59+
LATEST_VERSION=$(ls -1 /opt/intel/oneapi/compiler/ | grep -v latest | sort | tail -1)
60+
sudo rm -rf /opt/intel/oneapi/compiler/"$LATEST_VERSION"/linux/compiler/lib/ia32_lin
61+
sudo rm -rf /opt/intel/oneapi/compiler/"$LATEST_VERSION"/linux/bin/ia32
62+
sudo rm -rf /opt/intel/oneapi/compiler/"$LATEST_VERSION"/linux/lib/emu
63+
sudo rm -rf /opt/intel/oneapi/compiler/"$LATEST_VERSION"/linux/lib/oclfpga
3664
3765
- name: Set resources (Mac)
66+
if: runner.os == 'macOS'
3867
id: set-resources-macos
3968
shell: bash
4069
run: |
4170
echo "::set-output name=hpckit_url::https://registrationcenter-download.intel.com/akdlm/IRC_NAS/18681/m_HPCKit_p_2022.2.0.158_offline.dmg"
42-
echo "::set-output name=fortran::intel.oneapi.mac.ifort-compiler"
71+
echo "::set-output name=components::intel.oneapi.mac.ifort-compiler"
4372
44-
- name: Cache ifort (MacOS)
73+
- name: Cache ifort (Mac)
4574
if: runner.os == 'macOS'
4675
id: cache-install-macos
4776
uses: actions/cache@v3
4877
with:
4978
path: ${{ steps.set-install-path.outputs.install-path }}
50-
key: ifort-${{ runner.os }}-${{ hashFiles('action.yml') }}
79+
key: ifort-${{ runner.os }}-${{ steps.set-resources-macos.outputs.hpckit_url }}-${{ steps.set-resources-macos.outputs.components }}
5180

52-
- name: Install ifort (MacOS)
81+
- name: Install ifort (Mac)
5382
if: runner.os == 'macOS' && steps.cache-install-macos.outputs.cache-hit != 'true'
5483
shell: bash
5584
run: |
56-
./scripts/install/install_macos.sh $HPCKIT_URL $FORTRAN_COMPONENTS
85+
# SPDX-FileCopyrightText: 2020 Intel Corporation
86+
# SPDX-License-Identifier: MIT
87+
curl --output webimage.dmg --url "$HPCKIT_URL" --retry 5 --retry-delay 5
88+
hdiutil attach webimage.dmg
89+
if [ -z "$COMPONENTS" ]; then
90+
sudo /Volumes/"$(basename "$HPCKIT_URL" .dmg)"/bootstrapper.app/Contents/MacOS/bootstrapper -s --action install --eula=accept --continue-with-optional-error=yes --log-dir=.
91+
installer_exit_code=$?
92+
else
93+
sudo /Volumes/"$(basename "$HPCKIT_URL" .dmg)"/bootstrapper.app/Contents/MacOS/bootstrapper -s --action install --components="$COMPONENTS" --eula=accept --log-dir=.
94+
installer_exit_code=$?
95+
fi
96+
hdiutil detach /Volumes/"$(basename "$HPCKIT_URL" .dmg)" -quiet
97+
exit $installer_exit_code
5798
env:
5899
HPCKIT_URL: ${{ steps.set-resources-macos.outputs.hpckit_url }}
59-
FORTRAN: ${{ steps.set-resources-macos.outputs.fortran }}
100+
COMPONENTS: ${{ steps.set-resources-macos.outputs.components }}
101+
102+
- name: Configure environment (Linux & Mac)
103+
if: runner.os != 'Windows'
104+
shell: bash
105+
run: |
106+
source /opt/intel/oneapi/setvars.sh
107+
env | grep oneapi >> $GITHUB_ENV
60108
61109
- name: Set resources (Windows)
110+
if: runner.os == 'Windows'
62111
id: set-resources-windows
63112
shell: pwsh
64113
run: |
65114
echo "::set-output name=hpckit_url::https://registrationcenter-download.intel.com/akdlm/IRC_NAS/18680/w_HPCKit_p_2022.2.0.173_offline.exe"
66-
echo "::set-output name=fortran::intel.oneapi.win.ifort-compiler"
115+
echo "::set-output name=components::intel.oneapi.win.ifort-compiler"
67116
68117
- name: Cache ifort (Windows)
69118
if: runner.os == 'Windows'
70119
id: cache-install-windows
71120
uses: actions/cache@v3
72121
with:
73122
path: C:\Program Files (x86)\Intel\oneAPI
74-
key: ifort-${{ runner.os }}-${{ hashFiles('action.yml', 'scripts/install/cache_exclude_windows.sh') }}
123+
key: ifort-${{ runner.os }}-${{ steps.set-resources-windows.outputs.hpckit_url }}-${{ steps.set-resources-windows.outputs.components }}
75124

76125
- name: Install ifort (Windows)
77126
if: runner.os == 'Windows' && steps.cache-install-windows.outputs.cache-hit != 'true'
78-
shell: pwsh
127+
shell: cmd
79128
run: |
80-
./scripts/install/install_windows.bat $env:HPCKIT_URL $env:FORTRAN
129+
REM SPDX-FileCopyrightText: 2022 Intel Corporation
130+
REM SPDX-License-Identifier: MIT
131+
curl.exe --output %TEMP%\webimage.exe --url %HPCKIT_URL% --retry 5 --retry-delay 5
132+
start /b /wait %TEMP%\webimage.exe -s -x -f webimage_extracted --log extract.log
133+
del %TEMP%\webimage.exe
134+
if "%COMPONENTS%"=="" (
135+
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=.
136+
) else (
137+
webimage_extracted\bootstrapper.exe -s --action install --components=%COMPONENTS% --eula=accept -p=NEED_VS2017_INTEGRATION=0 -p=NEED_VS2019_INTEGRATION=0 -p=NEED_VS2022_INTEGRATION=0 --log-dir=.
138+
)
139+
rd /s/q "webimage_extracted"
81140
env:
82141
HPCKIT_URL: ${{ steps.set-resources-windows.outputs.hpckit_url }}
83-
FORTRAN: ${{ steps.set-resources-windows.outputs.fortran }}
142+
COMPONENTS: ${{ steps.set-resources-windows.outputs.components }}
143+
144+
- name: Configure environment (Windows)
145+
if: runner.os == 'Windows'
146+
shell: cmd
147+
run: |
148+
call "C:\Program Files (x86)\Intel\oneAPI\setvars-vcvarsall.bat" %VS_VER%
149+
for /f "tokens=* usebackq" %%f in (`dir /b "C:\Program Files (x86)\Intel\oneAPI\compiler\" ^| findstr /V latest ^| sort`) do @set "LATEST_VERSION=%%f"
150+
call "C:\Program Files (x86)\Intel\oneAPI\compiler\%LATEST_VERSION%\env\vars.bat"
151+
set | findstr "oneAPI" >> %GITHUB_ENV%
152+
set | findstr "vs" >> %GITHUB_ENV%
153+
env:
154+
VS_VER: vs2022
155+
156+
- name: Exclude unused files from cache (Windows)
157+
shell: bash
158+
if: runner.os == 'Windows' && steps.cache-install-windows.outputs.cache-hit != 'true'
159+
run: |
160+
# SPDX-FileCopyrightText: 2020 Intel Corporation
161+
# SPDX-License-Identifier: MIT
162+
LATEST_VERSION=$(ls -1 "C:\Program Files (x86)\Intel\oneAPI\compiler" | grep -v latest | sort | tail -1)
163+
rm -rf "C:\Program Files (x86)\Intel\oneAPI\compiler\'$LATEST_VERSION'\windows\compiler\lib\ia32_win"
164+
rm -rf "C:\Program Files (x86)\Intel\oneAPI\compiler\'$LATEST_VERSION'\windows\bin\intel64_ia32"
165+
rm -rf "C:\Program Files (x86)\Intel\oneAPI\compiler\'$LATEST_VERSION'\windows\lib\emu"
166+
rm -rf "C:\Program Files (x86)\Intel\oneAPI\compiler\'$LATEST_VERSION'\windows\lib\oclfpga"
167+
rm -rf "C:\Program Files (x86)\Intel\oneAPI\compiler\'$LATEST_VERSION'\windows\lib\ocloc"
168+
rm -rf "C:\Program Files (x86)\Intel\oneAPI\compiler\'$LATEST_VERSION'\windows\lib\x86"

scripts/install/README.md

Lines changed: 0 additions & 17 deletions
This file was deleted.

scripts/install/build_windows.bat

Lines changed: 0 additions & 14 deletions
This file was deleted.

scripts/install/cache_exclude_linux.sh

Lines changed: 0 additions & 13 deletions
This file was deleted.

scripts/install/cache_exclude_windows.sh

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)