Skip to content

Commit

Permalink
ci: move compiler compatibility tests to separate workflow (#1390)
Browse files Browse the repository at this point in the history
* trigger weekly, on release/master branches, and manual dispatch
* autocreate compatibility report for platform/toolchain/version combos
* check in initial compatibility databases, update DEVELOPER.md
* switch awvwgk/setup-fortran -> fortran-lang/setup-fortran
* include gcc 13 on windows, bump default gcc to 13 in ci.yml
  • Loading branch information
wpbonelli authored Oct 19, 2023
1 parent c8302ca commit f895fe5
Show file tree
Hide file tree
Showing 11 changed files with 519 additions and 106 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
35 changes: 35 additions & 0 deletions .github/common/update_compat_tables.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"""
Inserts Markdown compatibility tables
between tags in target 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 table path
update_path = Path(sys.argv[3]) # path to 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))
39 changes: 39 additions & 0 deletions .github/common/wide_compat_reports.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
"""
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"

# read long CSV
df = pd.read_csv(ip)

# pivot and sort
df = pd.pivot(
df,
index="runner",
columns=["compiler", "version"],
values="support",
).sort_values(by=["runner"])

# write wide CSV
df.to_csv(op)

# write wide markdown table
with open(op.with_suffix(".md"), "w") as file:
file.write(
df.to_markdown()
.replace("nan", "")
.replace("(", "")
.replace(")", "")
.replace(",", "")
.replace("'", "")
)
9 changes: 9 additions & 0 deletions .github/compat/comp.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
compiler,gcc,gcc,gcc,gcc,gcc,gcc,gcc,intel-classic,intel-classic,intel-classic,intel-classic,intel-classic,intel-classic,intel-classic,intel-classic,intel-classic,intel-classic,intel,intel,intel,intel,intel,intel,intel,intel,intel,intel
version,10,11,12,13,7,8,9,2021.1,2021.10,2021.2,2021.3,2021.4,2021.5,2021.6,2021.7,2021.8,2021.9,2021.1,2021.2,2021.4,2022.0,2022.1,2022.2.1,2022.2,2023.0,2023.1,2023.2
runner,,,,,,,,,,,,,,,,,,,,,,,,,,,
macos-11,&check;,&check;,&check;,&check;,&check;,&check;,&check;,&check;,&check;,&check;,&check;,&check;,&check;,&check;,&check;,&check;,&check;,,,,,,,,,,
macos-12,&check;,&check;,&check;,&check;,&check;,&check;,&check;,&check;,&check;,&check;,&check;,&check;,&check;,&check;,&check;,&check;,&check;,,,,,,,,,,
ubuntu-20.04,&check;,&check;,,,&check;,&check;,&check;,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?
ubuntu-22.04,&check;,&check;,&check;,&check;,,,&check;,,&check;,,,,,&check;,&check;,&check;,&check;,,,,,,&check;,&check;,,,&check;
windows-2019,&check;,&check;,&check;,&check;,,,&check;,,&check;,,,,,,&check;,&check;,&check;,,,,,,,&check;,,,&check;
windows-2022,&check;,&check;,&check;,&check;,,,&check;,,&check;,,,,,&check;,&check;,&check;,&check;,,,,,,,&check;,,,&check;
9 changes: 9 additions & 0 deletions .github/compat/test.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
compiler,gcc,gcc,gcc,gcc,gcc,gcc,gcc,intel-classic,intel-classic,intel-classic,intel-classic,intel-classic,intel-classic,intel-classic,intel-classic,intel-classic,intel-classic,intel,intel,intel,intel,intel,intel,intel,intel,intel,intel
version,10,11,12,13,7,8,9,2021.1,2021.10,2021.2,2021.3,2021.4,2021.5,2021.6,2021.7,2021.8,2021.9,2021.1,2021.2,2021.4,2022.0,2022.1,2022.2.1,2022.2,2023.0,2023.1,2023.2
runner,,,,,,,,,,,,,,,,,,,,,,,,,,,
macos-11,&check;,&check;,&check;,&check;,&check;,&check;,&check;,&check;,,&check;,&check;,&check;,&check;,&check;,&check;,,,,,,,,,,,,
macos-12,&check;,&check;,&check;,&check;,,,,&check;,,&check;,&check;,&check;,&check;,&check;,&check;,,,,,,,,,,,,
ubuntu-20.04,&check;,&check;,,,&check;,&check;,&check;,,,,,,,,,,,,,,,,,,,,
ubuntu-22.04,&check;,&check;,&check;,&check;,,,&check;,,,,,,,&check;,&check;,,,,,,,,,,,,
windows-2019,&check;,&check;,&check;,&check;,,,,,,,,,,,&check;,,,,,,,,,,,,
windows-2022,&check;,&check;,&check;,&check;,,,&check;,,,,,,,&check;,&check;,,,,,,,,,,,,
104 changes: 20 additions & 84 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ jobs:
uses: actions/checkout@v4

- name: Setup gfortran ${{ env.GCC_V }}
uses: awvwgk/setup-fortran@main
uses: fortran-lang/setup-fortran@v1
with:
compiler: gcc
version: ${{ env.GCC_V }}
Expand Down Expand Up @@ -108,7 +108,7 @@ jobs:
shell: bash -l {0}
env:
FC: gfortran
GCC_V: 13
GCC: 13
steps:
- name: Checkout modflow6
uses: actions/checkout@v4
Expand All @@ -121,11 +121,11 @@ jobs:
repository: fortran-lang/test-drive
path: test-drive

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

- name: Setup Micromamba
uses: mamba-org/setup-micromamba@v1
Expand Down Expand Up @@ -176,7 +176,7 @@ jobs:
fi
test_gfortran:
name: Test (gfortran)
name: Test gnu fortran
needs:
- lint
- build
Expand All @@ -185,33 +185,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 @@ -230,11 +210,11 @@ jobs:
repository: MODFLOW-USGS/modflow6-examples
path: modflow6-examples

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

- name: Setup Micromamba
uses: mamba-org/setup-micromamba@v1
Expand Down Expand Up @@ -262,20 +242,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 @@ -287,14 +264,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 @@ -304,19 +281,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 @@ -326,45 +302,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 @@ -393,7 +333,7 @@ jobs:
cache-downloads: true

- name: Setup Intel Fortran
uses: awvwgk/setup-fortran@main
uses: fortran-lang/setup-fortran@v1
with:
compiler: ${{ matrix.compiler }}
version: ${{ matrix.version }}
Expand All @@ -418,19 +358,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 @@ -442,7 +379,6 @@ jobs:
fi
- name: Test scripts
if: matrix.test
working-directory: modflow6/distribution
env:
GITHUB_TOKEN: ${{ github.token }}
Expand Down Expand Up @@ -492,7 +428,7 @@ jobs:
mpi: msmpi

- name: Setup GNU Fortran ${{ env.GCC_V }}
uses: awvwgk/setup-fortran@main
uses: fortran-lang/setup-fortran@v1
with:
compiler: gcc
version: ${{ env.GCC_V }}
Expand Down
Loading

0 comments on commit f895fe5

Please sign in to comment.