Skip to content

Commit

Permalink
Use poetry as package manager (#99)
Browse files Browse the repository at this point in the history
* Add poetry and refactor pyproject.toml

* Change poetry dep install call

* Adjust lint rules and reapply

* Remove unused extensions from devcontainer

* Update ci to use poetry

---------

Co-authored-by: tb1337 <[email protected]>
  • Loading branch information
tb1337 authored Feb 18, 2024
1 parent 89fbfcb commit 6063c31
Show file tree
Hide file tree
Showing 43 changed files with 1,569 additions and 197 deletions.
File renamed without changes.
9 changes: 3 additions & 6 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
{
"name": "PyPaperless Dev",
"context": "..",
"dockerFile": "../Dockerfile",
"dockerFile": "Dockerfile.dev",
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
"containerEnv": {
"DEVCONTAINER": "1"
},
"postCreateCommand": "script/setup",
"postStartCommand": "script/bootstrap",
"runArgs": ["-e", "GIT_EDITOR=code --wait"],
"remoteUser": "vscode",
"customizations": {
"vscode": {
"extensions": [
"ms-python.black-formatter",
"ms-python.pylint",
"ms-python.vscode-pylance",
"visualstudioexptteam.vscodeintellicode",
"redhat.vscode-yaml",
"esbenp.prettier-vscode",
"GitHub.vscode-pull-request-github",
"ms-azuretools.vscode-docker",
"ms-python.isort",
"ms-python.mypy-type-checker"
],
"settings": {
Expand All @@ -41,6 +39,5 @@
"terminal.integrated.defaultProfile.linux": "zsh"
}
}
},
"remoteUser": "vscode"
}
}
2 changes: 1 addition & 1 deletion .github/workflows/pre-commit-updater.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Pre-commit auto-update

on:
schedule:
- cron: '0 0 * * 1'
- cron: "0 0 * * 1"

env:
DEFAULT_PYTHON: "3.11"
Expand Down
27 changes: 11 additions & 16 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,31 +24,26 @@ jobs:
steps:
- name: ⤵️ Checkout code
uses: actions/[email protected]
- name: 🏷 Get repository tag
id: vars
run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
- name: 🚧 Setup Poetry
run: pip install poetry
- name: 🐍 Setup Python ${{ env.DEFAULT_PYTHON }}
uses: actions/[email protected]
with:
python-version: ${{ env.DEFAULT_PYTHON }}
cache: poetry
- name: 🚧 Install dependencies
run: |
python -m pip install --upgrade pip
pip install build tomli tomli-w
run: poetry install --no-interaction
- name: 🏷 Get repository tag
id: vars
run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
- name: 🚧 Set project version from tag
shell: python
run: |-
import tomli
import tomli_w
with open("pyproject.toml", "rb") as f:
pyproject = tomli.load(f)
pyproject["project"]["version"] = "${{ steps.vars.outputs.tag }}"
with open("pyproject.toml", "wb") as f:
tomli_w.dump(pyproject, f)
run: poetry version --no-interaction "${{ steps.vars.outputs.tag }}"
- name: 🚀 Build package
run: python -m build
run: poetry build --no-interaction
- name: ⬆️ Publish to PyPi
uses: pypa/[email protected]
with:
print-hash: true
- name: 🔏 Sign published artifacts
uses: sigstore/[email protected]
with:
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,20 @@ jobs:
stale-issue-label: "stale"
exempt-issue-labels: "no-stale,help-wanted"
stale-issue-message: >
There hasn't been any activity on this issue recently, so we
clean up some of the older and inactive issues.
There hasn't been any activity on this issue recently, so we have to
clean up some inactive issues.
Please make sure to update to the latest version and
check if that solves the issue. Let us know if that works for you
by leaving a comment 👍
This issue has now been marked as stale and will be closed if no
further activity occurs. Thanks!
further activity occurs. Thank you.
stale-pr-label: "stale"
exempt-pr-labels: "no-stale"
stale-pr-message: >
There hasn't been any activity on this pull request recently. This
pull request has been automatically marked as stale because of that
and will be closed if no further activity occurs within 7 days.
Thank you for your contributions.
Thank you for your contribution!
16 changes: 11 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,17 @@ jobs:
steps:
- name: ⤵️ Checkout code
uses: actions/[email protected]
- name: 🚧 Setup Poetry
run: pip install poetry
- name: 🐍 Setup Python ${{ matrix.python-version }}
uses: actions/[email protected]
with:
python-version: ${{ matrix.python-version }}
cache: poetry
- name: 🚧 Install dependencies
run: pip install . .[test]
run: poetry install --no-root --only main,test --no-interaction
- name: 🚀 Run Pytest
run: pytest --cov pypaperless tests
run: poetry run pytest --cov pypaperless tests
- name: ⬆️ Upload coverage
uses: actions/[email protected]
with:
Expand All @@ -44,16 +47,19 @@ jobs:
uses: actions/[email protected]
- name: ⬇️ Download coverage
uses: actions/[email protected]
- name: 🚧 Setup Poetry
run: pip install poetry
- name: 🐍 Setup Python ${{ env.DEFAULT_PYTHON }}
uses: actions/[email protected]
with:
python-version: ${{ env.DEFAULT_PYTHON }}
cache: poetry
- name: 🚧 Install dependencies
run: pip install . .[test]
run: poetry install --no-root --only main,test --no-interaction
- name: 🚀 Process coverage results
run: |
coverage combine coverage*/.coverage*
coverage xml -i
poetry run coverage combine coverage*/.coverage*
poetry run coverage xml -i
- name: ⬆️ Upload coverage to Codecov
uses: codecov/[email protected]
env:
Expand Down
31 changes: 17 additions & 14 deletions .github/workflows/typing-linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,27 @@ jobs:
steps:
- name: ⤵️ Checkout code
uses: actions/[email protected]
- name: 🚧 Setup Poetry
run: pip install poetry
- name: 🐍 Setup Python ${{ env.DEFAULT_PYTHON }}
uses: actions/[email protected]
with:
python-version: ${{ env.DEFAULT_PYTHON }}
cache: poetry
- name: 🚧 Install dependencies
run: pip install . .[test]
run: poetry install --no-root --only main,dev --no-interaction
- name: 🚀 Run pre-commit hooks
run: |
pre-commit run check-yaml --all-files
pre-commit run check-toml --all-files
pre-commit run check-ast --all-files
pre-commit run check-docstring-first --all-files
pre-commit run debug-statements --all-files
pre-commit run end-of-file-fixer --all-files
pre-commit run trailing-whitespace --all-files
pre-commit run ruff --all-files
pre-commit run ruff-format --all-files
pre-commit run black --all-files
pre-commit run codespell --all-files
pre-commit run mypy --all-files
pre-commit run pylint --all-files
poetry run pre-commit run check-yaml --all-files
poetry run pre-commit run check-toml --all-files
poetry run pre-commit run check-ast --all-files
poetry run pre-commit run check-docstring-first --all-files
poetry run pre-commit run debug-statements --all-files
poetry run pre-commit run end-of-file-fixer --all-files
poetry run pre-commit run trailing-whitespace --all-files
poetry run pre-commit run ruff --all-files
poetry run pre-commit run ruff-format --all-files
poetry run pre-commit run black --all-files
poetry run pre-commit run codespell --all-files
poetry run pre-commit run mypy --all-files
poetry run pre-commit run pylint --all-files
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,3 @@ venv.bak/

# mypy
.mypy_cache/

tests_old
15 changes: 6 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ repos:
- id: debug-statements
name: ✅ Check debug statements
- id: end-of-file-fixer
name: Fix end of files
name: ⮐ Fix end of files
- id: trailing-whitespace
name: Trailing whitespace
name: ⮐ Trailing whitespace
- id: no-commit-to-branch
name: 🛑 No commit to main branch
args:
Expand All @@ -41,22 +41,19 @@ repos:
hooks:
- id: codespell
name: ✅ Check code for proper spelling
args: []
exclude_types: [csv, json]
additional_dependencies:
- tomli
- repo: local
hooks:
- id: mypy
name: 🆎 Type checking with mypy
entry: script/run-in-env.sh mypy
language: script
language: system
types: [python]
entry: poetry run mypy
require_serial: true
files: ^pypaperless/.+\.py$
- id: pylint
name: 🌟 Rating code with pylint
entry: script/run-in-env.sh pylint -j 0
language: script
language: system
types: [python]
files: ^pypaperless/.+\.py$
entry: poetry run pylint pypaperless -j 0
5 changes: 1 addition & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,5 @@
"tests"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"files.associations": {
"*.yaml": "yaml"
},
"python.testing.pytestEnabled": true
}
Loading

0 comments on commit 6063c31

Please sign in to comment.