Skip to content

Commit e67ef6a

Browse files
committed
updates packaging
1 parent e18be73 commit e67ef6a

File tree

19 files changed

+484
-344
lines changed

19 files changed

+484
-344
lines changed

.github/workflows/lint.yaml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- develop
8+
pull_request:
9+
10+
jobs:
11+
changes:
12+
runs-on: ubuntu-latest
13+
timeout-minutes: 1
14+
defaults:
15+
run:
16+
shell: bash
17+
outputs:
18+
run_tests: ${{ steps.changes.outputs.run_tests }}
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
- id: changes
23+
name: Check for file changes
24+
uses: dorny/paths-filter@0bc4621a3135347011ad047f9ecf449bf72ce2bd # v3.0.0
25+
with:
26+
base: ${{ github.ref }}
27+
token: ${{ github.token }}
28+
filters: .github/file-filters.yml
29+
30+
pkg_meta:
31+
needs: [ changes ]
32+
if: needs.changes.outputs.run_tests == 'true'
33+
34+
runs-on: ubuntu-latest
35+
steps:
36+
- uses: actions/checkout@v4
37+
- uses: actions/setup-python@v2
38+
39+
- name: Install dependencies
40+
run: |
41+
python -m pip install --upgrade pip tox
42+
- name: Lint with flake8
43+
run: |
44+
tox -e pkg_meta
45+
lint:
46+
needs: [ changes ]
47+
if: needs.changes.outputs.run_tests == 'true'
48+
49+
runs-on: ubuntu-latest
50+
steps:
51+
- uses: actions/checkout@v4
52+
- uses: actions/setup-python@v2
53+
54+
- name: Install dependencies
55+
run: |
56+
python -m pip install --upgrade pip tox
57+
- name: Lint with flake8
58+
run: |
59+
tox -e lint

.github/workflows/release.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Release to PyPI
2+
on:
3+
push:
4+
tags: ["*"]
5+
6+
env:
7+
dists-artifact-name: python-package-distributions
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
with:
15+
fetch-depth: 0
16+
- name: Install the latest version of uv
17+
uses: astral-sh/setup-uv@v5
18+
with:
19+
enable-cache: true
20+
cache-dependency-glob: "pyproject.toml"
21+
github-token: ${{ secrets.GITHUB_TOKEN }}
22+
- name: Build package
23+
run: uv build --python 3.13 --python-preference only-managed --sdist --wheel . --out-dir dist
24+
- name: Store the distribution packages
25+
uses: actions/upload-artifact@v4
26+
with:
27+
name: ${{ env.dists-artifact-name }}
28+
path: dist/*
29+
30+
release:
31+
needs:
32+
- build
33+
runs-on: ubuntu-latest
34+
environment:
35+
name: release
36+
url: https://pypi.org/project/django-concurrency/${{ github.ref_name }}
37+
permissions:
38+
id-token: write
39+
steps:
40+
- name: Download all the dists
41+
uses: actions/download-artifact@v4
42+
with:
43+
name: ${{ env.dists-artifact-name }}
44+
path: dist/
45+
- name: Publish to PyPI
46+
uses: pypa/[email protected]
47+
with:
48+
attestations: true

.github/workflows/tests.yaml

Lines changed: 12 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -27,37 +27,6 @@ jobs:
2727
token: ${{ github.token }}
2828
filters: .github/file-filters.yml
2929

30-
pkg_meta:
31-
needs: [ changes ]
32-
if: needs.changes.outputs.run_tests == 'true'
33-
34-
runs-on: ubuntu-latest
35-
steps:
36-
- uses: actions/checkout@v4
37-
- uses: actions/setup-python@v2
38-
39-
- name: Install dependencies
40-
run: |
41-
python -m pip install --upgrade pip tox
42-
- name: Lint with flake8
43-
run: |
44-
tox -e pkg_meta
45-
lint:
46-
needs: [ changes ]
47-
if: needs.changes.outputs.run_tests == 'true'
48-
49-
runs-on: ubuntu-latest
50-
steps:
51-
- uses: actions/checkout@v4
52-
- uses: actions/setup-python@v2
53-
54-
- name: Install dependencies
55-
run: |
56-
python -m pip install --upgrade pip tox
57-
- name: Lint with flake8
58-
run: |
59-
tox -e lint
60-
6130
test:
6231
needs: [ changes ]
6332
if: needs.changes.outputs.run_tests == 'true'
@@ -66,12 +35,12 @@ jobs:
6635
strategy:
6736
fail-fast: false
6837
matrix:
69-
python-version: [ "3.11", "3.12" ]
70-
django-version: [ "3.2", "4.2", "5.1" ]
38+
python: [ "3.11", "3.12" ]
39+
django: [ "32", "42", "51" ]
7140
db-engine: [ "pg", "mysql" ]
7241
env:
73-
PY_VER: ${{ matrix.python-version}}
74-
DJ_VER: ${{ matrix.django-version}}
42+
PY_VER: ${{ matrix.python}}
43+
DJ_VER: ${{ matrix.django}}
7544
DBENGINE: ${{ matrix.db-engine}}
7645
MYSQL_USER: 'root'
7746
MYSQL_PASSWORD: 'root'
@@ -112,13 +81,17 @@ jobs:
11281
with:
11382
python-version: ${{ matrix.python-version }}
11483

115-
- name: Install dependencies
116-
run: python -m pip install --upgrade pip tox
84+
- name: Install Python
85+
if: matrix.python != '3.13'
86+
run: uv python install --python-preference only-managed ${{ matrix.python }}
87+
88+
- name: Setup test suite
89+
run: tox run -vv --notest --skip-missing-interpreters false
11790

11891
- name: Test with
119-
run: tox -e d${DJ_VER//.}-py${PY_VER//.}-${DBENGINE}
92+
run: tox run -e d${DJ_VER//.}-py${PY_VER//.}-${DBENGINE}
12093

121-
- name: UUpload test results to Codecov
94+
- name: Upload test results to Codecov
12295
uses: codecov/test-results-action@v1
12396
with:
12497
env_vars: OS

mypy.ini

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Regular configuration file (can be used as base in other projects, runs in CI)
2+
3+
[mypy]
4+
# Modified in `tests.yml`
5+
incremental = true
6+
mypy_path = tests/demoapp
7+
;
8+
;# Strictness:
9+
;allow_redefinition = true
10+
;check_untyped_defs = true
11+
;# TODO: add type args to all generics
12+
;disallow_any_generics = false
13+
;# TODO: fix `Any` subclassing in `typeshed/builtins.pyi`
14+
;disallow_subclassing_any = false
15+
;ignore_missing_imports = false
16+
strict = true
17+
;local_partial_types = true
18+
;warn_unreachable = true
19+
;
20+
;# TODO: update our output assertions to match a new syntax
21+
;force_uppercase_builtins = true
22+
;force_union_syntax = true
23+
;
24+
;disable_error_code = empty-body
25+
enable_error_code =
26+
deprecated,
27+
ignore-without-code
28+
29+
30+
show_traceback = true
31+
;
32+
plugins =
33+
mypy_django_plugin.main,
34+
mypy.plugins.proper_plugin
35+
;
36+
;# Ignore incomplete hints in 3rd party stubs:
37+
;[mypy-yaml.*]
38+
;disallow_untyped_defs = false
39+
;disallow_incomplete_defs = false
40+
;
41+
;[mypy-cryptography.*]
42+
;ignore_errors = true
43+
;
44+
;# Our settings:
45+
[mypy.plugins.django-stubs]
46+
django_settings_module = demo.settings

pyproject.toml

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,89 @@ dev = [
4848
"tox",
4949
]
5050

51+
dj = [
52+
"django",
53+
]
54+
5155
[tool.hatch.build.targets.wheel]
5256
packages = [ "src/concurrency" ]
5357

58+
[tool.ruff]
59+
target-version = "py39"
60+
line-length = 120
61+
exclude = [
62+
"docs",
63+
"manage.py",
64+
"tests",
65+
]
66+
format.preview = true
67+
format.docstring-code-line-length = 120
68+
format.docstring-code-format = true
69+
lint.select = [
70+
"ALL",
71+
]
72+
lint.ignore = [
73+
"ANN401", # Dynamically typed expressions
74+
"COM812",
75+
"CPY", # Missing copyright notice
76+
"D", # docstring
77+
"DOC", # docstring
78+
"E731", # Do not assign a `lambda` expression,
79+
"EM101", # Exception must not use a string literal, assign to variable first
80+
"EM102", # Exception must not use a f-string literal, assign to variable first
81+
"FBT001", # Boolean-typed positional argument in function definition
82+
"FBT002", # Boolean default positional argument in function definition
83+
"N806", # Variable `...` in function should be lowercase
84+
"S308", # Use of `mark_safe` may expose cross-site scripting vulnerabilities
85+
"SLF001", # Private member accessed: `...`
86+
"TRY003", # Avoid specifying long messages outside the exception class
87+
"TRY301", # Abstract `raise` to an inner function
88+
"TRY401", # Redundant exception object included in `logging.exception` call
89+
"UP037", #
90+
]
91+
lint.per-file-ignores."docs/conf.py" = [
92+
"A001", #
93+
"D100", #
94+
"ERA001", #
95+
"INP001", #
96+
]
97+
lint.per-file-ignores."tests/**/*.py" = [
98+
"A",
99+
"ANN",
100+
"ARG",
101+
"B",
102+
"BLE",
103+
"D",
104+
"DJ",
105+
"DTZ",
106+
"ERA",
107+
"F",
108+
"FBT",
109+
"FURB",
110+
"INP",
111+
"N",
112+
"PGH",
113+
"PLC",
114+
"PLR",
115+
"PLW",
116+
"PT",
117+
"PTH",
118+
"PYI",
119+
"RUF",
120+
"S",
121+
"SIM",
122+
"TC",
123+
"UP",
124+
]
125+
lint.isort = { known-first-party = [ "admin_extra_buttons" ] }
126+
lint.pylint.max-args = 7
127+
lint.pylint.max-branches = 14
128+
lint.pylint.max-nested-blocks = 8
129+
lint.preview = true
130+
131+
[tool.pyproject-fmt]
132+
max_supported_python = "3.13"
133+
54134
[tool.pytest.ini_options]
55135
django_find_project = false
56136
pythonpath = [ "./tests/demoapp/", "./src" ]
@@ -73,5 +153,34 @@ markers = [
73153
"skip: skip test",
74154
]
75155

156+
[tool.coverage]
157+
run.source = [
158+
"adminactions",
159+
]
160+
run.dynamic_context = "test_function"
161+
run.branch = true
162+
run.parallel = true
163+
run.omit = [
164+
"**/create_extra_permissions.py",
165+
]
166+
run.plugins = [
167+
"covdefaults",
168+
]
169+
report.fail_under = 80
170+
report.show_missing = true
171+
report.exclude_lines = [
172+
"pragma: no cover",
173+
]
174+
html.show_contexts = true
175+
html.skip_covered = false
176+
paths.source = [
177+
"src",
178+
".tox*/*/lib/python*/site-packages",
179+
".tox*/pypy*/site-packages",
180+
".tox*\\*\\Lib\\site-packages",
181+
"*/src",
182+
"*\\src",
183+
]
184+
76185
[tool.uv]
77186
package = true

0 commit comments

Comments
 (0)