Skip to content

Commit

Permalink
Merge pull request #724 from carlosmunozmoncayo/additionalchanges
Browse files Browse the repository at this point in the history
Additional changes to Pytest-based tests and CI workflow
  • Loading branch information
ketch authored Aug 8, 2024
2 parents 1d7ba17 + 840b488 commit a16a609
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 5 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Test PyClaw

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

workflow_dispatch:

permissions:
contents: read

env:
CLAW: ${{ github.workspace }}

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install gfortran
python -m pip install --upgrade pip
pip install 'numpy<2.0'
pip install matplotlib #Some imports require matplotlib
pip install scipy #To not skip tests
pip install flake8 meson-python ninja pytest
# if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Checkout Clawpack
uses: actions/[email protected]
with:
repository: clawpack/clawpack
submodules: true

- name: Checkout PyClaw branch
uses: actions/[email protected]
with:
path: pyclaw

- name: Install clawpack
run: |
cd ${CLAW}
pip install --no-build-isolation --editable .
- name: Test with pytest
run: |
cd ${CLAW}/pyclaw
pytest --ignore=development
5 changes: 1 addition & 4 deletions examples/euler_gravity_3d/test_eulerg3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,12 @@ class TestEulerGravity3D:

def test_rising_hot_sphere(self):
_ = importorskip("scipy") # skip test if scipy is not installed
#Compile source
command = ["make", "all"]
subprocess.call(command,cwd=thisdir)

# Read expected solution
expected_density = np.loadtxt(os.path.join(thisdir,'verify_rising_hot_sphere_classic_1.txt'))

#Run test
import rising_hot_sphere
from . import rising_hot_sphere
claw = rising_hot_sphere.euler3d(kernel_language='Fortran',solver_type='classic',
disable_output=True,mx=80, my=80, mz=80, tfinal=1.0, num_output_times=1)
claw.run()
Expand Down
2 changes: 1 addition & 1 deletion examples/shallow_2d/test_shallow2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def test_radialdambreak(self):
for riemann_solver in riemann_solvers:
test_name = f'radialdambreak_{solver_type}_{riemann_solver}'
assert error(test_name=test_name, solver_type=solver_type,
riemann_solver=riemann_solver, disable_output=True)<1e-6, f"Test {test_name} failed"
riemann_solver=riemann_solver, disable_output=True)<1e-5, f"Test {test_name} failed"

def test_sill(self):
assert error(test_name="sill", outdir=None)<1e-6, f"Test sill failed"
Expand Down

0 comments on commit a16a609

Please sign in to comment.