Skip to content

Commit

Permalink
Merge pull request #182 from dbcli/pyproject
Browse files Browse the repository at this point in the history
Pyproject
  • Loading branch information
amjith authored Sep 8, 2024
2 parents 54f9650 + c85c501 commit e033fe4
Show file tree
Hide file tree
Showing 37 changed files with 295 additions and 677 deletions.
3 changes: 0 additions & 3 deletions .coveragerc

This file was deleted.

33 changes: 12 additions & 21 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
pull_request:
paths-ignore:
- '**.md'
- 'AUTHORS'

jobs:
build:
Expand All @@ -14,31 +15,21 @@ jobs:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: astral-sh/setup-uv@v1
with:
version: "latest"

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install requirements
run: |
python -m pip install -U pip setuptools
pip install --no-cache-dir -e .
pip install -r requirements-dev.txt -U --upgrade-strategy=only-if-needed
- name: Install dependencies
run: uv sync --all-extras -p ${{ matrix.python-version }}

- name: Run unit tests
env:
PYTEST_PASSWORD: root
run: |
./setup.py test --pytest-args="--cov-report= --cov=litecli"
- name: Run Black
run: |
./setup.py lint
if: matrix.python-version == '3.7'

- name: Coverage
run: |
coverage report
codecov
run: uv run --verbose tox -e py${{ matrix.python-version }}

- name: Run Style Checks
run: uv run --verbose tox -e style
81 changes: 81 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Publish Python Package

on:
release:
types: [created]

permissions:
contents: read

jobs:
test:
runs-on: ubuntu-latest

strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v1
with:
version: "latest"

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: uv sync --all-extras -p ${{ matrix.python-version }}

- name: Run unit tests
run: uv run tox -e py${{ matrix.python-version }}

- name: Run Style Checks
run: uv run tox -e style

build:
runs-on: ubuntu-latest
needs: [test]

steps:
- uses: actions/checkout@v3
- uses: astral-sh/setup-uv@v1
with:
version: "latest"

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Install dependencies
run: uv sync --all-extras -p 3.12

- name: Build
run: |
python -m build
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-packages
path: dist/

publish:
name: Publish to PyPI
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
needs: [build]
environment: release
permissions:
id-token: write
steps:
- name: Download distribution packages
uses: actions/download-artifact@v4
with:
name: python-packages
path: dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
13 changes: 9 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
repos:
- repo: https://github.com/psf/black
rev: 23.11.0
hooks:
- id: black
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.6.4
hooks:
# Run the linter.
- id: ruff
args: [ --fix ]
# Run the formatter.
- id: ruff-format
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## 1.12.0 - 2024-09-07

## Internal Changes

* Modernize the project with following changes:
* pyproject.toml instead of setup.py
* Use ruff for linting and formatting
* Update GH actions to use uv and tox
* Use GH actions to release a new version

## 1.11.1 - 2024-07-04

### Bug Fixes
Expand Down
30 changes: 7 additions & 23 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Development Guide

This is a guide for developers who would like to contribute to this project. It is recommended to use Python 3.7 and above for development.
This is a guide for developers who would like to contribute to this project. It is recommended to use Python 3.10 and above for development.

If you're interested in contributing to litecli, thank you. We'd love your help!
You'll always get credit for your work.
Expand All @@ -24,16 +24,15 @@ You'll always get credit for your work.

```bash
$ cd litecli
$ pip install virtualenv
$ virtualenv litecli_dev
$ python -m venv .venv
```

We've just created a virtual environment that we'll use to install all the dependencies
and tools we need to work on litecli. Whenever you want to work on litecli, you
need to activate the virtual environment:

```bash
$ source litecli_dev/bin/activate
$ source .venv/bin/activate
```

When you're done working, you can deactivate the virtual environment:
Expand All @@ -45,8 +44,7 @@ You'll always get credit for your work.
5. Install the dependencies and development tools:
```bash
$ pip install -r requirements-dev.txt
$ pip install --editable .
$ pip install --editable .[dev]
```
6. Create a branch for your bugfix or feature based off the `main` branch:
Expand Down Expand Up @@ -75,18 +73,10 @@ You'll always get credit for your work.
While you work on litecli, it's important to run the tests to make sure your code
hasn't broken any existing functionality. To run the tests, just type in:
```bash
$ ./setup.py test
```
litecli supports Python 3.7+. You can test against multiple versions of
Python by running tox:
```bash
$ tox
```
### CLI Tests
Some CLI tests expect the program `ex` to be a symbolic link to `vim`.
Expand All @@ -102,18 +92,12 @@ $ readlink -f $(which ex)
## Coding Style
litecli uses [black](https://github.com/ambv/black) to format the source code. Make sure to install black.
It's easy to check the style of your code, just run:

```bash
$ ./setup.py lint
```
Litecli uses [ruff](https://docs.astral.sh/ruff/) to format the source code.
If you see any style issues, you can automatically fix them by running:
To check the style and fix any violations, run:
```bash
$ ./setup.py lint --fix
$ tox -e style
```
Be sure to commit and push any stylistic fixes.
6 changes: 2 additions & 4 deletions litecli/clistyle.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def parse_pygments_style(token_name, style_object, style_dict):
try:
other_token_type = string_to_tokentype(style_dict[token_name])
return token_type, style_object.styles[other_token_type]
except AttributeError as err:
except AttributeError:
return token_type, style_dict[token_name]


Expand Down Expand Up @@ -85,9 +85,7 @@ def style_factory(name, cli_style):
prompt_styles.append((token, cli_style[token]))

override_style = Style([("bottom-toolbar", "noreverse")])
return merge_styles(
[style_from_pygments_cls(style), override_style, Style(prompt_styles)]
)
return merge_styles([style_from_pygments_cls(style), override_style, Style(prompt_styles)])


def style_factory_output(name, cli_style):
Expand Down
12 changes: 3 additions & 9 deletions litecli/clitoolbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,17 @@ def get_toolbar_tokens():
result.append(("class:bottom-toolbar", " "))

if cli.multi_line:
result.append(
("class:bottom-toolbar", " (Semi-colon [;] will end the line) ")
)
result.append(("class:bottom-toolbar", " (Semi-colon [;] will end the line) "))

if cli.multi_line:
result.append(("class:bottom-toolbar.on", "[F3] Multiline: ON "))
else:
result.append(("class:bottom-toolbar.off", "[F3] Multiline: OFF "))
if cli.prompt_app.editing_mode == EditingMode.VI:
result.append(
("class:botton-toolbar.on", "Vi-mode ({})".format(_get_vi_mode()))
)
result.append(("class:botton-toolbar.on", "Vi-mode ({})".format(_get_vi_mode())))

if show_fish_help():
result.append(
("class:bottom-toolbar", " Right-arrow to complete suggestion")
)
result.append(("class:bottom-toolbar", " Right-arrow to complete suggestion"))

if cli.completion_refresher.is_refreshing():
result.append(("class:bottom-toolbar", " Refreshing completions..."))
Expand Down
9 changes: 0 additions & 9 deletions litecli/compat.py

This file was deleted.

38 changes: 0 additions & 38 deletions litecli/encodingutils.py

This file was deleted.

Loading

0 comments on commit e033fe4

Please sign in to comment.