Skip to content

Commit

Permalink
Add regression testing continuous integration.
Browse files Browse the repository at this point in the history
  • Loading branch information
dbhart committed Sep 9, 2024
1 parent 440d617 commit e4ec14f
Show file tree
Hide file tree
Showing 14 changed files with 3,287 additions and 44 deletions.
81 changes: 81 additions & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Continuous Integration

on:
push:
branches:
- main
pull_request:
workflow_dispatch:

defaults:
run:
shell: bash

permissions:
contents: read

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
version: ["3.9", "3.10", "3.11", "3.12"]
steps:

- name: Harden Runner
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
with:
egress-policy: audit

- name: Check out the commit
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ~${{ matrix.version }}

- name: Install development dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install -r requirements.txt
- name: Test install
run: python3 -m pip install .[test,dev,docs]

- name: Test with pytest
run: python3 -m pytest --cov=src\python\sansmic examples/ tests/

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

# - name: Check documentation coverage
# run: |
# make coverage
# mv build/coverage/python.txt ../docs-coverage-report-${{ matrix.version }}.txt
# working-directory: ./docs

# - name: Archive documentation coverage results
# uses: actions/upload-artifact@v3
# with:
# name: docs-coverage-report-${{ matrix.version }}
# path: docs-coverage-report-${{ matrix.version }}.txt

- name: Test uninstall
run: python3 -m pip uninstall -y my-repository-name

commits:
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
with:
egress-policy: audit

- name: Conventional Commits
uses: taskmedia/action-conventional-commits@9148865058f63a6cb560ff4bfd7d534505f43646 # v1.1.3
with:
types: >
build|chore|ci|docs|feat|fix|minor|patch|perf|style|refactor|test
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
breathe_domain_by_extension = {"hpp": "cpp"}
breathe_projects_source = {
"libsansmic": (
"../src/ext_modules/libsansmic",
"",
glob.glob("../src/ext_modules/libsansmic/*"),
)
}
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ classifiers = [
[project.optional-dependencies]
formats = ['h5py', 'openpyxl', 'tabulate']
docs = ['Sphinx', 'pydata-sphinx-theme', 'sphinx_design', 'sphinxcontrib-bibtex', 'breathe', 'exhale', 'sphinx-argparse']
test = ['unittest']
test = ['unittest', 'pytest', 'pytest-cov', 'black']
dev = ['pre-commit', 'pyproject_hooks', 'black', 'pybind11']

[project.urls]
Expand Down
4 changes: 4 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@ numpy
pandas
pyyaml
pre-commit
pytest
pytest-cov
black
pybind11
2 changes: 1 addition & 1 deletion src/python/sansmic/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ def convert():
args = parser.parse_args()
infile = args.infile
logger.debug("Running sansmic-convert")
model = sio.read_scenario(infile, warn=not args.quiet)
model = sio.read_scenario(infile)
logger.debug("Successfully created scenario from {}".format(infile))
sio.write_scenario(model, args.outfile, redundant=args.full)
logger.debug("Successfully wrote scenario to {}".format(args.outfile))
8 changes: 5 additions & 3 deletions src/python/sansmic/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -653,11 +653,13 @@ def _to_cstage(self, defaults=None) -> _ext.CStage:
(self.injection_duration + self.rest_duration) / stage.timestep
)
)
elif self.save_frequency is not None:
stage.print_interval = self.save_frequency
else:
stage.print_interval = int(self.save_frequency)
elif isinstance(self.save_frequency, (int, float)):
stage.print_interval = int(self.save_frequency)
else:
stage.print_interval = defaults.get(
"solver_timestep", int(np.round(24.0 / stage.timestep))
"save_frequency", int(np.round(24.0 / stage.timestep))
)
stage.subsequent = 0 if self.set_initial_conditions else 1
stage.rest_duration = self.rest_duration
Expand Down
28 changes: 14 additions & 14 deletions tests/baseline.dat
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Ordinary leaching - direct
100 0 2400 0 0 600 1 0 0
1000. 32.0 680.0 700.0 20.0
Witdrawal leaching - initial
100 1 12000 0 0 480 1 0 0
1000. 32.0 1000.0 350.0 20.0
240000.0
4.925 5.3750 4.925 5.3750
1.03 1.2019
Expand Down Expand Up @@ -108,28 +108,28 @@ Ordinary leaching - direct
2
2
1.0 0.05 4000. 4000.
Ordinary leaching - reverse
100 0 2400 1 0 600 1 0 0
1000. 680.0 32.0 0.0 20.0
Ordinary leaching - direct
100 0 12000 1 0 480 1 0 0
1000. 32.0 600.0 0.0 20.0
240000.0
4.925 5.3750 4.925 5.3750
1.03 0.0
0.01 120
0.0 0.0 0.0
Leach fill
100 2 2400 1 0 600 1 0 0
1000. 480.0 32.0 0.0 20.0
Ordinary leaching - reverse
100 0 12000 1 0 480 1 0 0
1000. 600.0 32.0 0.0 20.0
240000.0
4.925 5.3750 4.925 5.3750
1.03 0.0
0.01 120
240000.0 0.0 0.0
Withdrawal leaching
100 1 2400 1 0 600 1 0 0
1000. 680.0 32.0 0.0 20.0
0.0 0.0 0.0
Leach fill
100 2 12000 1 0 480 1 0 0
1000. 32.0 350.0 0.0 20.0
240000.0
4.925 5.3750 4.925 5.3750
1.03 0.0
0.01 120
0.0 0.0 0.0
240000.0 0.0 0.0
END
102 changes: 102 additions & 0 deletions tests/baseline.ddl
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
DEPTH R0 DRs-->
101 3.0000E+03 2.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00
100 3.0100E+03 2.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00
99 3.0200E+03 2.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00
98 3.0300E+03 2.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00
97 3.0400E+03 2.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00
96 3.0500E+03 2.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00
95 3.0600E+03 2.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00
94 3.0700E+03 2.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00
93 3.0800E+03 2.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00
92 3.0900E+03 2.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00
91 3.1000E+03 2.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00
90 3.1100E+03 2.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00
89 3.1200E+03 2.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00
88 3.1300E+03 2.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00
87 3.1400E+03 2.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00
86 3.1500E+03 2.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00
85 3.1600E+03 2.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00
84 3.1700E+03 2.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00
83 3.1800E+03 2.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00
82 3.1900E+03 2.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00
81 3.2000E+03 2.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00
80 3.2100E+03 2.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00
79 3.2200E+03 2.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00
78 3.2300E+03 2.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00
77 3.2400E+03 2.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00
76 3.2500E+03 2.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00
75 3.2600E+03 2.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00
74 3.2700E+03 1.0000E+01 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00
73 3.2800E+03 3.5000E+01 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00
72 3.2900E+03 5.0000E+01 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00
71 3.3000E+03 7.5000E+01 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00
70 3.3100E+03 7.5000E+01 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00
69 3.3200E+03 7.5000E+01 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00
68 3.3300E+03 7.5000E+01 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00
67 3.3400E+03 7.5000E+01 1.6794E+00 3.9976E+00 1.2351E+01 1.2352E+01
66 3.3500E+03 7.5000E+01 1.6948E+00 3.9813E+00 1.2041E+01 1.2059E+01
65 3.3600E+03 7.5000E+01 1.7166E+00 4.0037E+00 1.2030E+01 1.2064E+01
64 3.3700E+03 7.5000E+01 1.7380E+00 4.0259E+00 1.2008E+01 1.2057E+01
63 3.3800E+03 7.5000E+01 1.7591E+00 4.0481E+00 1.1971E+01 1.2037E+01
62 3.3900E+03 7.5000E+01 1.7800E+00 4.0697E+00 1.1918E+01 1.1998E+01
61 3.4000E+03 7.5000E+01 1.8004E+00 4.0912E+00 1.1841E+01 1.1937E+01
60 3.4100E+03 7.5000E+01 1.8206E+00 4.1132E+00 1.1730E+01 1.1840E+01
59 3.4200E+03 7.5000E+01 1.8404E+00 4.1351E+00 1.1546E+01 1.1671E+01
58 3.4300E+03 7.5000E+01 1.8599E+00 4.1568E+00 1.0054E+01 1.0186E+01
57 3.4400E+03 7.5000E+01 1.8791E+00 4.1786E+00 9.8364E+00 9.9762E+00
56 3.4500E+03 7.5000E+01 1.8978E+00 4.2001E+00 9.5632E+00 9.7106E+00
55 3.4600E+03 7.5000E+01 1.9161E+00 4.2215E+00 9.3363E+00 9.4921E+00
54 3.4700E+03 7.5000E+01 1.9340E+00 4.2428E+00 9.1451E+00 9.3102E+00
53 3.4800E+03 7.5000E+01 1.9514E+00 4.2641E+00 8.9828E+00 9.1580E+00
52 3.4900E+03 7.5000E+01 1.9690E+00 4.2887E+00 8.8538E+00 9.0414E+00
51 3.5000E+03 7.5000E+01 2.1430E+00 4.6468E+00 9.4094E+00 9.6241E+00
50 3.5100E+03 8.8000E+01 2.1597E+00 4.6544E+00 9.2488E+00 9.4830E+00
49 3.5200E+03 8.8000E+01 2.0217E+00 4.3341E+00 8.4962E+00 8.7398E+00
48 3.5300E+03 8.8000E+01 2.0376E+00 4.3252E+00 8.3596E+00 8.6298E+00
47 3.5400E+03 8.8000E+01 2.0384E+00 4.2879E+00 8.1710E+00 8.4690E+00
46 3.5500E+03 8.8000E+01 2.0185E+00 4.2420E+00 7.9788E+00 8.3053E+00
45 3.5600E+03 8.8000E+01 2.0082E+00 4.2130E+00 7.7942E+00 8.1506E+00
44 3.5700E+03 8.8000E+01 2.0030E+00 4.1934E+00 7.6108E+00 7.9985E+00
43 3.5800E+03 8.8000E+01 2.0003E+00 4.1794E+00 7.4296E+00 7.8496E+00
42 3.5900E+03 8.8000E+01 1.9988E+00 4.1689E+00 7.2482E+00 7.7017E+00
41 3.6000E+03 8.8000E+01 1.9978E+00 4.1604E+00 7.0644E+00 7.5523E+00
40 3.6100E+03 8.8000E+01 1.9968E+00 4.1532E+00 6.8765E+00 9.4072E+00
39 3.6200E+03 8.8000E+01 1.9955E+00 4.1465E+00 6.6842E+00 9.2043E+00
38 3.6300E+03 8.8000E+01 1.9937E+00 4.1401E+00 6.4882E+00 9.0042E+00
37 3.6400E+03 8.8000E+01 1.9912E+00 4.1336E+00 6.2902E+00 8.8019E+00
36 3.6500E+03 8.8000E+01 1.9882E+00 4.1271E+00 6.0932E+00 8.5910E+00
35 3.6600E+03 8.8000E+01 1.9846E+00 4.1204E+00 5.9007E+00 8.3512E+00
34 3.6700E+03 8.8000E+01 1.9812E+00 4.1142E+00 5.7174E+00 8.1396E+00
33 3.6800E+03 8.8000E+01 1.9788E+00 4.1115E+00 5.5508E+00 7.9540E+00
32 3.6900E+03 8.8000E+01 2.1166E+00 4.3991E+00 5.7414E+00 8.2999E+00
31 3.7000E+03 1.0000E+02 2.1120E+00 4.3856E+00 5.6182E+00 8.1493E+00
30 3.7100E+03 1.0000E+02 1.9711E+00 4.0955E+00 5.1419E+00 7.5063E+00
29 3.7200E+03 1.0000E+02 1.9692E+00 4.0920E+00 5.0329E+00 7.3899E+00
28 3.7300E+03 1.0000E+02 1.9675E+00 4.0887E+00 4.9515E+00 7.3018E+00
27 3.7400E+03 1.0000E+02 1.9659E+00 4.0858E+00 4.8931E+00 7.2377E+00
26 3.7500E+03 1.0000E+02 1.9645E+00 4.0830E+00 4.8526E+00 7.1923E+00
25 3.7600E+03 1.0000E+02 1.9632E+00 4.0805E+00 4.8254E+00 7.1609E+00
24 3.7700E+03 1.0000E+02 1.9620E+00 4.0781E+00 4.8077E+00 7.1395E+00
23 3.7800E+03 1.0000E+02 1.9609E+00 4.0760E+00 4.7965E+00 7.1250E+00
22 3.7900E+03 1.0000E+02 1.9599E+00 4.0739E+00 4.7907E+00 7.1163E+00
21 3.8000E+03 1.0000E+02 1.9589E+00 4.0721E+00 4.7877E+00 7.1107E+00
20 3.8100E+03 1.0000E+02 1.9580E+00 4.0703E+00 4.7857E+00 7.1063E+00
19 3.8200E+03 1.0000E+02 1.9572E+00 4.0686E+00 4.7840E+00 7.1024E+00
18 3.8300E+03 1.0000E+02 1.9564E+00 4.0671E+00 4.7825E+00 7.0989E+00
17 3.8400E+03 1.0000E+02 1.9556E+00 4.0656E+00 4.7810E+00 7.0957E+00
16 3.8500E+03 1.0000E+02 1.9549E+00 4.0642E+00 4.7796E+00 7.0926E+00
15 3.8600E+03 1.0000E+02 1.9543E+00 4.0629E+00 4.7783E+00 7.0898E+00
14 3.8700E+03 1.0000E+02 1.9536E+00 4.0617E+00 4.7771E+00 7.0872E+00
13 3.8800E+03 1.0000E+02 1.9531E+00 4.0605E+00 4.7759E+00 7.0847E+00
12 3.8900E+03 1.0000E+02 1.9525E+00 4.0594E+00 4.7748E+00 7.0824E+00
11 3.9000E+03 1.0000E+02 1.9520E+00 4.0583E+00 4.7737E+00 7.0802E+00
10 3.9100E+03 1.0000E+02 1.9515E+00 4.0573E+00 4.7727E+00 7.0781E+00
9 3.9200E+03 1.0000E+02 1.9510E+00 4.0564E+00 4.7718E+00 7.0762E+00
8 3.9300E+03 1.0000E+02 1.9505E+00 4.0555E+00 4.7708E+00 7.0743E+00
7 3.9400E+03 1.0000E+02 1.9501E+00 4.0546E+00 4.7700E+00 7.0726E+00
6 3.9500E+03 1.0000E+02 1.9497E+00 4.0537E+00 4.7691E+00 7.0709E+00
5 3.9600E+03 1.0000E+02 1.9493E+00 4.0529E+00 4.7683E+00 7.0694E+00
4 3.9700E+03 1.0000E+02 1.9488E+00 4.0515E+00 4.7665E+00 7.0642E+00
3 3.9800E+03 1.0000E+02 1.5303E+00 3.1593E+00 3.7076E+00 5.4468E+00
2 3.9900E+03 7.5000E+01 9.0298E-01 1.7524E+00 1.9607E+00 2.4800E+00
1 4.0000E+03 1.0000E+01 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00
Loading

0 comments on commit e4ec14f

Please sign in to comment.