Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add workflows for pre-commit and PyPI release #205

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
19 changes: 19 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ repos:
- id: debug-statements
- id: end-of-file-fixer
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
---------------------
Expand Down
8 changes: 4 additions & 4 deletions src/targetcli/targetcli_shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down