From daf85e2f14359ec10811f8438466dcdf6e6d7fe1 Mon Sep 17 00:00:00 2001 From: williamfzc <178894043@qq.com> Date: Sun, 26 Nov 2023 12:23:30 +0800 Subject: [PATCH] chore(ci): add third party lib test --- .github/workflows/python-package.yml | 4 ++++ examples/for_axios.py | 35 ++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 examples/for_axios.py diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 4fe3dc9..febfc02 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -36,3 +36,7 @@ jobs: poetry run python3 examples/write.py poetry run python3 examples/read.py poetry run pytest + - name: Third Party Test + run: | + git clone https://github.com/axios/axios.git + poetry run python3 examples/for_axios.py diff --git a/examples/for_axios.py b/examples/for_axios.py new file mode 100644 index 0000000..4686e63 --- /dev/null +++ b/examples/for_axios.py @@ -0,0 +1,35 @@ +import pathlib +import sys +import warnings + +from srctag.collector import Collector +from srctag.storage import Storage +from srctag.tagger import Tagger + +axios_repo = pathlib.Path(__file__).parent.parent / "axios" +if not axios_repo.is_dir(): + warnings.warn(f"clone axios to {axios_repo} first") + sys.exit(0) + +collector = Collector() +collector.config.repo_root = axios_repo +collector.config.max_depth_limit = -1 +collector.config.include_regex = r"lib.*" + +ctx = collector.collect_metadata() +storage = Storage() +storage.embed_ctx(ctx) +tagger = Tagger() +tagger.config.tags = [ + "XMLHttpRequests from browser", + "HTTP requests from node.js", + "Promise API support", + "Request and response interception", + "Request and response data transformation", + "Request cancellation", + "Automatic JSON data transforms", + "Automatic serialization of data objects", + "Client-side XSRF protection" +] +tag_dict = tagger.tag(storage) +print(tag_dict.scores_df.to_string(index=False))