Skip to content

Commit

Permalink
* update request ci to use pixi
Browse files Browse the repository at this point in the history
  • Loading branch information
jdhughes-usgs committed Jun 16, 2024
1 parent 74bcb07 commit 133ab83
Show file tree
Hide file tree
Showing 14 changed files with 148 additions and 143 deletions.
89 changes: 73 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,90 @@ concurrency:
cancel-in-progress: true
jobs:

pymakeCI-os-compiler:
pymake-schedule:
name: pymake CI gcc on different OSs
if: ${{ github.event_name == 'schedule' }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# test latest gcc and python
- {os: ubuntu-latest, FC: gcc, FC_V: 13}
- {os: macos-latest, FC: gcc, FC_V: 13}
- {os: windows-latest, FC: gcc, FC_V: 13}
# test latest python and intel
- {os: ubuntu-latest, FC: intel-classic, FC_V: 2021.7}
- {os: macos-13, FC: intel-classic, FC_V: 2021.7}
- {os: windows-2019, FC: intel-classic, FC_V: 2021.7}
defaults:
run:
shell: bash

steps:
- 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

- name: Setup pixi
uses: prefix-dev/setup-pixi@v0.8.1
with:
pixi-version: v0.19.1
manifest-path: "pixi.toml"

- name: pixi post-install
working-directory: pymake
run: |
pixi run postinstall
- name: Setup ${{ matrix.FC }} ${{ matrix.FC_V }} on ${{ matrix.os }}
uses: fortran-lang/setup-fortran@main
with:
compiler: ${{ matrix.FC }}
version: ${{ matrix.FC_V }}

- name: Install make
if: runner.os == 'Windows'
run: choco install make

- name: Run scheduled tests
run: |
pixi run autotest-schedule
- name: Upload failed test output
if: failure()
uses: actions/upload-artifact@v4
with:
name: failed-schedule-${{ matrix.os }}-${{ matrix.FC }}-${{ matrix.FC_V }}
path: ./autotest/.failed


pymake-os-compiler:
name: pymake CI gcc on different OSs
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# test latest gcc and python
- {os: ubuntu-latest, FC: gcc, FC_V: 13}
- {os: macos-latest, FC: gcc, FC_V: 13}
- {os: windows-latest, FC: gcc, FC_V: 13}
# test latest python and intel-classic
- {os: ubuntu-latest, FC: intel-classic, FC_V: 2021.7}
- {os: macos-13, FC: intel-classic, FC_V: 2021.7}
- {os: windows-2019, FC: intel-classic, FC_V: 2021.7}
# test latest python and previous gcc
- {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
Expand Down Expand Up @@ -65,7 +131,7 @@ jobs:
run: |
pixi run postinstall
- name: Setup ${{ env.FC }} ${{ env.FC_V }}
- name: Setup ${{ matrix.FC }} ${{ matrix.FC_V }} on ${{ matrix.os }}
uses: fortran-lang/setup-fortran@main
with:
compiler: ${{ matrix.FC }}
Expand Down Expand Up @@ -96,14 +162,5 @@ jobs:
with:
name: failed-${{ matrix.os }}-${{ matrix.FC }}-${{ matrix.FC_V }}
path: ./autotest/.failed

- name: Print coverage report before upload
run: |
pixi run coverage-report

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
file: ./autotest/coverage.xml

32 changes: 16 additions & 16 deletions .github/workflows/pymake-requests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,32 +30,32 @@ jobs:
- name: Checkout repo
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
- name: Setup pixi
uses: prefix-dev/setup-pixi@v0.8.1
with:
python-version: "3.12"
pixi-version: v0.19.1
manifest-path: "pixi.toml"

- name: Install python packages
- name: pixi post-install
working-directory: pymake
run: |
python -m pip install --upgrade pip
pip install ".[test]"
pixi run postinstall
- name: Run pytest
working-directory: ./autotest
run: |
pytest -v -n=auto -m requests --durations=0 --cov=pymake --cov-report=xml
pixi run autotest-request
- name: Run scheduled tests
if: ${{ github.event_name == 'schedule' }}
working-directory: ./autotest
run: |
pytest -v -m="schedule" --durations=0 --cov=pymake --cov-report=xml
- name: Upload failed test output
if: failure()
uses: actions/upload-artifact@v4
with:
name: failed-requests
path: ./autotest/.failed

- name: Print coverage report before upload
working-directory: ./autotest
run: |
coverage report
pixi run coverage-report
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
env:
Expand Down
15 changes: 9 additions & 6 deletions autotest/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@
RERUNS = 3

targets = pymake.usgs_program_data.get_keys(current=True)
targets_make = [
t
for t in targets
if t not in ("libmf6", "gridgen", "mf2000", "swtv4", "mflgr")
]
test_ostag = get_ostag()
test_fc_env = os.environ.get("FC")
if "win" in test_ostag:
Expand All @@ -27,6 +22,15 @@
meson_exclude = ("sutra",)
targets_meson = [t for t in targets if t not in meson_exclude]

if "win" in test_ostag and test_fc_env in ("ifort",):
targets_make = []
else:
targets_make = [
t
for t in targets
if t not in ("libmf6", "gridgen", "mf2000", "swtv4", "mflgr")
]


def build_with_makefile(target, path, fc):
success = True
Expand Down Expand Up @@ -103,7 +107,6 @@ def test_meson_build(function_tmpdir, target: str) -> None:

@pytest.mark.base
@flaky(max_runs=RERUNS)
@pytest.mark.skipif(sys.platform == "win32", reason="do not run on Windows")
@pytest.mark.parametrize("target", targets_make)
def test_makefile_build(function_tmpdir, target: str) -> None:
pm = pymake.Pymake(verbose=True)
Expand Down
55 changes: 29 additions & 26 deletions autotest/test_cli_cmds.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,43 +46,46 @@ def run_cli_cmd(cmd: list) -> None:
@pytest.mark.base
@pytest.mark.parametrize("target", targets)
def test_make_program(function_tmpdir, target: str) -> None:
cmd = [
"make-program",
target,
"--appdir",
str(function_tmpdir),
"--verbose",
]
run_cli_cmd(cmd)
with set_dir(function_tmpdir):
cmd = [
"make-program",
target,
"--appdir",
str(function_tmpdir),
"--verbose",
]
run_cli_cmd(cmd)


@flaky(max_runs=RERUNS)
@pytest.mark.dependency(name="make_program")
@pytest.mark.base
def test_make_program_double(function_tmpdir) -> None:
cmd = [
"make-program",
"mf2005",
"--double",
"--verbose",
"--appdir",
str(function_tmpdir),
]
run_cli_cmd(cmd)
with set_dir(function_tmpdir):
cmd = [
"make-program",
"mf2005",
"--double",
"--verbose",
"--appdir",
str(function_tmpdir),
]
run_cli_cmd(cmd)


@pytest.mark.dependency(name="make_program_all")
@pytest.mark.schedule
def test_make_program_all(module_tmpdir) -> None:
cmd = [
"make-program",
":",
"--appdir",
str(module_tmpdir / "all"),
"--verbose",
"--dryrun",
]
run_cli_cmd(cmd)
with set_dir(module_tmpdir):
cmd = [
"make-program",
":",
"--appdir",
str(module_tmpdir / "all"),
"--verbose",
"--dryrun",
]
run_cli_cmd(cmd)


@flaky(max_runs=RERUNS)
Expand Down
4 changes: 2 additions & 2 deletions autotest/test_gridgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ def run_gridgen(cmd, ws, exe):


@pytest.mark.dependency(name="download")
@pytest.mark.base
@pytest.mark.regression
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
@pytest.mark.regression
def test_compile(pm, target):
assert pm.build() == 0, f"could not compile {target}"

Expand Down
4 changes: 2 additions & 2 deletions autotest/test_mf2005.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ def run_mf2005(namefile, ws, exe):


@pytest.mark.dependency(name="download")
@pytest.mark.base
@pytest.mark.regression
def test_download(pm, module_tmpdir, target):
pm.download_target(target, download_path=module_tmpdir)
assert pm.download, f"could not download {target}"


@pytest.mark.dependency(name="build", depends=["download"])
@pytest.mark.base
@pytest.mark.regression
def test_compile(pm, target):
assert pm.build() == 0, f"could not compile {target}"

Expand Down
40 changes: 2 additions & 38 deletions autotest/test_mf6.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,14 @@ def build_with_makefile(pm, workspace, exe):


@pytest.mark.dependency(name="download")
@pytest.mark.base
@pytest.mark.regression
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
@pytest.mark.regression
def test_compile(pm, target):
assert pm.build() == 0, f"could not compile {target}"

Expand All @@ -118,39 +118,3 @@ def test_compile(pm, target):
def test_mf6(ws, target):
success, _ = flopy.run_model(target, None, model_ws=ws, silent=False)
assert success, f"could not run {ws}"


@pytest.mark.dependency(name="makefile", depends=["build"])
@pytest.mark.base
def test_makefile(pm, module_tmpdir, target):
assert build_with_makefile(
pm, module_tmpdir, target
), f"could not compile {target} with makefile"


@pytest.mark.dependency(name="shared", depends=["makefile"])
@pytest.mark.base
def test_sharedobject(pm, module_tmpdir, workspace, target_so, prog_data):
# reconfigure pymake object
pm.target = str(target_so)
pm.appdir = module_tmpdir
pm.srcdir = workspace / prog_data.srcdir
pm.srcdir2 = workspace / "src"
pm.excludefiles = [os.path.join(pm.srcdir2, "mf6.f90")]
pm.makefile = True
pm.makeclean = True
pm.sharedobject = True
pm.inplace = True
pm.dryrun = False

# build the target
assert pm.build() == 0, f"could not compile {pm.target}"
assert target_so.is_file()


@pytest.mark.dependency(name="shared_makefile", depends=["shared", "makefile"])
@pytest.mark.base
def test_sharedobject_makefile(pm, module_tmpdir, target_so):
assert build_with_makefile(
pm, module_tmpdir, target_so
), f"could not compile {target_so} with makefile"
6 changes: 3 additions & 3 deletions autotest/test_mfusg.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def run_mfusg(fn, exe):


@pytest.mark.dependency(name="download")
@pytest.mark.base
@pytest.mark.regrression
def test_download(pm, pm_gsi, module_tmpdir, targets):
pm.download_target(targets[0], download_path=module_tmpdir)
assert pm.download, f"could not download {targets[0]}"
Expand All @@ -78,7 +78,7 @@ def test_download(pm, pm_gsi, module_tmpdir, targets):


@pytest.mark.dependency(name="build", depends=["download"])
@pytest.mark.base
@pytest.mark.regression
def test_compile(pm, pm_gsi, targets):
assert pm.build() == 0, f"could not compile {targets[0]}"
assert (targets[0]).is_file()
Expand All @@ -87,7 +87,7 @@ def test_compile(pm, pm_gsi, targets):
assert targets[1].is_file()


@pytest.mark.dependency(name="test", depends=["build"])
@pytest.mark.dependency(name="test", depends=["download", "build"])
@pytest.mark.regression
@pytest.mark.parametrize(
"namefile",
Expand Down
Loading

0 comments on commit 133ab83

Please sign in to comment.