Skip to content

Commit

Permalink
Validate pyproject config with pydantic models.
Browse files Browse the repository at this point in the history
- Make plugin more verbose in console output.
- Redefine tests.
- Add mypy and make package typed.
- Add pre-commit to project.
- Replace interrogate with pydocstyle.
  • Loading branch information
monim67 committed Oct 2, 2022
1 parent f9ac4f8 commit 7fa5acc
Show file tree
Hide file tree
Showing 33 changed files with 1,438 additions and 413 deletions.
66 changes: 58 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ on:
pull_request:

jobs:
build:
if: "!contains(github.event.head_commit.message, 'skip-ci')"
pre-build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.9", "3.8", "3.7"]
python-version: ["3.10"]
steps:
- uses: actions/checkout@v3

Expand All @@ -23,14 +22,65 @@ jobs:
python-version: ${{ matrix.python-version }}
cache: poetry

- name: Check poetry.lock
run: poetry lock --check

- name: Install dependencies
run: |
poetry env use ${{ matrix.python-version }}
poetry install --no-ansi --no-root --no-interaction --only build
poetry run pip install .
poetry install --no-root --only build --no-ansi --no-interaction
poetry run pip install -c tests/pip-constraints.txt .
- name: Lint
run: poetry run poe lint

- name: Test
run: poetry run pytest
- name: Test Coverage
run: poetry run poe test-cov

- name: Coveralls Parallel
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
flag-name: run-${{ matrix.python-version }}
parallel: true

build:
runs-on: ubuntu-latest
needs: pre-build
strategy:
matrix:
python-version: ["3.9", "3.8", "3.7"]
steps:
- uses: actions/checkout@v3

- name: Install poetry
run: pipx install poetry

- uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
cache: poetry

- name: Install dependencies
run: |
poetry install --no-root --only build --no-ansi --no-interaction
poetry run pip install -c tests/pip-constraints.txt .
- name: Test Coverage
run: poetry run poe test-cov

- name: Coveralls Parallel
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
flag-name: run-${{ matrix.python-version }}
parallel: true

finish:
runs-on: ubuntu-latest
needs: [pre-build, build]
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ htmlcov/
.tox/
.coverage
.coverage.*
coverage.*
coverage/*
*.cover
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/

# Distribution / packaging
Expand Down
15 changes: 15 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
repos:
- repo: local
hooks:
- id: poetry-lock
name: Check poetry.lock consistency
language: system
entry: poetry run poe check-lock
always_run: true
pass_filenames: false
- id: lint
name: Run poe lint
language: system
entry: poetry run poe lint
always_run: true
pass_filenames: false
20 changes: 20 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Module",
"type": "python",
"request": "launch",
"module": "poetry",
"args": [
"version",
"major",
"--dry-run",
],
"justMyCode": true
}
]
}
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
{
"python.formatting.provider": "black",
"python.linting.mypyEnabled": true,
"python.linting.pydocstyleEnabled": true,
"python.testing.pytestEnabled": true,
"python.testing.unittestEnabled": false,
"[python]": {
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll": true,
"source.organizeImports": true,
}
},
Expand Down
32 changes: 25 additions & 7 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ The ``poetry version`` command only updates version in ``pyproject.toml`` file.
This plugin updates version in other files when ``poetry version <version>``
command is executed.

| |build-status| |pyversions| |pypi-version| |license|
| |build-status| |coverage.io| |pyversions| |pypi-version| |license|
********************
Getting Started
Expand All @@ -16,7 +16,7 @@ Getting Started
Prerequisites
++++++++++++++++++++

- poetry = ^1.2.0a1
- poetry = ^1.2.0a2

++++++++++++++++++++
Install
Expand Down Expand Up @@ -44,20 +44,33 @@ Add the following to your ``pyproject.toml`` file.
.. code:: toml
[tool.poetry_bumpversion.file."your_package/__init__.py"]
# Duplicate the line above to add more files
Now run ``poetry version patch`` to check if version in both ``pyproject.toml`` and
``your_package/__init__.py`` file has been updated.
Now run ``poetry version patch --dry-run``, if your output looks somewhat like below
you are all set (dry-run does not update any file).

You can add more files following the steps above. You can also fine define
search and replace terms to be more precise
::

Bumping version from 0.5.0 to 0.5.1
poetry-bumpversion: processed file: your_package/__init__.py

If dry-run output looks fine you can run version update command without dry-run flag to
check if version in both ``pyproject.toml`` and ``your_package/__init__.py`` file has been updated.

********************
Advanced Usage
********************

You can define search and replace terms to be more precise

.. code:: toml
[tool.poetry_bumpversion.file."your_package/__init__.py"]
search = '__version__ = "{current_version}"'
replace = '__version__ = "{new_version}"'
You can also define replacements if you have same search/replace patterns across multiple files.
You can define replacements if you have same search/replace patterns
across multiple files.

.. code:: toml
Expand Down Expand Up @@ -85,6 +98,11 @@ This project is licensed under MIT License - see the
:alt: Build Status
:height: 20px

.. |coverage.io| image:: https://coveralls.io/repos/github/monim67/poetry-bumpversion/badge.svg?branch=master
:target: https://coveralls.io/github/monim67/poetry-bumpversion?branch=master
:alt: Coverage Status
:height: 20px

.. |pyversions| image:: https://img.shields.io/pypi/pyversions/poetry-bumpversion.svg
:target: https://pypi.python.org/pypi/poetry-bumpversion
:alt: Python Versions
Expand Down
Loading

0 comments on commit 7fa5acc

Please sign in to comment.