From 3a954283d8820fe247c0f83031a6e997bd385abf Mon Sep 17 00:00:00 2001 From: Martin Hoyer Date: Wed, 15 May 2024 11:35:22 +0200 Subject: [PATCH 1/4] Adding pre-commit check to gh workflow --- .github/workflows/pre-commit.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .github/workflows/pre-commit.yml diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml new file mode 100644 index 0000000..7f579af --- /dev/null +++ b/.github/workflows/pre-commit.yml @@ -0,0 +1,14 @@ +name: pre-commit + +on: + pull_request: + push: + branches: [master] + +jobs: + pre-commit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + - uses: pre-commit/action@v3.0.1 From 0ec3668e7e2204c82041c02dc6473c329b814dbb Mon Sep 17 00:00:00 2001 From: Martin Hoyer Date: Wed, 15 May 2024 11:36:08 +0200 Subject: [PATCH 2/4] Adding PyPI release workflow --- .github/workflows/publish.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..07fc729 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,19 @@ +on: + release: + types: + - published + +name: pypi-release + +jobs: + pypi-publish: + name: Upload release to PyPI + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/p/targetcli + permissions: + id-token: write # IMPORTANT: this permission is mandatory for trusted publishing + steps: + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 From e28659f98e613bee91ae1ed2118009506778be60 Mon Sep 17 00:00:00 2001 From: Martin Hoyer Date: Wed, 15 May 2024 11:42:23 +0200 Subject: [PATCH 3/4] Fix pre-commit trimming linebreaks in markdown --- .pre-commit-config.yaml | 1 + README.md | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index bbc1aa1..fa26480 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -20,3 +20,4 @@ repos: - id: debug-statements - id: end-of-file-fixer - id: trailing-whitespace + args: [--markdown-linebreak-ext=md] diff --git a/README.md b/README.md index 6b6651a..0ec41db 100644 --- a/README.md +++ b/README.md @@ -31,10 +31,10 @@ Contribute ---------- targetcli complies with PEP 621 and as such can be built and installed with tools like `build` and `pip`. -For development, consider using [Hatch](https://hatch.pypa.io): -`hatch shell` to create and enter a Python virtualenv with the project installed in editable mode -`pre-commit install` to enable pre-commit hooks -`hatch build` to create tarball and wheel +For development, consider using [Hatch](https://hatch.pypa.io): +`hatch shell` to create and enter a Python virtualenv with the project installed in editable mode +`pre-commit install` to enable pre-commit hooks +`hatch build` to create tarball and wheel "fb" -- "free branch" --------------------- From 954c6c07da63ae06e0dc4cadc5534926e1a69e40 Mon Sep 17 00:00:00 2001 From: Martin Hoyer Date: Wed, 15 May 2024 17:26:26 +0200 Subject: [PATCH 4/4] Fix shell exit on expected errors --- src/targetcli/targetcli_shell.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/targetcli/targetcli_shell.py b/src/targetcli/targetcli_shell.py index 2d2bd7d..bd1a8f8 100644 --- a/src/targetcli/targetcli_shell.py +++ b/src/targetcli/targetcli_shell.py @@ -308,11 +308,11 @@ def main(): if not is_root: shell.con.display("You are not root, disabling privileged commands.\n") - try: - while not shell._exit: + while not shell._exit: + try: shell.run_interactive() - except (RTSLibError, ExecutionError) as msg: - shell.log.error(str(msg)) + except (RTSLibError, ExecutionError) as msg: # noqa: PERF203 - would otherwise exit shell + shell.log.error(str(msg)) if shell.prefs['auto_save_on_exit'] and is_root: shell.log.info("Global pref auto_save_on_exit=true")