Skip to content

Commit

Permalink
ci: check compiler compatibility in separate workflow
Browse files Browse the repository at this point in the history
* trigger weekly, on release/master branches, and on manual dispatch
* create compatibility report for platform/toolchain/version combos
* if changed and not on release/master, open PR autoupdating README
  • Loading branch information
wpbonelli committed Oct 10, 2023
1 parent c50ec80 commit f146abd
Show file tree
Hide file tree
Showing 8 changed files with 435 additions and 98 deletions.
6 changes: 3 additions & 3 deletions .github/common/fortran_format_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
# Exclude these files from checks
excludefiles = ["src/Utilities/InputOutput.f90"] # excluded until refactored


class FortranFormatCheck:
"""
Verify MODFLOW 6 fortran source code format
Expand Down Expand Up @@ -99,16 +100,15 @@ def _excluded(self, path: Path) -> bool:

return False


if __name__ == "__main__":
parser = argparse.ArgumentParser(
"MODFLOW 6 fortran format source code verification"
)
parser.add_argument(
"-r", "--root", help="path to MODFLOW 6 repository root directory"
)
parser.add_argument(
"-v", "--verbose", action="store_true", help="verbose"
)
parser.add_argument("-v", "--verbose", action="store_true", help="verbose")
args = parser.parse_args()

# set MODFLOW 6 repository root
Expand Down
34 changes: 34 additions & 0 deletions .github/common/update_compat_tables.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
"""
Updates compatibility tables in a markdown file.
"""

import re
import sys
from pathlib import Path

name = sys.argv[1] # name of the table, e.g. "compile", "test"
compat_path = Path(sys.argv[2]) # compatibility report path
update_path = Path(sys.argv[3]) # path to markdown file to update

assert compat_path.is_file()
assert update_path.is_file()

with open(compat_path, "r") as compat:
table = "".join(compat.readlines())
r = re.compile(
r"<!\-\- "
+ name
+ r" compat starts \-\->.*<!\-\- "
+ name
+ r" compat ends \-\->",
re.DOTALL,
)
ct = (
"<!-- "
+ name
+ " compat starts -->{}<!-- ".format("\n{}\n".format(table))
+ name
+ " compat ends -->"
)
readme = update_path.open().read()
update_path.open("w").write(r.sub(ct, readme))
32 changes: 32 additions & 0 deletions .github/common/wide_compat_reports.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""
Converts compatibility reports from long to wide format
and makes a markdown table from the wide format report.
"""

from pathlib import Path
import pandas as pd
import sys

ip = Path(sys.argv[1]) # input file path
op = Path(sys.argv[2]) # output file path

assert ip.is_file()
assert ip.suffix == ".csv"
assert op.suffix == ".csv"

df = pd.pivot(
pd.read_csv(ip),
index="runner",
columns=["compiler", "version"],
values="support",
).sort_values(by=["runner"])
df.to_csv(op)
with open(op.with_suffix(".md"), "w") as file:
file.write(
df.to_markdown()
.replace("nan", "")
.replace("(", "")
.replace(")", "")
.replace(",", "")
.replace("'", "")
)
Empty file added .github/compat/comp.csv
Empty file.
Empty file added .github/compat/test.csv
Empty file.
94 changes: 15 additions & 79 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,18 +110,18 @@ jobs:
shell: bash -l {0}
env:
FC: gfortran
GCC_V: 13
GCC: 13
steps:
- name: Checkout modflow6
uses: actions/checkout@v4
with:
path: modflow6

- name: Setup GNU Fortran ${{ env.GCC_V }}
- name: Setup GNU Fortran ${{ env.GCC }}
uses: awvwgk/setup-fortran@main
with:
compiler: gcc
version: ${{ env.GCC_V }}
version: ${{ env.GCC }}

- name: Setup Micromamba
uses: mamba-org/setup-micromamba@v1
Expand Down Expand Up @@ -165,7 +165,7 @@ jobs:
fi
test_gfortran:
name: Test (gfortran)
name: Test gnu fortran
needs:
- lint
- build
Expand All @@ -174,33 +174,13 @@ jobs:
strategy:
fail-fast: false
matrix:
# compatible combinations from https://github.com/awvwgk/setup-fortran#runner-compatibility
include:
- {os: ubuntu-20.04, gcc_v: 7, test: false}
- {os: ubuntu-20.04, gcc_v: 8, test: false}
- {os: ubuntu-20.04, gcc_v: 9, test: false}
- {os: ubuntu-20.04, gcc_v: 10, test: false}
- {os: ubuntu-20.04, gcc_v: 11, test: false}
- {os: ubuntu-22.04, gcc_v: 12, test: false}
# only run autotests on latest version on each platform
- {os: ubuntu-22.04, gcc_v: 13, test: true}
- {os: macos-12, gcc_v: 7, test: false}
- {os: macos-12, gcc_v: 8, test: false}
- {os: macos-12, gcc_v: 9, test: false}
- {os: macos-12, gcc_v: 10, test: false}
- {os: macos-12, gcc_v: 11, test: false}
- {os: macos-12, gcc_v: 12, test: false}
- {os: macos-12, gcc_v: 13, test: true}
- {os: windows-2022, gcc_v: 9, test: false}
- {os: windows-2022, gcc_v: 10, test: false}
- {os: windows-2022, gcc_v: 11, test: false}
- {os: windows-2022, gcc_v: 12, test: true}

os: [ ubuntu-22.04, macos-12, windows-2022 ]
defaults:
run:
shell: bash -l {0}
env:
FC: gfortran
GCC: 13
steps:
- name: Checkout modflow6
uses: actions/checkout@v4
Expand All @@ -219,11 +199,11 @@ jobs:
repository: MODFLOW-USGS/modflow6-examples
path: modflow6-examples

- name: Setup GNU Fortran ${{ matrix.gcc_v }}
- name: Setup GNU Fortran ${{ env.GCC }}
uses: awvwgk/setup-fortran@main
with:
compiler: gcc
version: ${{ matrix.gcc_v }}
version: ${{ runner.os == 'Windows' && 12 || env.GCC }}

- name: Setup Micromamba
uses: mamba-org/setup-micromamba@v1
Expand Down Expand Up @@ -251,20 +231,17 @@ jobs:
run: meson test --verbose --no-rebuild -C builddir

- name: Update flopy
if: matrix.test
working-directory: modflow6/autotest
run: python update_flopy.py

- name: Get executables
if: matrix.test
working-directory: modflow6/autotest
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
pytest -v --durations 0 get_exes.py
- name: Test modflow6
if: matrix.test
working-directory: modflow6/autotest
env:
REPOS_PATH: ${{ github.workspace }}
Expand All @@ -276,14 +253,14 @@ jobs:
fi
- name: Checkout usgslatex
if: matrix.test && runner.os == 'Linux'
if: runner.os == 'Linux'
uses: actions/checkout@v4
with:
repository: MODFLOW-USGS/usgslatex
path: usgslatex

- name: Install TeX Live
if: matrix.test && runner.os == 'Linux'
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt install texlive-science \
Expand All @@ -293,19 +270,18 @@ jobs:
texlive-fonts-extra
- name: Install USGS LaTeX style files and Univers font
if: matrix.test && runner.os == 'Linux'
if: runner.os == 'Linux'
working-directory: usgslatex/usgsLaTeX
run: sudo ./install.sh --all-users

- name: Test distribution scripts
if: matrix.test
working-directory: modflow6/distribution
env:
GITHUB_TOKEN: ${{ github.token }}
run: pytest -v --durations 0

test_intel_fortran:
name: Test (Intel)
name: Test intel fortran
needs:
- lint
- build
Expand All @@ -315,45 +291,9 @@ jobs:
fail-fast: false
matrix:
include:
### ifx
## 2022.2.x autotests disabled
# - mf5to6 test_evt: failure to converge
# - mf6 Keating_[disu_]dev: bad head comparison
- {os: ubuntu-22.04, compiler: intel, version: 2022.2.1, test: false}
- {os: ubuntu-22.04, compiler: intel, version: 2022.2, test: false}
## 2021.1 segfault in meson serial sim test
# - {os: ubuntu-22.04, compiler: intel, version: 2022.1, test: false}
## 2022.0 & 2021.[1,2,4] segfault at compile time
# - {os: ubuntu-22.04, compiler: intel, version: "2022.0", test: false}
# - {os: ubuntu-22.04, compiler: intel, version: 2021.4, test: false}
# - {os: ubuntu-22.04, compiler: intel, version: 2021.2, test: false}
# - {os: ubuntu-22.04, compiler: intel, version: 2021.1, test: false}
## ifx not yet supported on macOS
# - {os: macos-12, compiler: intel, version: 2023.2, test: true}
## 2023.[0,1] fail to compile
# - {os: windows-2022, compiler: intel, version: 2023.1, test: false}
# - {os: windows-2022, compiler: intel, version: "2023.0", test: false}
- {os: windows-2022, compiler: intel, version: 2022.2, test: false}
## 2022.1 fail to link
# - {os: windows-2022, compiler: intel, version: 2022.1, test: false}

### ifort
## only autotest latest on each platform
- {os: ubuntu-22.04, compiler: intel-classic, version: "2021.10", test: false}
- {os: ubuntu-22.04, compiler: intel-classic, version: 2021.9, test: false}
- {os: ubuntu-22.04, compiler: intel-classic, version: 2021.8, test: false}
- {os: ubuntu-22.04, compiler: intel-classic, version: 2021.7, test: true}
- {os: ubuntu-22.04, compiler: intel-classic, version: 2021.6, test: false}
- {os: macos-12, compiler: intel-classic, version: "2021.10", test: false}
- {os: macos-12, compiler: intel-classic, version: 2021.9, test: false}
- {os: macos-12, compiler: intel-classic, version: 2021.8, test: false}
- {os: macos-12, compiler: intel-classic, version: 2021.7, test: true}
- {os: macos-12, compiler: intel-classic, version: 2021.6, test: false}
- {os: windows-2022, compiler: intel-classic, version: "2021.10", test: false}
- {os: windows-2022, compiler: intel-classic, version: 2021.9, test: false}
- {os: windows-2022, compiler: intel-classic, version: 2021.8, test: false}
- {os: windows-2022, compiler: intel-classic, version: 2021.7, test: true}
- {os: windows-2022, compiler: intel-classic, version: 2021.6, test: false}
- {os: ubuntu-22.04, compiler: intel-classic, version: 2021.7}
- {os: macos-12, compiler: intel-classic, version: 2021.7}
- {os: windows-2022, compiler: intel-classic, version: 2021.7}

defaults:
run:
Expand Down Expand Up @@ -407,19 +347,16 @@ jobs:
run: meson test --verbose --no-rebuild -C builddir

- name: Update flopy
if: matrix.test
working-directory: modflow6/autotest
run: python update_flopy.py

- name: Get executables
if: matrix.test
working-directory: modflow6/autotest
env:
GITHUB_TOKEN: ${{ github.token }}
run: pytest -v --durations 0 get_exes.py

- name: Test programs
if: matrix.test
working-directory: modflow6/autotest
env:
REPOS_PATH: ${{ github.workspace }}
Expand All @@ -431,7 +368,6 @@ jobs:
fi
- name: Test scripts
if: matrix.test
working-directory: modflow6/distribution
env:
GITHUB_TOKEN: ${{ github.token }}
Expand Down
Loading

0 comments on commit f146abd

Please sign in to comment.