my.coding.commits: actually test on CI, add config stub

This commit is contained in:
Dima Gerasimov 2021-03-15 03:31:03 +00:00 committed by karlicoss
parent 8d6f691824
commit ec8b0e9170
5 changed files with 47 additions and 6 deletions

View file

@ -34,6 +34,7 @@ jobs:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
with: with:
submodules: recursive submodules: recursive
fetch-depth: 0 # nicer to have all git history when debugging/for tests
# uncomment for SSH debugging # uncomment for SSH debugging
# - uses: mxschmitt/action-tmate@v3 # - uses: mxschmitt/action-tmate@v3

View file

@ -73,3 +73,10 @@ class orgmode:
class arbtt: class arbtt:
logfiles: Paths logfiles: Paths
from typing import Optional
class commits:
emails: Optional[Sequence[str]]
names: Optional[Sequence[str]]
roots: Sequence[PathIsh]

View file

@ -14,9 +14,10 @@ if ! [ -z "$CI" ]; then
# install OS specific stuff here # install OS specific stuff here
if [[ "$OSTYPE" == "darwin"* ]]; then if [[ "$OSTYPE" == "darwin"* ]]; then
# macos # macos
: brew install fd
else else
: sudo apt update
sudo apt install fd-find
fi fi
fi fi

View file

@ -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: def test() -> None:
from my.coding.commits import commits from my.coding.commits import commits
all_commits = commits() all_commits = list(commits())
assert ilen(all_commits) > 10 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

View file

@ -34,6 +34,8 @@ commands =
# my.body.weight dep # my.body.weight dep
hpi module install my.orgmode hpi module install my.orgmode
pip install gitpython # my.commits dep
python3 -m pytest tests \ python3 -m pytest tests \
# ignore some tests which might take a while to run on ci.. # ignore some tests which might take a while to run on ci..
--ignore tests/takeout.py \ --ignore tests/takeout.py \
@ -77,6 +79,7 @@ commands =
hpi module install my.stackexchange.stexport hpi module install my.stackexchange.stexport
hpi module install my.pinboard hpi module install my.pinboard
hpi module install my.arbtt hpi module install my.arbtt
pip install gitpython # my.commits dep
# todo fuck. -p my.github isn't checking the subpackages?? wtf... # todo fuck. -p my.github isn't checking the subpackages?? wtf...
# guess it wants .pyi file?? # guess it wants .pyi file??
@ -96,6 +99,7 @@ commands =
-p my.time.tz.via_location \ -p my.time.tz.via_location \
-p my.calendar.holidays \ -p my.calendar.holidays \
-p my.arbtt \ -p my.arbtt \
-p my.coding.commits \
--txt-report .coverage.mypy-misc \ --txt-report .coverage.mypy-misc \
--html-report .coverage.mypy-misc \ --html-report .coverage.mypy-misc \
{posargs} {posargs}