Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: run test with gh actions in docker #173

Merged
merged 12 commits into from
Aug 4, 2023
36 changes: 34 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: psf/black@stable
release:
name: release
Expand All @@ -23,7 +23,7 @@ jobs:
with:
release-type: python
package-name: kimmdy
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: tag stable versions
if: ${{ steps.release.outputs.release_created }}
run: |
Expand All @@ -34,3 +34,35 @@ jobs:
git push origin :stable || true
git tag -a stable -m "Last Stable Release"
git push origin stable
prlabel:
runs-on: ubuntu-latest
outputs:
status: ${{ steps.prcheck.conclusion }}
steps:
- name: Check pr lable
id: prcheck
uses: jesusvasquez333/verify-pr-label-action@v1.4.0
with:
github-token: '${{ secrets.GITHUB_TOKEN }}'
valid-labels: 'CI:run_test'
invalid-labels: ''
disable-reviews: true
test:
runs-on: ubuntu-latest
container: riedmiki/gromacs-plumed-python:2021
needs: prlabel
if: needs.prlabel.outputs.status == 'success'
steps:
- uses : actions/checkout@v3
- name: run tox
run: tox
- name: zip coverage report
if: ${{ !cancelled() }}
run: zip -r htmlcov.zip htmlcov || true
- uses: actions/upload-artifact@v3
if: ${{ !cancelled() }}
with:
name: coverage artifact
path: htmlcov.zip


2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
artifacts
htmlcov/
htmlcov*
.tox/
.nox/
.coverage
Expand Down
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# KIMMDY

[![CI](https://github.com/hits-mbm-dev/kimmdy/actions/workflows/ci.yml/badge.svg)](https://github.com/hits-mbm-dev/kimmdy/actions/workflows/ci.yml)

Reactive MD pipeline for GROMACS using Kinetic Monte Carlo / Molecular Dynamics (KIMMDY)

## Quick start
Expand All @@ -8,8 +10,16 @@ Reactive MD pipeline for GROMACS using Kinetic Monte Carlo / Molecular Dynamics
* `cd kimmdy`
* `python -m venv .venv`
* `source ./venv/bin/activate`
* `python -m pip install -e ./`
* Some rections need a GROMACS version patched with PLUMED, gromacs name should then contain `MODIFIED` or `plumed`

## Development setup

* `python -m pip install -r requirments.txt`
* Some rections need a GROMACS version patched with PLUMED
* code style: black
* docstrings: numpy
* [Conventional commit](https://www.conventionalcommits.org/en/v1.0.0/) messages when possible for pretty release notes.


## First simulation

Expand All @@ -19,3 +29,14 @@ Reactive MD pipeline for GROMACS using Kinetic Monte Carlo / Molecular Dynamics
* check output: `kimmdy.log`, `test_out_00X/`


## Local testing

For developoment, we provide a docker image containing gromacs and multiple python versions to test against.
To run the test locally, you must:
- install docker
- install [act](https://github.com/nektos/act), easiest option is with github cli
- install github cli (`gh`)
- `gh extension install https://github.com/nektos/gh-act`
- run tests with `gh extension exec act -j test --artifact-server-path ./artifacts`
- customize which python versions to test in `tox.ini`
- html coverage report is exported into `artifacts`
1 change: 0 additions & 1 deletion plugins/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package_dir =
=src
include_package_data = True
install_requires =
kimmdy
MDAnalysis

python_requires = >= 3.9
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ tox
black
hypothesis
jupyter
git+https://github.com/machow/quartodoc.git
# git+https://github.com/machow/quartodoc.git
pydantic<2
-e .
-e ./plugins
21 changes: 8 additions & 13 deletions src/kimmdy/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def check_gmx_version(config):
"""Check for an existing gromacs installation.

If PLUMED is meant to be used it additionally checks for the keyword
'MODIFIED' in the version name.
'MODIFIED' or 'plumed' in the version name.
"""
try:
version = [
Expand All @@ -184,18 +184,13 @@ def check_gmx_version(config):
logging.error(m)
raise SystemError(m)

# this should probably be a TODO: then
# i hate this
if (
any(
"plumed" in y
for y in [
config.mds.attr(x).get_attributes() for x in config.mds.get_attributes()
]
)
and not "MODIFIED" in version
):
m = "GROMACS version does not contain MODIFIED, aborting due to lack of PLUMED patch."
if any(
"plumed" in y
for y in [
config.mds.attr(x).get_attributes() for x in config.mds.get_attributes()
]
) and (not ("MODIFIED" in version or "plumed" in version)):
m = "GROMACS version does not contain MODIFIED or plumed, aborting due to lack of PLUMED patch."
logging.error(m)
logging.error("Version was: " + version)
if not config.dryrun:
Expand Down
3 changes: 3 additions & 0 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ def test_grompp_with_kimmdy_topology(tmp_path):
)


@pytest.mark.slow
def test_integration_hat_reaction(tmp_path, caplog):
testdir = setup_testdir(tmp_path, "hat_naive")
caplog.set_level(logging.INFO)
Expand All @@ -91,6 +92,7 @@ def test_integration_hat_reaction(tmp_path, caplog):
)


@pytest.mark.slow
def test_integration_homolysis_reaction(tmp_path, caplog):
testdir = setup_testdir(tmp_path, "homolysis")
caplog.set_level(logging.INFO)
Expand All @@ -105,6 +107,7 @@ def test_integration_homolysis_reaction(tmp_path, caplog):
)


@pytest.mark.slow
def test_integration_whole_run(tmp_path, caplog):
testdir = setup_testdir(tmp_path, "whole_run")
caplog.set_level(logging.INFO)
Expand Down
5 changes: 4 additions & 1 deletion tests/test_topology.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,10 @@ def test_break_bind_bond_hexala(self, hexala_top_fix):
assert top.improper_dihedrals == og_top.improper_dihedrals

@given(bondindex=st.integers(min_value=0, max_value=70))
@settings(suppress_health_check=[HealthCheck.function_scoped_fixture])
@settings(
suppress_health_check=[HealthCheck.function_scoped_fixture], deadline=1000
)
@pytest.mark.slow
def test_break_bind_random_bond_hexala(self, hexala_top_fix, bondindex):
top = deepcopy(hexala_top_fix)
og_top = deepcopy(top)
Expand Down
41 changes: 39 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,13 +1,50 @@
[tox]
envlist =
py38
clean
lint
py39
py310
py311
report

[testenv]
description = run tests
package_root =
./
plugins
deps =
pytest
pytest-cov
pytest-randomly
hypothesis
; installes editable, packaged would be better:
-r requirements.txt
; would work if extra would be public:
; extras = plugins
commands =
pytest --cov=kimmdy --randomly-seed=1
pytest -m "not slow" --durations=15 --cov=kimmdy --randomly-seed=1
; pytest --cov=kimmdy --randomly-seed=1
; pytest --cov=kimmdy --cov-append --randomly-seed=1
; only test discovery:
; pytest --cov=kimmdy --randomly-seed=1 --co

[testenv:lint]
description = run black
skip_install = true
deps =
black
commands =
black src tests

[testenv:clean]
deps = coverage
skip_install = true
commands = coverage erase

[testenv:report]
deps = coverage
skip_install = true
commands =
coverage report
coverage html