From 1310d80a21d3a42125519075ceb027eb43759c7e Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Sun, 11 Sep 2022 21:28:17 -0500 Subject: [PATCH 01/20] refactor: Move pytest plugin test to tests/ --- tests/{sync => }/test_pytest_plugin.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tests/{sync => }/test_pytest_plugin.py (100%) diff --git a/tests/sync/test_pytest_plugin.py b/tests/test_pytest_plugin.py similarity index 100% rename from tests/sync/test_pytest_plugin.py rename to tests/test_pytest_plugin.py From 8e56c2d6feb36e1da5a460794ad8d932dc08befa Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Sun, 11 Sep 2022 21:44:34 -0500 Subject: [PATCH 02/20] tests(conftest): Add pytester --- tests/conftest.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/conftest.py b/tests/conftest.py index 08fea4da3..66bc15aca 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1 +1,3 @@ from libvcs.conftest import * # NOQA: F4 + +pytest_plugins = ["pytester"] From e583184c979a4fb6fa82fe12fd8f541781e9ed0a Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Sun, 11 Sep 2022 21:43:25 -0500 Subject: [PATCH 03/20] tests(test_plugin): Add pytester test for create_git_remote_repo --- tests/test_pytest_plugin.py | 79 +++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/tests/test_pytest_plugin.py b/tests/test_pytest_plugin.py index 284cf2f6f..1da543111 100644 --- a/tests/test_pytest_plugin.py +++ b/tests/test_pytest_plugin.py @@ -1,8 +1,11 @@ import pathlib import shutil +import textwrap import pytest +import _pytest.pytester + from libvcs.pytest_plugin import CreateProjectCallbackFixtureProtocol @@ -28,3 +31,79 @@ def test_create_svn_remote_repo( svn_remote_2 = create_svn_remote_repo() assert svn_remote_1 != svn_remote_2 + + +def test_plugin( + pytester: _pytest.pytester.Pytester, + monkeypatch: pytest.MonkeyPatch, +) -> None: + # Initialize variables + pytester.plugins = ["pytest_plugin"] + pytester.makefile( + ".ini", + pytest=textwrap.dedent( + """ +[pytest] +addopts=-vv + """.strip() + ), + ) + pytester.makeconftest( + textwrap.dedent( + r""" +import pathlib +import pytest + +@pytest.fixture(autouse=True) +def setup( + request: pytest.FixtureRequest, + gitconfig: pathlib.Path, + set_home: pathlib.Path, +) -> None: + pass + """ + ) + ) + tests_path = pytester.path / "tests" + files = { + "example.py": textwrap.dedent( + """ +import pathlib + +from libvcs.sync.git import GitSync +from libvcs.pytest_plugin import CreateProjectCallbackFixtureProtocol + +def test_repo_git_remote_checkout( + create_git_remote_repo: CreateProjectCallbackFixtureProtocol, + tmp_path: pathlib.Path, + projects_path: pathlib.Path, +) -> None: + git_server = create_git_remote_repo() + git_repo_checkout_dir = projects_path / "my_git_checkout" + git_repo = GitSync(dir=str(git_repo_checkout_dir), url=f"file://{git_server!s}") + + git_repo.obtain() + git_repo.update_repo() + + assert git_repo.get_revision() == "initial" + + assert git_repo_checkout_dir.exists() + assert pathlib.Path(git_repo_checkout_dir / ".git").exists() + """ + ) + } + first_test_key = list(files.keys())[0] + first_test_filename = str(tests_path / first_test_key) + + # Setup: Files + tests_path.mkdir() + for file_name, text in files.items(): + rst_file = tests_path / file_name + rst_file.write_text( + text, + encoding="utf-8", + ) + + # Test + result = pytester.runpytest(str(first_test_filename)) + result.assert_outcomes(passed=1) From f81c37f874cdb8f46da6e988f2c6d25cb18f6bd8 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Sun, 11 Sep 2022 21:48:45 -0500 Subject: [PATCH 04/20] docs(CHANGES): Note pytest plugin test --- CHANGES | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGES b/CHANGES index 35e6ceb1e..225d26ec6 100644 --- a/CHANGES +++ b/CHANGES @@ -13,6 +13,10 @@ $ pip install --user --upgrade --pre libvcs - _Add your latest changes from PRs here_ +### Tests + +- Basic pytest plugin test (#413) + ## libvcs 0.16.2 (2022-09-11) ### Bug fix From 73254e8e2c4772dfba379ed144ae01f6bed99125 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Sun, 11 Sep 2022 21:57:52 -0500 Subject: [PATCH 05/20] chore(pytest tests): Variable naming --- tests/test_pytest_plugin.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_pytest_plugin.py b/tests/test_pytest_plugin.py index 1da543111..467a5c489 100644 --- a/tests/test_pytest_plugin.py +++ b/tests/test_pytest_plugin.py @@ -98,8 +98,8 @@ def test_repo_git_remote_checkout( # Setup: Files tests_path.mkdir() for file_name, text in files.items(): - rst_file = tests_path / file_name - rst_file.write_text( + test_file = tests_path / file_name + test_file.write_text( text, encoding="utf-8", ) From 848730755a75bca3aec80832ee9ebd9a16a412f0 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Wed, 14 Sep 2022 07:07:41 -0500 Subject: [PATCH 06/20] build(deps): Bump certifi, idna --- poetry.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/poetry.lock b/poetry.lock index 8ba9cfce8..0390868dd 100644 --- a/poetry.lock +++ b/poetry.lock @@ -70,7 +70,7 @@ uvloop = ["uvloop (>=0.15.2)"] [[package]] name = "certifi" -version = "2022.6.15.1" +version = "2022.6.15.2" description = "Python package for providing Mozilla's CA Bundle." category = "dev" optional = false @@ -207,7 +207,7 @@ myst_parser = "*" [[package]] name = "idna" -version = "3.3" +version = "3.4" description = "Internationalized Domain Names in Applications (IDNA)" category = "dev" optional = false @@ -936,8 +936,8 @@ black = [ {file = "black-22.8.0.tar.gz", hash = "sha256:792f7eb540ba9a17e8656538701d3eb1afcb134e3b45b71f20b25c77a8db7e6e"}, ] certifi = [ - {file = "certifi-2022.6.15.1-py3-none-any.whl", hash = "sha256:43dadad18a7f168740e66944e4fa82c6611848ff9056ad910f8f7a3e46ab89e0"}, - {file = "certifi-2022.6.15.1.tar.gz", hash = "sha256:cffdcd380919da6137f76633531a5817e3a9f268575c128249fb637e4f9e73fb"}, + {file = "certifi-2022.6.15.2-py3-none-any.whl", hash = "sha256:0aa1a42fbd57645fabeb6290a7687c21755b0344ecaeaa05f4e9f6207ae2e9a8"}, + {file = "certifi-2022.6.15.2.tar.gz", hash = "sha256:aa08c101214127b9b0472ca6338315113c9487d45376fd3e669201b477c71003"}, ] charset-normalizer = [ {file = "charset-normalizer-2.1.1.tar.gz", hash = "sha256:5a3d016c7c547f69d6f81fb0db9449ce888b418b5b9952cc5e6e66843e9dd845"}, @@ -1033,8 +1033,8 @@ gp-libs = [ {file = "gp_libs-0.0.1a10-py3-none-any.whl", hash = "sha256:701b190ffd468ca4d776b196707344748dd550aea03db9aaa1ffdecdd0c32506"}, ] idna = [ - {file = "idna-3.3-py3-none-any.whl", hash = "sha256:84d9dd047ffa80596e0f246e2eab0b391788b0503584e8945f2368256d2735ff"}, - {file = "idna-3.3.tar.gz", hash = "sha256:9d643ff0a55b762d5cdb124b8eaa99c66322e2157b69160bc32796e824360e6d"}, + {file = "idna-3.4-py3-none-any.whl", hash = "sha256:90b77e79eaa3eba6de819a0c442c0b4ceefc341a7a2ab77d7562bf49f425c5c2"}, + {file = "idna-3.4.tar.gz", hash = "sha256:814f528e8dead7d329833b91c5faa87d60bf71824cd12a7530b5526063d02cb4"}, ] imagesize = [ {file = "imagesize-1.4.1-py2.py3-none-any.whl", hash = "sha256:0d8d18d08f840c19d0ee7ca1fd82490fdc3729b7ac93f49870406ddde8ef8d8b"}, From 55acb21fad0e6d673da4b076cd7f2fadfe3b2cb3 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Thu, 15 Sep 2022 21:00:20 -0500 Subject: [PATCH 07/20] build(deps): Bump certifi and furo --- poetry.lock | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/poetry.lock b/poetry.lock index 0390868dd..bddb1c833 100644 --- a/poetry.lock +++ b/poetry.lock @@ -70,7 +70,7 @@ uvloop = ["uvloop (>=0.15.2)"] [[package]] name = "certifi" -version = "2022.6.15.2" +version = "2022.9.14" description = "Python package for providing Mozilla's CA Bundle." category = "dev" optional = false @@ -181,7 +181,7 @@ flake8 = ">=3.0,<3.2.0 || >3.2.0" [[package]] name = "furo" -version = "2022.6.21" +version = "2022.9.15" description = "A clean customisable Sphinx documentation theme." category = "dev" optional = false @@ -189,7 +189,7 @@ python-versions = ">=3.7" [package.dependencies] beautifulsoup4 = "*" -pygments = "*" +pygments = ">=2.7" sphinx = ">=4.0,<6.0" sphinx-basic-ng = "*" @@ -936,8 +936,8 @@ black = [ {file = "black-22.8.0.tar.gz", hash = "sha256:792f7eb540ba9a17e8656538701d3eb1afcb134e3b45b71f20b25c77a8db7e6e"}, ] certifi = [ - {file = "certifi-2022.6.15.2-py3-none-any.whl", hash = "sha256:0aa1a42fbd57645fabeb6290a7687c21755b0344ecaeaa05f4e9f6207ae2e9a8"}, - {file = "certifi-2022.6.15.2.tar.gz", hash = "sha256:aa08c101214127b9b0472ca6338315113c9487d45376fd3e669201b477c71003"}, + {file = "certifi-2022.9.14-py3-none-any.whl", hash = "sha256:e232343de1ab72c2aa521b625c80f699e356830fd0e2c620b465b304b17b0516"}, + {file = "certifi-2022.9.14.tar.gz", hash = "sha256:36973885b9542e6bd01dea287b2b4b3b21236307c56324fcc3f1160f2d655ed5"}, ] charset-normalizer = [ {file = "charset-normalizer-2.1.1.tar.gz", hash = "sha256:5a3d016c7c547f69d6f81fb0db9449ce888b418b5b9952cc5e6e66843e9dd845"}, @@ -1025,8 +1025,8 @@ flake8-comprehensions = [ {file = "flake8_comprehensions-3.10.0-py3-none-any.whl", hash = "sha256:dad454fd3d525039121e98fa1dd90c46bc138708196a4ebbc949ad3c859adedb"}, ] furo = [ - {file = "furo-2022.6.21-py3-none-any.whl", hash = "sha256:061b68e323345e27fcba024cf33a1e77f3dfd8d9987410be822749a706e2add6"}, - {file = "furo-2022.6.21.tar.gz", hash = "sha256:9aa983b7488a4601d13113884bfb7254502c8729942e073a0acb87a5512af223"}, + {file = "furo-2022.9.15-py3-none-any.whl", hash = "sha256:9129dead1f75e9fb4fa407612f1d5a0d0320767e6156c925aafe36f362f9b11a"}, + {file = "furo-2022.9.15.tar.gz", hash = "sha256:4a7ef1c8a3b615171592da4d2ad8a53cc4aacfbe111958890f5f9ff7279066ab"}, ] gp-libs = [ {file = "gp-libs-0.0.1a10.tar.gz", hash = "sha256:54fbe07f42628b114f0b1472bb03ce75be2928090ec26d8d6f675f3bd9f58c2e"}, From 1efe871a3e8476a1630e7939f9ce1aca6af5d7d4 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Sat, 17 Sep 2022 16:46:08 -0500 Subject: [PATCH 08/20] test(QueryList): Test objects (#414) --- tests/_internal/test_query_list.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/_internal/test_query_list.py b/tests/_internal/test_query_list.py index 2ec9ea97f..4b3056819 100644 --- a/tests/_internal/test_query_list.py +++ b/tests/_internal/test_query_list.py @@ -1,3 +1,4 @@ +import dataclasses from typing import Any, Optional, Union import pytest @@ -5,12 +6,24 @@ from libvcs._internal.query_list import QueryList +@dataclasses.dataclass +class Obj: + test: int + fruit: list[str] = dataclasses.field(default_factory=list) + + @pytest.mark.parametrize( "items,filter_expr,expected_result", [ + [[Obj(test=1)], None, [Obj(test=1)]], [[{"test": 1}], None, [{"test": 1}]], [[{"test": 1}], None, QueryList([{"test": 1}])], [[{"fruit": "apple"}], None, QueryList([{"fruit": "apple"}])], + [ + [Obj(test=2, fruit=["apple"])], + None, + QueryList([Obj(test=2, fruit=["apple"])]), + ], [ [{"fruit": "apple", "banana": object()}], None, From 1c873a5b09e5777c9ffda3094956349e868c5857 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Sat, 17 Sep 2022 18:07:25 -0500 Subject: [PATCH 09/20] QueryList: Better object handling --- src/libvcs/_internal/query_list.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/libvcs/_internal/query_list.py b/src/libvcs/_internal/query_list.py index c8f54ddee..c33d0efe8 100644 --- a/src/libvcs/_internal/query_list.py +++ b/src/libvcs/_internal/query_list.py @@ -29,10 +29,14 @@ def keygetter( sub_fields = path.split("__") dct = obj for sub_field in sub_fields: - dct = dct[sub_field] + if isinstance(dct, dict): + dct = dct[sub_field] + elif hasattr(dct, sub_field): + dct = getattr(dct, sub_field) return dct - except Exception: + except Exception as e: traceback.print_stack() + print(f"Above error was {e}") return None From fe98727144e83f7ce84327abd195c3e2c8a05c20 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Sun, 18 Sep 2022 09:58:31 -0500 Subject: [PATCH 10/20] tests(QueryList): Lookup by objects --- tests/_internal/test_query_list.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/_internal/test_query_list.py b/tests/_internal/test_query_list.py index 4b3056819..552b360e9 100644 --- a/tests/_internal/test_query_list.py +++ b/tests/_internal/test_query_list.py @@ -16,14 +16,16 @@ class Obj: "items,filter_expr,expected_result", [ [[Obj(test=1)], None, [Obj(test=1)]], - [[{"test": 1}], None, [{"test": 1}]], - [[{"test": 1}], None, QueryList([{"test": 1}])], - [[{"fruit": "apple"}], None, QueryList([{"fruit": "apple"}])], + [[Obj(test=1)], dict(test=1), [Obj(test=1)]], + [[Obj(test=1)], dict(test=2), []], [ [Obj(test=2, fruit=["apple"])], - None, + dict(fruit__in="apple"), QueryList([Obj(test=2, fruit=["apple"])]), ], + [[{"test": 1}], None, [{"test": 1}]], + [[{"test": 1}], None, QueryList([{"test": 1}])], + [[{"fruit": "apple"}], None, QueryList([{"fruit": "apple"}])], [ [{"fruit": "apple", "banana": object()}], None, From 4acf23aa238043d33d3408500f5af52a5e91db2f Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Sun, 18 Sep 2022 10:20:59 -0500 Subject: [PATCH 11/20] tests/docs(query_list): Document object lookups --- src/libvcs/_internal/query_list.py | 99 ++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) diff --git a/src/libvcs/_internal/query_list.py b/src/libvcs/_internal/query_list.py index c33d0efe8..852d65c7c 100644 --- a/src/libvcs/_internal/query_list.py +++ b/src/libvcs/_internal/query_list.py @@ -49,6 +49,22 @@ def parse_lookup(obj: Mapping[str, Any], path: str, lookup: str) -> Optional[Any >>> parse_lookup({ "food": "red apple" }, "food__istartswith", "__istartswith") 'red apple' + + It can also look up objects: + + >>> from dataclasses import dataclass + + >>> @dataclass() + ... class Inventory: + ... food: str + + >>> item = Inventory(food="red apple") + + >>> item + Inventory(food='red apple') + + >>> parse_lookup(item, "food__istartswith", "__istartswith") + 'red apple' """ try: if isinstance(path, str) and isinstance(lookup, str) and path.endswith(lookup): @@ -262,6 +278,89 @@ class QueryList(list[T]): 'Elmhurst' >>> query.filter(foods__fruit__in="orange")[0]['city'] 'Tampa' + + Examples of object lookups: + + >>> from typing import Any + >>> from dataclasses import dataclass, field + + >>> @dataclass() + ... class Restaurant: + ... place: str + ... city: str + ... state: str + ... foods: dict[str, Any] + + >>> restaurant = Restaurant( + ... place="Largo", + ... city="Tampa", + ... state="Florida", + ... foods={ + ... "fruit": ["banana", "orange"], "breakfast": "cereal" + ... } + ... ) + + >>> restaurant + Restaurant(place='Largo', + city='Tampa', + state='Florida', + foods={'fruit': ['banana', 'orange'], 'breakfast': 'cereal'}) + + >>> query = QueryList([restaurant]) + + >>> query.filter(foods__fruit__in="banana") + [Restaurant(place='Largo', + city='Tampa', + state='Florida', + foods={'fruit': ['banana', 'orange'], 'breakfast': 'cereal'})] + + >>> query.filter(foods__fruit__in="banana")[0].city + 'Tampa' + + Example of deeper object lookups: + + >>> from typing import Optional + >>> from dataclasses import dataclass, field + + >>> @dataclass() + ... class Menu: + ... fruit: list[str] = field(default_factory=list) + ... breakfast: Optional[str] = None + + + >>> @dataclass() + ... class Restaurant: + ... place: str + ... city: str + ... state: str + ... menu: Menu = field(default_factory=Menu) + + + >>> restaurant = Restaurant( + ... place="Largo", + ... city="Tampa", + ... state="Florida", + ... menu=Menu( + ... fruit=["banana", "orange"], breakfast="cereal" + ... ) + ... ) + + >>> restaurant + Restaurant(place='Largo', + city='Tampa', + state='Florida', + menu=Menu(fruit=['banana', 'orange'], breakfast='cereal')) + + >>> query = QueryList([restaurant]) + + >>> query.filter(menu__fruit__in="banana") + [Restaurant(place='Largo', + city='Tampa', + state='Florida', + menu=Menu(fruit=['banana', 'orange'], breakfast='cereal'))] + + >>> query.filter(menu__fruit__in="banana")[0].city + 'Tampa' """ data: Sequence[T] From d73d110cc3b65e3575dccaf76e68a292a5e679aa Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Sun, 18 Sep 2022 10:26:27 -0500 Subject: [PATCH 12/20] docs(query_list): Clean up keygetter --- src/libvcs/_internal/query_list.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/libvcs/_internal/query_list.py b/src/libvcs/_internal/query_list.py index 852d65c7c..088fc3bc4 100644 --- a/src/libvcs/_internal/query_list.py +++ b/src/libvcs/_internal/query_list.py @@ -17,13 +17,12 @@ def keygetter( obj: Mapping[str, Any], path: str, ) -> Union[None, Any, str, list[str], Mapping[str, str]]: - """obj, "foods__breakfast", obj['foods']['breakfast'] + """Fetch values in objects and keys, deeply. >>> keygetter({ "foods": { "breakfast": "cereal" } }, "foods__breakfast") 'cereal' >>> keygetter({ "foods": { "breakfast": "cereal" } }, "foods") {'breakfast': 'cereal'} - """ try: sub_fields = path.split("__") From 133d4eb6b6769f7978be72e6217d63b1e3a4989e Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Sun, 18 Sep 2022 10:31:21 -0500 Subject: [PATCH 13/20] docs(query_list): More detailed docs for keygetter --- src/libvcs/_internal/query_list.py | 49 ++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/src/libvcs/_internal/query_list.py b/src/libvcs/_internal/query_list.py index 088fc3bc4..1d0f0c54b 100644 --- a/src/libvcs/_internal/query_list.py +++ b/src/libvcs/_internal/query_list.py @@ -19,10 +19,53 @@ def keygetter( ) -> Union[None, Any, str, list[str], Mapping[str, str]]: """Fetch values in objects and keys, deeply. - >>> keygetter({ "foods": { "breakfast": "cereal" } }, "foods__breakfast") - 'cereal' - >>> keygetter({ "foods": { "breakfast": "cereal" } }, "foods") + **With dictionaries**: + + >>> keygetter({ "menu": { "breakfast": "cereal" } }, "menu") {'breakfast': 'cereal'} + + >>> keygetter({ "menu": { "breakfast": "cereal" } }, "menu__breakfast") + 'cereal' + + **With objects**: + + >>> from typing import Optional + >>> from dataclasses import dataclass, field + + >>> @dataclass() + ... class Menu: + ... fruit: list[str] = field(default_factory=list) + ... breakfast: Optional[str] = None + + + >>> @dataclass() + ... class Restaurant: + ... place: str + ... city: str + ... state: str + ... menu: Menu = field(default_factory=Menu) + + + >>> restaurant = Restaurant( + ... place="Largo", + ... city="Tampa", + ... state="Florida", + ... menu=Menu( + ... fruit=["banana", "orange"], breakfast="cereal" + ... ) + ... ) + + >>> restaurant + Restaurant(place='Largo', + city='Tampa', + state='Florida', + menu=Menu(fruit=['banana', 'orange'], breakfast='cereal')) + + >>> keygetter(restaurant, "menu") + Menu(fruit=['banana', 'orange'], breakfast='cereal') + + >>> keygetter(restaurant, "menu__breakfast") + 'cereal' """ try: sub_fields = path.split("__") From 1ce6f15d2fb870c22cf59fef9f8b352dbf1b2af5 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Sun, 18 Sep 2022 10:37:09 -0500 Subject: [PATCH 14/20] docs(query_list): Clean up parse_lookup --- src/libvcs/_internal/query_list.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/libvcs/_internal/query_list.py b/src/libvcs/_internal/query_list.py index 1d0f0c54b..214dfadc0 100644 --- a/src/libvcs/_internal/query_list.py +++ b/src/libvcs/_internal/query_list.py @@ -87,8 +87,6 @@ def parse_lookup(obj: Mapping[str, Any], path: str, lookup: str) -> Optional[Any If comparator not used or value not found, return None. - mykey__endswith("mykey") -> "mykey" else None - >>> parse_lookup({ "food": "red apple" }, "food__istartswith", "__istartswith") 'red apple' From d98c54f33f5d61e26c42955545dd5767a4fe8e74 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Sun, 18 Sep 2022 10:02:00 -0500 Subject: [PATCH 15/20] docs(CHANGES): QueryList fixes --- CHANGES | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/CHANGES b/CHANGES index 225d26ec6..dc15b2963 100644 --- a/CHANGES +++ b/CHANGES @@ -13,9 +13,21 @@ $ pip install --user --upgrade --pre libvcs - _Add your latest changes from PRs here_ +## libvcs 0.16.3 (unreleased) + +### Bug fixes + +- `QueryList`: Fix lookups of objects (#415) + ### Tests - Basic pytest plugin test (#413) +- Add test for object based lookups (#414) + +### Documentation + +- Improve doc examples / tests for `keygetter` and `QueryList` to show deep lookups for objects + (#415) ## libvcs 0.16.2 (2022-09-11) From 3161f99c6fbcccd68355016677a38c5fcea3bf2e Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Sun, 18 Sep 2022 10:42:06 -0500 Subject: [PATCH 16/20] ci(codeql-analysis): Update action versions, cleanup --- .github/workflows/codeql-analysis.yml | 49 ++++----------------------- 1 file changed, 6 insertions(+), 43 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 2341f6dad..5da69bd96 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -1,24 +1,12 @@ -# For most projects, this workflow file will not need changing; you simply need -# to commit it to your repository. -# -# You may wish to alter this file to override the set of languages analyzed, -# or to provide custom queries or build logic. -# -# ******** NOTE ******** -# We have attempted to detect the languages in your repository. Please check -# the `language` matrix defined below to confirm you have the correct set of -# supported CodeQL languages. -# name: "CodeQL" on: push: branches: [ master ] pull_request: - # The branches below must be a subset of the branches above branches: [ master ] schedule: - - cron: '21 7 * * 4' + - cron: '16 5 * * 2' jobs: analyze: @@ -29,42 +17,17 @@ jobs: contents: read security-events: write - strategy: - fail-fast: false - matrix: - language: [ 'python' ] - # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] - # Learn more about CodeQL language support at https://git.io/codeql-language-support - steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 - # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@v1 + uses: github/codeql-action/init@v2 with: - languages: ${{ matrix.language }} - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. - # queries: ./path/to/local/query, your-org/your-repo/queries@main + languages: "python" - # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild - uses: github/codeql-action/autobuild@v1 - - # â„šī¸ Command-line programs to run using the OS shell. - # 📚 https://git.io/JvXDl - - # âœī¸ If the Autobuild fails above, remove it and uncomment the following three lines - # and modify them (or add more) to build your code if your project - # uses a compiled language - - #- run: | - # make bootstrap - # make release + uses: github/codeql-action/autobuild@v2 - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v1 + uses: github/codeql-action/analyze@v2 From a52d556419b3f0fd9063210cd9914a5435332ca9 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Sun, 18 Sep 2022 10:43:43 -0500 Subject: [PATCH 17/20] ci(tests): Only pull docker image on release (after tests pass) --- .github/workflows/tests.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 335326e03..81b772ffa 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -52,6 +52,27 @@ jobs: with: token: ${{ secrets.CODECOV_TOKEN }} + release: + runs-on: ubuntu-latest + needs: build + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') + + strategy: + matrix: + python-version: ["3.10"] + + steps: + - uses: actions/checkout@v3 + + - name: Install poetry + run: pipx install "poetry==1.1.15" + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + cache: 'poetry' + - name: Build package if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') run: poetry build From b117d012be7495a22375795279f0f5b29870db1a Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Sun, 18 Sep 2022 10:45:12 -0500 Subject: [PATCH 18/20] docs(CHANGES): Note CI updates --- CHANGES | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGES b/CHANGES index dc15b2963..44ec85f59 100644 --- a/CHANGES +++ b/CHANGES @@ -29,6 +29,14 @@ $ pip install --user --upgrade --pre libvcs - Improve doc examples / tests for `keygetter` and `QueryList` to show deep lookups for objects (#415) +### Infrastructure + +- CI speedups (#416) + + - Avoid fetching unused apt package + - Split out release to separate job so the PyPI Upload docker image isn't pulled on normal runs + - Clean up CodeQL + ## libvcs 0.16.2 (2022-09-11) ### Bug fix From 116014192ee57d119541d08df68c6bf0b0c1d932 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Sun, 18 Sep 2022 10:47:57 -0500 Subject: [PATCH 19/20] Tag v0.16.3a0 (test CI release from #416) --- CHANGES | 2 +- pyproject.toml | 2 +- src/libvcs/__about__.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index 44ec85f59..79b55863b 100644 --- a/CHANGES +++ b/CHANGES @@ -13,7 +13,7 @@ $ pip install --user --upgrade --pre libvcs - _Add your latest changes from PRs here_ -## libvcs 0.16.3 (unreleased) +## libvcs 0.16.3 (2022-09-18) ### Bug fixes diff --git a/pyproject.toml b/pyproject.toml index bf493f3ba..272a59cbf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "libvcs" -version = "0.16.2" +version = "0.16.3a0" description = "Lite, typed, python utilities for Git, SVN, Mercurial, etc." license = "MIT" authors = ["Tony Narlock "] diff --git a/src/libvcs/__about__.py b/src/libvcs/__about__.py index f3c6ec9fa..417778fc6 100644 --- a/src/libvcs/__about__.py +++ b/src/libvcs/__about__.py @@ -1,7 +1,7 @@ __title__ = "libvcs" __package_name__ = "libvcs" __description__ = "Lite, typed, python utilities for Git, SVN, Mercurial, etc." -__version__ = "0.16.2" +__version__ = "0.16.3a0" __author__ = "Tony Narlock" __github__ = "https://github.com/vcs-python/libvcs" __docs__ = "https://libvcs.git-pull.com" From 3e9f614f8807336d64f7ac8fc4b6d6f887c88275 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Sun, 18 Sep 2022 10:53:17 -0500 Subject: [PATCH 20/20] Tag v0.16.3 (query_list docs and improvements, pytest plugin tests, CI) --- pyproject.toml | 2 +- src/libvcs/__about__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 272a59cbf..59bee713f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "libvcs" -version = "0.16.3a0" +version = "0.16.3" description = "Lite, typed, python utilities for Git, SVN, Mercurial, etc." license = "MIT" authors = ["Tony Narlock "] diff --git a/src/libvcs/__about__.py b/src/libvcs/__about__.py index 417778fc6..0dfb32601 100644 --- a/src/libvcs/__about__.py +++ b/src/libvcs/__about__.py @@ -1,7 +1,7 @@ __title__ = "libvcs" __package_name__ = "libvcs" __description__ = "Lite, typed, python utilities for Git, SVN, Mercurial, etc." -__version__ = "0.16.3a0" +__version__ = "0.16.3" __author__ = "Tony Narlock" __github__ = "https://github.com/vcs-python/libvcs" __docs__ = "https://libvcs.git-pull.com"