Skip to content
Merged
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
80 changes: 38 additions & 42 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,34 +17,22 @@ cd python-cli-template

## Install

Install [Python](https://www.python.org/):
Install [uv](https://docs.astral.sh/uv/):

```sh
brew install python
brew install uv
```

Create the virtual environment:
Install development dependencies:

```sh
python3 -m venv .venv
```

Activate the virtual environment:

```sh
source .venv/bin/activate
```

Install the dependencies:

```sh
pip install -e '.[build,docs,lint,test]'
uv sync --all-extras
```

Install pre-commit into your git hooks:

```sh
pre-commit install
uv run pre-commit install
```

## Develop
Expand Down Expand Up @@ -74,38 +62,38 @@ Things that will improve the chance that your pull request will be accepted:

## Test

Install the dependencies:
Install test dependencies:

```sh
pip install -e '.[test]'
uv sync --extra test
```

Run the tests:

```sh
pytest
uv run pytest
```

Run the tests with [coverage](https://coverage.readthedocs.io/):

```sh
coverage run -m pytest
uv run coverage run -m pytest
```

Generate a coverage report:

```sh
coverage report
uv run coverage report
```

```sh
coverage html
uv run coverage html
```

Install the package with [pipx](https://pipx.pypa.io/):
Install the package with [uv](https://docs.astral.sh/uv/):

```sh
pipx install . --force
uv tool install . --force
```

Test the command:
Expand All @@ -116,80 +104,88 @@ python-cli-template --help

## Lint

Install the dependencies:
Install lint dependencies:

```sh
pip install -e '.[lint]'
uv sync --extra lint
```

Update pre-commit hooks to the latest version:

```sh
pre-commit autoupdate
uv run pre-commit autoupdate
```

Run all pre-commit hooks:

```sh
pre-commit run --all-files
uv run pre-commit run --all-files
```

Lint all files:

```sh
uv run ruff check # --fix
```

Lint all files in the current directory:
Format all files:

```sh
ruff check
uv run ruff format
```

Format all files in the current directory:
## Run

Run the CLI:

```sh
ruff format
uv run python-cli-template
```

## Build

Install the dependencies:
Install build dependencies:

```sh
pip install -e '.[build]'
uv sync --extra build
```

Generate the distribution packages:

```sh
python3 -m build
uv build
```

Upload all of the archives under `dist`:

```sh
twine upload --repository testpypi dist/*
uv publish --repository testpypi
```

Install the package:

```sh
pip install --index-url https://test.pypi.org/simple/ --no-deps python-cli-template
uv tool install --index-url testpypi python-cli-template
```

Bundle the package with [PyInstaller](https://pyinstaller.org/):

```sh
pyinstaller src/python-cli-template/cli.py --name python-cli-template
uv run pyinstaller python_cli_template.cli --name python-cli-template
```

## Docs

Install the dependencies:
Install docs dependencies:

```sh
pip install -e '.[docs]'
uv sync --extra docs
```

Generate the docs with [pdoc](https://pdoc.dev/):

```sh
pdoc src/python_cli_template/
uv run pdoc src/python_cli_template/
```

## Release
Expand Down
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

version: 2
updates:
- package-ecosystem: 'pip'
- package-ecosystem: 'uv'
directory: '/'
schedule:
interval: 'daily'
Expand Down
11 changes: 4 additions & 7 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,14 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v6

- name: Use Python
uses: actions/setup-python@v6
with:
cache: pip
python-version-file: pyproject.toml
- name: Install uv
uses: astral-sh/setup-uv@v7

- name: Install dependencies
run: pip install -e .[docs]
run: uv sync --extra docs

- name: Build docs
run: pdoc src/python_cli_template/ -o docs
run: uv run pdoc src/python_cli_template/ -o docs

- name: Deploy
if: github.ref_name == 'master'
Expand Down
17 changes: 7 additions & 10 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,20 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v6

- name: Use Python
uses: actions/setup-python@v6
with:
cache: pip
python-version-file: pyproject.toml
- name: Install uv
uses: astral-sh/setup-uv@v7

- name: Install dependencies
run: pip install -e .[lint]
run: uv sync --extra lint

- name: Type check
run: mypy .
run: uv run mypy .

- name: Run Black
run: black --check .
run: uv run black --check .

- name: Run Ruff
run: ruff check
run: uv run ruff check

- name: Run pre-commit
run: pre-commit run --all-files
run: uv run pre-commit run --all-files
23 changes: 8 additions & 15 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,14 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v6

- name: Use Python
uses: actions/setup-python@v6
with:
python-version-file: pyproject.toml

- name: Install build
run: python -m pip install build
- name: Install uv
uses: astral-sh/setup-uv@v7

- name: Build package
run: python -m build
run: uv build

- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
run: uv publish

upload:
needs: release
Expand All @@ -64,16 +59,14 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v6

- name: Use Python
uses: actions/setup-python@v6
with:
python-version-file: pyproject.toml
- name: Install uv
uses: astral-sh/setup-uv@v7

- name: Install dependencies
run: pip install -e '.[build]'
run: uv sync --extra build

- name: Build executable
run: pyinstaller src/python_cli_template/cli.py --name python-cli-template --onefile --clean
run: uv run pyinstaller python_cli_template.cli --name python-cli-template --onefile --clean

- name: Compress executable
shell: bash
Expand Down
64 changes: 21 additions & 43 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,53 +11,23 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v6

- name: Use Python
uses: actions/setup-python@v6
with:
cache: pip
python-version-file: pyproject.toml
- name: Install uv
uses: astral-sh/setup-uv@v7

- name: Install dependencies
run: pip install -e .[test]
run: uv sync --extra test

- name: Run tests and collect coverage
run: |
coverage run -m pytest
coverage report
coverage xml
uv run coverage run -m pytest
uv run coverage report
uv run coverage xml

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}

install:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6

- name: Use Python
uses: actions/setup-python@v6
with:
cache: pip
python-version-file: pyproject.toml

- name: Install package
run: pipx install .

- name: Check version
run: |
version=$(grep version src/python_cli_template/__init__.py | cut -d'"' -f 2)
echo $version
python-cli-template --version
set -e
[[ $(python-cli-template --version) == $version ]]
[[ $(python-cli-template -v) == $version ]]

- name: Get help
run: python-cli-template --help

integration:
runs-on: ubuntu-latest
strategy:
Expand All @@ -69,14 +39,22 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v6

- name: Use Python
uses: actions/setup-python@v6
with:
cache: pip
python-version-file: pyproject.toml
- name: Install uv
uses: astral-sh/setup-uv@v7

- name: Install package
run: pipx install .
- name: Install tool
run: uv tool install .

- name: Run command
run: ${{ matrix.command }}

- name: Get version
run: |
VERSION=$(grep version src/python_cli_template/__init__.py | cut -d'"' -f 2)
echo "VERSION=$VERSION" >> $GITHUB_ENV

- name: Check version
run: |
set -e
[[ $(python-cli-template --version) == "$VERSION" ]]
[[ $(python-cli-template -v) == "$VERSION" ]]
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ ipython_config.py
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
#uv.lock
uv.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
Expand Down
Loading