diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index cecce73a..e0c1fe2a 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -15,4 +15,6 @@ jobs: - uses: actions/setup-python@v4 with: python-version: 3.9 - - uses: pre-commit/action@v3.0.0 \ No newline at end of file + - uses: pre-commit/action@v3.0.0 + with: + extra_args: "--hook-stage manual --all-files" \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 86f0ab06..093c3020 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,4 +1,5 @@ -default_stages: [commit, push] +default_stages: [push, manual] +default_install_hook_types: [pre-push, pre-commit] # Using the "manual" stage for github actions repos: - repo: https://github.com/PyCQA/autoflake @@ -12,7 +13,7 @@ repos: hooks: - id: isort name: isort (python) - args: ["--profile", "black", "--filter-files", "--skip __init__.py"] + args: ["--profile", "black"] - repo: https://github.com/asottile/add-trailing-comma rev: v2.2.3 @@ -56,7 +57,7 @@ repos: entry: check-yaml language: python types: [yaml] - + - repo: https://github.com/pycqa/pylint rev: v2.15.2 hooks: @@ -67,5 +68,15 @@ repos: "-rn", # Only display messages "-sn", # Don't display the score "--disable=R,import-error" # Refactors are not important enough to block a commit. - # Unused-imports aren't testable by the github action, so don't test that here. - ] \ No newline at end of file + # Unused-imports aren't testable by the github action without installing the whole project, so don't test that here. + ] + + - repo: local + hooks: + - id: pytest + name: Run integration tests before push + entry: .venv/bin/pytest -m pre_push_test + language: script + stages: [push] + pass_filenames: false + always_run: true \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 462407ee..3c66bd91 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -71,6 +71,11 @@ good-names = "df,p,f,d,e,n,k,i,v,y_,X,y" disable = "too-many-lines,line-too-long,missing-raises-doc,no-self-argument,unused-wildcard-import,wildcard-import,no-else-return,too-many-arguments,redefined-outer-name,c-extension-no-member,wrong-import-order,import-outside-toplevel" extension-pkg-allow-list = "wandb" +[tool.pytest.ini_options] +markers = [ + "pre_push_test: Tests run on push. Should be as minimal as possible to maintain fast push speeds.", +] + [tool.isort] known_third_party = ["wandb"] diff --git a/src/psycopt2d/about.py b/src/psycopt2d/about.py deleted file mode 100644 index 99a76d8f..00000000 --- a/src/psycopt2d/about.py +++ /dev/null @@ -1,6 +0,0 @@ -# pylint: disable-all -import pkg_resources - -__version__ = pkg_resources.get_distribution("psycop-t2d").version -__title__ = "psycopt2d" -__download_url__ = "https://github.com/Aarhus-Psychiatry-Research/psycop-t2d.git" diff --git a/tests/test_train_model.py b/tests/test_train_model.py index db07acd8..76217236 100644 --- a/tests/test_train_model.py +++ b/tests/test_train_model.py @@ -18,6 +18,20 @@ def test_main(model_name): main(cfg) +@pytest.mark.pre_push_test +def test_integration_test(): + """test main using the logistic model. + + Used for quickly testing functions before a push. + """ + with initialize(version_base=None, config_path="../src/psycopt2d/config/"): + cfg = compose( + config_name="integration_testing.yaml", + overrides=["+model=logistic-regression"], + ) + main(cfg) + + def test_crossvalidation(): """Test crossvalidation.""" with initialize(version_base=None, config_path="../src/psycopt2d/config/"):