From ec4b4b9ba48ca5684566ba0fd44f239be594729d Mon Sep 17 00:00:00 2001 From: Ievgenii Shepeliuk Date: Tue, 25 Jul 2023 17:32:28 +0000 Subject: [PATCH] fix: semantic release --- .editorconfig | 4 ++-- .github/workflows/build.yaml | 12 ++++++++++-- .github/workflows/release.yaml | 2 +- README.md | 20 ++++++++------------ cspell.json | 11 ++++++++++- justfile | 7 ++++--- pykli/__main__.py | 5 +++-- pykli/repl_print.py | 8 +++++--- pykli/repl_read.py | 2 +- pyproject.toml | 13 ++++++++----- tests/test_pykli.py | 3 ++- 11 files changed, 54 insertions(+), 33 deletions(-) diff --git a/.editorconfig b/.editorconfig index 177b154..cf02477 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,14 +1,14 @@ root = true -# Unix-style newlines with a newline ending every file [*] end_of_line = lf insert_final_newline = true charset = utf-8 indent_style = space indent_size = 2 +max_line_length = 80 -# 4 space indentation [*.py] indent_size = 4 +max_line_length = 120 diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 2959cbe..0cebdcb 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -42,7 +42,16 @@ jobs: - uses: extractions/setup-just@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - run: just test + - uses: jaxxstorm/action-install-gh-release@v1 + with: + repo: astral-sh/ruff + tag: v0.0.280 + cache: enable + # extension-matching: disable + # rename-to: skaffold + # chmod: 0755 + - run: + just test - name: test report junit uses: dorny/test-reporter@v1 if: ${{ success() || failure() }} @@ -54,4 +63,3 @@ jobs: if: ${{ failure() }} run: docker ps - diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index d04fa08..f3e17a1 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -17,7 +17,7 @@ jobs: path: ~/.cache/pypoetry/virtualenvs key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }} - run: | - poetry self add poetry-version-plugin + poetry self add "poetry-dynamic-versioning[plugin]" - uses: bahmutov/npm-install@v1 - run: npx semantic-release env: diff --git a/README.md b/README.md index f330a8d..d328586 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,8 @@ [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff) [![Poetry](https://img.shields.io/endpoint?url=https://python-poetry.org/badge/v0.json)](https://python-poetry.org/) -[![PyPI version](https://badge.fury.io/py/pykli.svg)](https://badge.fury.io/py/pykli) +![PyPI - Version](https://img.shields.io/pypi/v/pykli?color=greenlight) +![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pykli) ![PyPI - License](https://img.shields.io/pypi/l/pykli) Interactive [ksqlDB](https://ksqldb.io/) command line client @@ -15,16 +16,14 @@ PRs and suggestions are welcome. ## Installation * Latest released version - - ```sh - pip install pykli - ``` +```sh +pip install pykli +``` * From latest source code - - ```sh - pip install -U git+https://github.com/eshepelyuk/pykli@main - ``` +```sh +pip install -U git+https://github.com/eshepelyuk/pykli@main +``` ## Supported KSQL commands @@ -40,7 +39,6 @@ PRs and suggestions are welcome. ## TODO (prioritized) -* Semantic versioned release and publish to PyPI * Auto detect when needed output via pager * Push queries, i.e. with `EMIT CHANGES` for `SELECT` statement * In-place KSQL editing with default editor @@ -59,5 +57,3 @@ PRs and suggestions are welcome. * `PAUSE` / `RESUME` * `DESCRIBE ... EXTENDED` * `EXPLAIN` - - diff --git a/cspell.json b/cspell.json index c4aa0f6..7fb92c4 100644 --- a/cspell.json +++ b/cspell.json @@ -1 +1,10 @@ -{"version":"0.2","language":"en","words":["ksql","Pygments","pykli"],"flagWords":[]} +{ + "flagWords": [], + "language": "en", + "version": "0.2", + "words": [ + "Pygments", + "ksql", + "pykli" + ] +} diff --git a/justfile b/justfile index a4f7c50..6ad99bd 100644 --- a/justfile +++ b/justfile @@ -1,5 +1,3 @@ - - # list available receipes @default: just --list @@ -10,13 +8,16 @@ up: down: docker-compose -f tests/docker-compose.yaml down -v --remove-orphans +lint: + ruff pykli/ tests/ + test-unit filter='': poetry run pytest -o junit_suite_name='Unit tests' -m 'not e2e' --capture=tee-sys --junit-xml=test-unit.xml -k '{{filter}}' test-e2e filter='': up poetry run pytest -o junit_suite_name='E2E tests' -m e2e --capture=tee-sys --junit-xml=test-e2e.xml -k '{{filter}}' -test: test-unit test-e2e +test: lint test-unit test-e2e run srv="http://localhost:28088": poetry run pykli {{srv}} diff --git a/pykli/__main__.py b/pykli/__main__.py index 690935a..7fd0a70 100644 --- a/pykli/__main__.py +++ b/pykli/__main__.py @@ -26,12 +26,13 @@ def main(server, file): initialize_sqlparse() eval = pykli_eval(KsqlDBClient(server)) - prompt = pykli_prompt() if file is None else file_prompt(file) if isinstance(pykli_print(eval(Info(server))), ErrMsg): sys.exit(1) - evaluated = (tt for t in pykli_read(prompt) if (tt := eval(t)) is not None) + read = pykli_read(pykli_prompt() if file is None else file_prompt(file)) + + evaluated = (tt for t in read if (tt := eval(t)) is not None) for t in evaluated: pykli_print(t) diff --git a/pykli/repl_print.py b/pykli/repl_print.py index 44498f3..98d82c6 100644 --- a/pykli/repl_print.py +++ b/pykli/repl_print.py @@ -121,7 +121,8 @@ def print_show(data_type, json): def print_describe_src(data): def row_extractor(rows): return ((r["name"], format_ksql_type(r)) for r in rows) - ff = format_output(row_extractor(data["fields"]), DESCRIBE_SRC_HEADERS, format_name="psql", preprocessors=(style_output,), + ff = format_output(row_extractor(data["fields"]), DESCRIBE_SRC_HEADERS, format_name="psql", + preprocessors=(style_output,), header_token=Token.String, odd_row_token=None, even_row_token=None, style=MONOKAI_STYLE, include_default_pygments_style=False) pok("\n".join(ff)) @@ -148,7 +149,8 @@ def func_extractor(rows): for r in rows: args = [f"{a['name']} {a['type']}" for a in r["arguments"]] yield (f"{func_name}({', '.join(args)})", r["returnType"], r["description"]) - ff = format_output(func_extractor(func_arr), DESCRIBE_FUNC_VARS_HEADERS, format_name="psql", preprocessors=(style_output,), + ff = format_output(func_extractor(func_arr), DESCRIBE_FUNC_VARS_HEADERS, format_name="psql", + preprocessors=(style_output,), header_token=Token.String, odd_row_token=None, even_row_token=None, sep_title="Variation #{n}", style=MONOKAI_STYLE, include_default_pygments_style=False) pok("\n".join(ff)) @@ -166,7 +168,7 @@ def print_describe_func(data): def print_stmt(json_arr): for json in json_arr: match json: - case {"@type": tp, "statementText": stmt} if stmt.startswith(("show", "list", "SHOW", "LIST")): + case {"statementText": stmt} if stmt.startswith(("show", "list", "SHOW", "LIST")): print_show(json["@type"], json) case {"@type": "sourceDescription", "sourceDescription": data}: print_describe_src(data) diff --git a/pykli/repl_read.py b/pykli/repl_read.py index f42606a..347c0f0 100644 --- a/pykli/repl_read.py +++ b/pykli/repl_read.py @@ -15,7 +15,7 @@ from .completer import pykli_completer from .keybindgings import pykli_keys from .tokens import KSQL, Stmt, ErrMsg, PullQuery, SessionVar -from .repl_print import pok + class file_prompt: def __init__(self, path): diff --git a/pyproject.toml b/pyproject.toml index 88af7a2..81c3984 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,16 +29,19 @@ pytest-mock = "^3.11.1" exceptiongroup = {version = "^1", python = "<3.11"} [build-system] -requires = ["poetry-core"] -build-backend = "poetry.core.masonry.api" +requires = ["poetry-core>=1.0.0", "poetry-dynamic-versioning"] +build-backend = "poetry_dynamic_versioning.backend" [tool.ruff] -line-length = 140 +line-length = 120 [tool.pytest.ini_options] markers = [ "e2e: e2e tests", ] -[tool.poetry-version-plugin] -source = "git-tag" +[tool.poetry-dynamic-versioning] +enable = true +vcs = "git" +pattern = "default-unprefixed" +metadata = false diff --git a/tests/test_pykli.py b/tests/test_pykli.py index 70bb06e..c956034 100644 --- a/tests/test_pykli.py +++ b/tests/test_pykli.py @@ -6,7 +6,8 @@ from prompt_toolkit.output import DummyOutput from pykli.__main__ import main -from .conftest import list_type_names, list_topic_names, list_stream_names, list_connector_names, list_table_names, list_query_ids +from .conftest import list_type_names, list_topic_names, list_stream_names +from .conftest import list_connector_names, list_table_names, list_query_ids @pytest.fixture(scope="function")