From ec8b0e917080384b1647ede83a600a7ed5fb5e8b Mon Sep 17 00:00:00 2001 From: Dima Gerasimov Date: Mon, 15 Mar 2021 03:31:03 +0000 Subject: [PATCH] my.coding.commits: actually test on CI, add config stub --- .github/workflows/main.yml | 1 + my/config.py | 7 +++++++ scripts/ci/run | 5 +++-- tests/commits.py | 36 ++++++++++++++++++++++++++++++++---- tox.ini | 4 ++++ 5 files changed, 47 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1145914..925887b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -34,6 +34,7 @@ jobs: - uses: actions/checkout@v2 with: submodules: recursive + fetch-depth: 0 # nicer to have all git history when debugging/for tests # uncomment for SSH debugging # - uses: mxschmitt/action-tmate@v3 diff --git a/my/config.py b/my/config.py index fb502c3..bdeb55a 100644 --- a/my/config.py +++ b/my/config.py @@ -73,3 +73,10 @@ class orgmode: class arbtt: logfiles: Paths + + +from typing import Optional +class commits: + emails: Optional[Sequence[str]] + names: Optional[Sequence[str]] + roots: Sequence[PathIsh] diff --git a/scripts/ci/run b/scripts/ci/run index 48019d6..a7ea3ba 100755 --- a/scripts/ci/run +++ b/scripts/ci/run @@ -14,9 +14,10 @@ if ! [ -z "$CI" ]; then # install OS specific stuff here if [[ "$OSTYPE" == "darwin"* ]]; then # macos - : + brew install fd else - : + sudo apt update + sudo apt install fd-find fi fi diff --git a/tests/commits.py b/tests/commits.py index ffc7d66..ab4e2c7 100644 --- a/tests/commits.py +++ b/tests/commits.py @@ -1,8 +1,36 @@ -from .common import skip_if_not_karlicoss as pytestmark +# TODO need fdfind on CI? +from pathlib import Path + +from more_itertools import bucket +import pytest -from more_itertools import ilen def test() -> None: from my.coding.commits import commits - all_commits = commits() - assert ilen(all_commits) > 10 + all_commits = list(commits()) + assert len(all_commits) > 100 + + buckets = bucket(all_commits, key=lambda c: c.repo) + by_repo = {k: list(buckets[k]) for k in buckets} + # handle later + + +@pytest.fixture(autouse=True) +def prepare(tmp_path: Path): + # TODO maybe test against actual testdata, could check for + # - datetime handling + # - bare repos + # - canonical name + # - caching? + hpi_repo_root = Path(__file__).absolute().parent.parent + assert (hpi_repo_root / '.git').exists(), hpi_repo_root + + class commits: + emails = {'karlicoss@gmail.com'} + names = {'Dima'} + roots = [hpi_repo_root] + + from my.core.cfg import tmp_config + with tmp_config() as config: + config.commits = commits + yield diff --git a/tox.ini b/tox.ini index 9bd8464..e565fd6 100644 --- a/tox.ini +++ b/tox.ini @@ -34,6 +34,8 @@ commands = # my.body.weight dep hpi module install my.orgmode + pip install gitpython # my.commits dep + python3 -m pytest tests \ # ignore some tests which might take a while to run on ci.. --ignore tests/takeout.py \ @@ -77,6 +79,7 @@ commands = hpi module install my.stackexchange.stexport hpi module install my.pinboard hpi module install my.arbtt + pip install gitpython # my.commits dep # todo fuck. -p my.github isn't checking the subpackages?? wtf... # guess it wants .pyi file?? @@ -96,6 +99,7 @@ commands = -p my.time.tz.via_location \ -p my.calendar.holidays \ -p my.arbtt \ + -p my.coding.commits \ --txt-report .coverage.mypy-misc \ --html-report .coverage.mypy-misc \ {posargs}