Skip to content

Commit 0104ca6

Browse files
authored
Merge pull request #4 from numberly/chore/hatch
chore(hatch): hatch builder + ci + lint
2 parents ecdfc5d + 7e6f66c commit 0104ca6

File tree

17 files changed

+407
-92
lines changed

17 files changed

+407
-92
lines changed

.github/workflows/ci.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: CI
2+
3+
on: [ push, pull_request ]
4+
5+
jobs:
6+
test:
7+
strategy:
8+
fail-fast: false
9+
matrix:
10+
python-version: [ '3.10', '3.11' ]
11+
os: [ ubuntu-latest ]
12+
runs-on: ${{ matrix.os }}
13+
steps:
14+
- uses: actions/checkout@v3
15+
- name: Setup Python ${{ matrix.python-version }}
16+
uses: actions/setup-python@v4
17+
with:
18+
python-version: ${{ matrix.python-version }}
19+
- name: Install dependencies
20+
run: |
21+
python -m pip install --upgrade hatch
22+
- name: Run tests
23+
run: |
24+
hatch run +py=${{ matrix.py || matrix.python-version }} test:with-coverage
25+
26+
lint:
27+
runs-on: ubuntu-latest
28+
steps:
29+
- uses: actions/checkout@v3
30+
- name: Setup Python
31+
uses: actions/setup-python@v4
32+
with:
33+
python-version: '3.10'
34+
- name: Install Python dependencies
35+
run: |
36+
python -m pip install --upgrade hatch
37+
- name: Check with black + isort
38+
if: always()
39+
run: hatch run style:format && git diff --exit-code
40+
- name: Check with ruff
41+
if: always()
42+
run: hatch run style:lint
43+
- name: Check with mypy
44+
if: always()
45+
run: hatch run types:check
46+
47+
package:
48+
runs-on: ubuntu-latest
49+
steps:
50+
- uses: actions/checkout@v3
51+
- name: Setup Python
52+
uses: actions/setup-python@v4
53+
with:
54+
python-version: '3.10'
55+
- name: Install Hatch
56+
run: |
57+
python -m pip install -U hatch
58+
- name: Build package
59+
run: |
60+
hatch build
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: deploy-release
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
8+
jobs:
9+
pypi:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v3
13+
- name: Setup Python
14+
uses: actions/setup-python@v4
15+
with:
16+
python-version: '3.10'
17+
- name: Install Hatch
18+
run: |
19+
python -m pip install -U hatch
20+
- name: Build package
21+
run: |
22+
hatch build
23+
- name: Publish
24+
run: |
25+
hatch publish
26+
env:
27+
HATCH_INDEX_USER: __token__
28+
HATCH_INDEX_AUTH: ${{ secrets.PYPI_PASSWORD }}

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# python-vaultwarden
22

3+
[![PyPI Version][pypi-v-image]][pypi-v-link]
4+
[![Build Status][GHAction-image]][GHAction-link]
5+
36
A python library for vaultwarden
47

58
## Clients
@@ -17,6 +20,23 @@ target user.
1720
The cryptographic part is handled by the [bitwardentools library](https://github.com/corpusops/bitwardentools).
1821

1922

23+
<!-- Badges -->
24+
25+
[pypi-v-image]: https://img.shields.io/pypi/v/python-vaultwarden.svg
26+
27+
[pypi-v-link]: https://pypi.org/project/python-vaultwarden/
28+
29+
[GHAction-image]: https://github.com/numberly/python-vaultwarden/workflows/CI/badge.svg?branch=main&event=push
30+
31+
[GHAction-link]: https://github.com/numberly/python-vaultwarden/actions?query=event%3Apush+branch%3Amain
32+
<!-- Links -->
33+
34+
[Issue]: https://github.com/numberly/python-vaultwarden/issues
35+
36+
[Discussions]: https://github.com/numberly/python-vaultwarden/discussions
37+
38+
[PyPA Code of Conduct]: https://www.pypa.io/en/latest/code-of-conduct/
39+
2040
## License
2141

2242
Python-vaultwarden is distributed under the terms of the [Apache](https://spdx.org/licenses/Apache-2.0.html) license.

pyproject.toml

Lines changed: 127 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,148 @@
1+
[build-system]
2+
requires = ["hatchling"]
3+
build-backend = "hatchling.build"
4+
15
[project]
26
name = "python-vaultwarden"
37
version = "0.7.0"
4-
description = "The Vautlwarden Python Client"
5-
requires-python = ">=3.11"
8+
description = "Admin Vaultwarden and Simple Bitwarden Python Client"
69
authors = [
710
{ name = "Lyonel Martinez", email = "[email protected]" },
811
{ name = "Mathis Ribet", email = "[email protected]" },
912
]
13+
license = "Apache-2.0"
14+
readme = "README.md"
15+
repository = "https://github.com/numberly/python-vaultwarden"
16+
documentation = "https://numberly.github.io/python-vaultwarden/"
17+
packages = [
18+
{ include = "vaultwarden", from = "src" },
19+
]
1020
classifiers = [
1121
"Development Status :: 4 - Beta",
12-
"Environment :: Web Environment",
1322
"Intended Audience :: Developers",
23+
"Environment :: Web Environment",
24+
"License :: OSI Approved :: Apache Software License",
1425
"Operating System :: OS Independent",
26+
"Intended Audience :: Developers",
27+
"Programming Language :: Python",
28+
"Programming Language :: Python :: 3",
29+
"Programming Language :: Python :: 3 :: Only",
30+
"Programming Language :: Python :: 3.10",
1531
"Programming Language :: Python :: 3.11",
32+
"Typing :: Typed",
1633
"Topic :: Internet :: WWW/HTTP",
34+
# Include this classifier to prevent accidently publishing private code to PyPI.
35+
# https://pypi.org/classifiers/
36+
"Private :: Do Not Upload",
37+
]
38+
requires-python = ">=3.10"
39+
dependencies = [
40+
"bitwardentools >=1.0.55",
41+
"httpx >=0.24.1",
42+
]
43+
44+
[tool.hatch.version]
45+
path = "src/vaultwarden/__version__.py"
46+
47+
[tool.hatch.build]
48+
packages = [
49+
"src/vaultwarden",
50+
]
51+
include = [
52+
"/tests",
53+
]
54+
55+
[tool.hatch.build.targets.sdist]
56+
include = ["/src/vaultwarden/**/*.py"]
57+
[tool.hatch.build.targets.wheel]
58+
packages = [
59+
"src/vaultwarden",
60+
]
61+
62+
[tool.hatch.envs.test]
63+
dependencies = [
64+
"coverage",
1765
]
66+
67+
[tool.hatch.envs.test.scripts]
68+
test = "coverage run --source=src/vaultwarden -m unittest discover -p 'test_*.py' tests --top-level-directory ."
69+
_coverage = ["test", "coverage xml", "coverage report --show-missing"]
70+
with-coverage = "test"
71+
[[tool.hatch.envs.test.matrix]]
72+
python = ["3.10", "3.11"]
73+
type = ["default"]
74+
[tool.hatch.envs.test.overrides]
75+
matrix.type.scripts = [
76+
{ key = "with-coverage", value = "_coverage", if = ["default"] },
77+
]
78+
79+
[tool.hatch.envs.types]
80+
dependencies = [
81+
"mypy",
82+
"types-PyYAML",
83+
"types-setuptools",
84+
"typing-extensions",
85+
]
86+
[tool.hatch.envs.types.scripts]
87+
check = "mypy src/vaultwarden"
88+
89+
[tool.hatch.envs.style]
90+
detached = true
1891
dependencies = [
19-
"bitwardentools==1.0.55",
20-
"httpx==0.24.1",
92+
"black",
93+
"isort",
94+
"ruff",
95+
]
96+
[tool.hatch.envs.style.scripts]
97+
lint = [
98+
"ruff check --fix src/vaultwarden",
99+
]
100+
check = [
101+
"isort --check-only --diff src/vaultwarden",
102+
"black -q --check --diff src/vaultwarden",
103+
"ruff check src/vaultwarden",
21104
]
105+
format = [
106+
"isort -q src/vaultwarden",
107+
"black -q src/vaultwarden",
108+
"lint"
109+
]
110+
111+
[tool.ruff]
112+
# Add "Q" to the list of enabled codes.
113+
select = ["B", "E", "F", "I", "N", "Q", "RUF", "SIM", "TCH"]
114+
fixable = ["ALL"]
115+
src = ["src/vaultwarden", "tests"]
116+
target-version = "py310"
117+
line-length = 79
118+
119+
[tool.ruff.flake8-quotes]
120+
docstring-quotes = "double"
121+
122+
[tool.ruff.flake8-bugbear]
123+
extend-immutable-calls = ["typer.Argument"]
124+
125+
[tool.ruff.isort]
126+
force-sort-within-sections = true
127+
128+
[tool.black]
129+
line-length = 79
130+
target-version = ["py310", "py311"]
131+
132+
[tool.isort]
133+
profile = "black"
134+
line_length = 80
135+
136+
[tool.mypy]
137+
ignore_missing_imports = true
138+
warn_unreachable = true
139+
no_implicit_optional = true
140+
show_error_codes = true
22141

23142
[tool.commitizen]
24143
version = "0.7.0"
144+
tag_format = "$version"
145+
update_changelog_on_bump = true
25146
version_files = [
26-
"pyproject.toml:version",
27-
"vaultwarden/__version__.py",
147+
"src/vaultwarden/__version__.py",
28148
]

0 commit comments

Comments
 (0)