From 74bcb07615571b156c794841ca2615fb72ac5c54 Mon Sep 17 00:00:00 2001 From: Joseph D Hughes Date: Sun, 16 Jun 2024 10:40:13 -0500 Subject: [PATCH] ci: update workflows --- .github/workflows/{pymake-gcc.yml => ci.yml} | 36 ++++++-- .../workflows/{main.yml => pymake-intel.yml} | 2 +- .gitignore | 1 + autotest/test_mflgr.py | 34 ------- autotest/test_mfnwt.py | 91 ------------------- autotest/test_triangle_makefile.py | 69 -------------- pixi.toml | 3 +- 7 files changed, 29 insertions(+), 207 deletions(-) rename .github/workflows/{pymake-gcc.yml => ci.yml} (63%) rename .github/workflows/{main.yml => pymake-intel.yml} (98%) delete mode 100644 autotest/test_mflgr.py delete mode 100644 autotest/test_mfnwt.py delete mode 100644 autotest/test_triangle_makefile.py diff --git a/.github/workflows/pymake-gcc.yml b/.github/workflows/ci.yml similarity index 63% rename from .github/workflows/pymake-gcc.yml rename to .github/workflows/ci.yml index d514ba78..32f6eca9 100644 --- a/.github/workflows/pymake-gcc.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -name: pymake gcc build +name: pymake continuous integration on: schedule: @@ -19,7 +19,7 @@ concurrency: cancel-in-progress: true jobs: - pymakeCI-os-gcc: + pymakeCI-os-compiler: name: pymake CI gcc on different OSs runs-on: ${{ matrix.os }} strategy: @@ -27,12 +27,16 @@ jobs: matrix: include: # test latest gcc and python - - {os: ubuntu-latest, gcc: 13} - - {os: windows-latest, gcc: 13} - - {os: macos-latest, gcc: 13} + - {os: ubuntu-latest, FC: gcc, FC_V: 13} + - {os: windows-latest, FC: gcc, FC_V: 13} + - {os: macos-latest, FC: gcc, FC_V: 13} # test latest python and previous gcc - - {os: ubuntu-latest, gcc: 12} - - {os: ubuntu-latest, gcc: 11} + - {os: ubuntu-latest, FC: gcc, FC_V: 12} + - {os: ubuntu-latest, FC: gcc, FC_V: 11} + # test latest python and intel + - {os: ubuntu-latest, FC: intel-classic, FC_V: 2021.7} + - {os: windows-latest, FC: intel-classic, FC_V: 2021.7} + - {os: macos-13, FC: intel-classic, FC_V: 2021.7} defaults: run: shell: bash @@ -41,6 +45,11 @@ jobs: - name: Checkout repo uses: actions/checkout@v4 + - uses: maxim-lobanov/setup-xcode@v1 + if: ${{ (runner.os == 'macOS') && (matrix.FC == 'intel-classic') }} + with: + xcode-version: "14.3.1" + - name: Setup Graphviz on Linux if: runner.os == 'Linux' uses: ts-graphviz/setup-graphviz@v2 @@ -56,11 +65,11 @@ jobs: run: | pixi run postinstall - - name: Setup GNU Fortran + - name: Setup ${{ env.FC }} ${{ env.FC_V }} uses: fortran-lang/setup-fortran@main with: - compiler: gcc - version: ${{ matrix.gcc }} + compiler: ${{ matrix.FC }} + version: ${{ matrix.FC_V }} - name: Download examples for pytest runs run: | @@ -81,6 +90,13 @@ jobs: run: | pixi run autotest-Windows + - name: Upload failed test output + if: failure() + uses: actions/upload-artifact@v4 + with: + name: failed-${{ matrix.os }}-${{ matrix.FC }}-${{ matrix.FC_V }} + path: ./autotest/.failed + - name: Print coverage report before upload run: | pixi run coverage-report diff --git a/.github/workflows/main.yml b/.github/workflows/pymake-intel.yml similarity index 98% rename from .github/workflows/main.yml rename to .github/workflows/pymake-intel.yml index 8c901ed5..fe4f0fbc 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/pymake-intel.yml @@ -1,4 +1,4 @@ -name: pymake continuous integration +name: pymake continuous integration intel on: schedule: diff --git a/.gitignore b/.gitignore index f700a606..66ff0ef3 100644 --- a/.gitignore +++ b/.gitignore @@ -66,6 +66,7 @@ target/ # files in the autotest directory autotest/temp*/ +autotest/.failed/ autotest/*.json autotest/code.md mod_temp/ diff --git a/autotest/test_mflgr.py b/autotest/test_mflgr.py deleted file mode 100644 index 1de8c968..00000000 --- a/autotest/test_mflgr.py +++ /dev/null @@ -1,34 +0,0 @@ -from pathlib import Path - -import pytest - -import pymake - - -@pytest.fixture(scope="module") -def target(module_tmpdir) -> Path: - target = "mflgr" - return module_tmpdir / target - - -@pytest.fixture(scope="module") -def prog_dict(target) -> dict: - return pymake.usgs_program_data.get_target(target) - - -@pytest.fixture(scope="module") -def workspace(module_tmpdir, prog_dict) -> Path: - return module_tmpdir / prog_dict.dirname - - -def compile_code(ws, exe): - return pymake.build_apps( - str(exe), download_dir=ws, appdir=ws, verbose=True - ) - - -@pytest.mark.base -def test_compile(module_tmpdir, target): - assert ( - compile_code(module_tmpdir, target) == 0 - ), f"could not compile {target}" diff --git a/autotest/test_mfnwt.py b/autotest/test_mfnwt.py deleted file mode 100644 index f7cb8013..00000000 --- a/autotest/test_mfnwt.py +++ /dev/null @@ -1,91 +0,0 @@ -import os -import sys -import time -from pathlib import Path - -import pytest -from modflow_devtools.misc import set_dir - -import pymake - - -@pytest.fixture(scope="module") -def target(module_tmpdir) -> str: - target = "mfnwt" - return module_tmpdir / target - - -@pytest.fixture(scope="module") -def prog_data(target) -> dict: - return pymake.usgs_program_data.get_target(target.name) - - -@pytest.fixture(scope="module") -def workspace(module_tmpdir, prog_data) -> Path: - return module_tmpdir / prog_data.dirname - - -@pytest.fixture(scope="module") -def pm(module_tmpdir, target) -> pymake.Pymake: - pm = pymake.Pymake(verbose=True) - pm.target = str(target) - pm.appdir = str(module_tmpdir) - pm.makefile = True - pm.makefiledir = str(module_tmpdir) - pm.inplace = True - pm.dryrun = False - pm.verbose = True - yield pm - pm.finalize() - - -def build_with_makefile(ws): - success = True - with set_dir(ws): - if os.path.isfile("makefile"): - # wait to delete on windows - if sys.platform.lower() == "win32": - time.sleep(6) - - # clean prior to make - print(f"clean {target} with makefile") - os.system("make clean") - - # build MODFLOW-NWT with makefile - print(f"build {target} with makefile") - return_code = os.system("make") - - # test if running on Windows with ifort, if True the makefile - # should fail - errmsg = f"{target} created by makefile does not exist." - if sys.platform.lower() == "win32" and pm.fc == "ifort": - if return_code != 0: - success = True - else: - success = False - # verify that MODFLOW-NWT was made - else: - success = os.path.isfile(target) - else: - errmsg = "makefile does not exist" - - assert success, errmsg - - -@pytest.mark.dependency(name="download") -@pytest.mark.base -def test_download(pm, module_tmpdir, target): - pm.download_target(target, download_path=module_tmpdir) - assert pm.download, f"could not download {target} distribution" - - -@pytest.mark.dependency(name="build", depends=["download"]) -@pytest.mark.base -def test_compile(pm, target): - assert pm.build() == 0, f"could not compile {target}" - - -@pytest.mark.dependency(name="makefile", depends=["build"]) -@pytest.mark.base -def test_makefile(workspace): - build_with_makefile(workspace) diff --git a/autotest/test_triangle_makefile.py b/autotest/test_triangle_makefile.py deleted file mode 100644 index 45579d87..00000000 --- a/autotest/test_triangle_makefile.py +++ /dev/null @@ -1,69 +0,0 @@ -import os -import sys - -import flopy -import pytest - -import pymake - - -@pytest.mark.base -def test_pymake_makefile(module_tmpdir): - target = "triangle" - pm = pymake.Pymake(verbose=True) - pm.makefile = True - pm.makeclean = True - # pm.cc = "gcc" - - if sys.platform.lower() == "win32": - if pm.cc == "icl": - return - target += ".exe" - - # get current directory - cwd = os.getcwd() - - # change to working directory so triangle download directory is - # a subdirectory in the working directory - os.chdir(module_tmpdir) - - # build triangle and makefile - assert ( - pymake.build_apps(target, clean=False, pymake_object=pm) == 0 - ), f"could not build {target}" - - if os.path.isfile(os.path.join(module_tmpdir, "makefile")): - print("cleaning with GNU make") - # clean prior to make - print(f"clean {target} with makefile") - success, _ = flopy.run_model( - "make", - None, - cargs="clean", - model_ws=module_tmpdir, - report=True, - normal_msg="rm -rf ./triangle", - silent=False, - ) - - # build triangle with makefile - if success: - print(f"build {target} with makefile") - success, _ = flopy.run_model( - "make", - None, - model_ws=module_tmpdir, - report=True, - normal_msg="cc -O2 -o triangle ./obj_temp/triangle.o", - silent=False, - ) - - # finalize Pymake object - pm.finalize() - - # return to starting directory - os.chdir(cwd) - - assert os.path.isfile( - os.path.join(module_tmpdir, target) - ), f"could not build {target} with makefile" diff --git a/pixi.toml b/pixi.toml index 589bea5c..63f34b44 100644 --- a/pixi.toml +++ b/pixi.toml @@ -34,9 +34,8 @@ postinstall = "pip install --no-build-isolation --no-deps --disable-pip-version- # format check-lint = "ruff check ." -fix-lint = "ruff check . --fix" check-format = "ruff format . --check" -fix-format = "ruff format ." +fix-style = "ruff check . --fix; ruff format ." # build test = "meson test --verbose --no-rebuild -C"