Skip to content
This repository has been archived by the owner on Oct 5, 2023. It is now read-only.

Commit

Permalink
fix: semantic release
Browse files Browse the repository at this point in the history
  • Loading branch information
eshepelyuk committed Jul 29, 2023
1 parent 2a590b8 commit ec4b4b9
Show file tree
Hide file tree
Showing 11 changed files with 54 additions and 33 deletions.
4 changes: 2 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -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

12 changes: 10 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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() }}
Expand All @@ -54,4 +63,3 @@ jobs:
if: ${{ failure() }}
run:
docker ps

2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
20 changes: 8 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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
Expand All @@ -59,5 +57,3 @@ PRs and suggestions are welcome.
* `PAUSE` / `RESUME`
* `DESCRIBE ... EXTENDED`
* `EXPLAIN`


11 changes: 10 additions & 1 deletion cspell.json
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
{"version":"0.2","language":"en","words":["ksql","Pygments","pykli"],"flagWords":[]}
{
"flagWords": [],
"language": "en",
"version": "0.2",
"words": [
"Pygments",
"ksql",
"pykli"
]
}
7 changes: 4 additions & 3 deletions justfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


# list available receipes
@default:
just --list
Expand All @@ -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}}
Expand Down
5 changes: 3 additions & 2 deletions pykli/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
8 changes: 5 additions & 3 deletions pykli/repl_print.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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))
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion pykli/repl_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
13 changes: 8 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 2 additions & 1 deletion tests/test_pykli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit ec4b4b9

Please sign in to comment.