Skip to content

Commit a216e16

Browse files
committed
Work toward tooling modernization to reflect other omenapps packages
- Remove obsolete configuration (poetry, etc) - Update/add to reflect changes in other omenapps packages (uv, bandit, nox, etc)
1 parent 2fba009 commit a216e16

16 files changed

Lines changed: 1894 additions & 249 deletions

.github/workflows/django.yml

Lines changed: 52 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,68 @@
1-
name: Django CI
1+
name: CI
22

33
on:
44
push:
5-
branches: [ main ]
5+
branches: [main]
66
pull_request:
7-
branches: [ main ]
7+
branches: [main]
8+
9+
env:
10+
PG_USER: postgres
11+
PG_PASSWORD: postgres
12+
PG_DATABASE: postgres
13+
PG_HOST: localhost
14+
PG_PORT: 5432
815

916
jobs:
10-
black:
17+
lint:
1118
runs-on: ubuntu-latest
1219
steps:
13-
- uses: actions/setup-python@v1
14-
- uses: actions/checkout@v2
15-
- run: python -m pip install black
16-
- run: black -l 120 --check --diff .
17-
18-
build:
20+
- uses: actions/checkout@v4
21+
- uses: actions/setup-python@v5
22+
with:
23+
python-version: "3.13"
24+
- uses: astral-sh/setup-uv@v4
25+
- run: uv sync --extra dev
26+
- run: uv run nox -s pre-commit
1927

28+
pip-audit:
2029
runs-on: ubuntu-latest
21-
30+
steps:
31+
- uses: actions/checkout@v4
32+
- uses: actions/setup-python@v5
33+
with:
34+
python-version: "3.13"
35+
- uses: astral-sh/setup-uv@v4
36+
- run: uv sync --extra dev
37+
- run: uv run nox -s pip-audit
38+
39+
tests:
40+
runs-on: ubuntu-latest
41+
strategy:
42+
fail-fast: false
43+
matrix:
44+
python-version: ["3.11", "3.12", "3.13"]
45+
django-version: ["4.2", "5.1", "5.2", "6.0"]
46+
exclude:
47+
- python-version: "3.11"
48+
django-version: "6.0"
49+
2250
services:
2351
postgres:
24-
image: postgres:12
52+
image: postgres:16
2553
env:
26-
POSTGRES_USER: daguser
27-
POSTGRES_PASSWORD: daguser
28-
POSTGRES_DB: dagdb
29-
ports: ['5432:5432']
54+
POSTGRES_USER: postgres
55+
POSTGRES_PASSWORD: postgres
56+
POSTGRES_DB: postgres
57+
ports:
58+
- 5432:5432
3059
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
31-
32-
strategy:
33-
max-parallel: 4
34-
matrix:
35-
python-version: [3.7, 3.8, 3.9]
3660

3761
steps:
38-
- uses: actions/checkout@v2
39-
- name: Set up Python ${{ matrix.python-version }}
40-
uses: actions/setup-python@v2
41-
with:
42-
python-version: ${{ matrix.python-version }}
43-
- name: Install Dependencies
44-
run: |
45-
python -m pip install --upgrade pip
46-
pip install -r requirements-dev.txt
47-
- name: Run Migrations
48-
run: |
49-
python manage.py migrate
50-
- name: Run Tests
51-
run: |
52-
python manage.py test
62+
- uses: actions/checkout@v4
63+
- uses: actions/setup-python@v5
64+
with:
65+
python-version: ${{ matrix.python-version }}
66+
- uses: astral-sh/setup-uv@v4
67+
- run: uv sync --extra dev
68+
- run: uv run nox -s "tests(django='${{ matrix.django-version }}', python='${{ matrix.python-version }}')"

.gitignore

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
__pycache__/
33
*.py[cod]
44
*$py.class
5+
.ipython/*
56

67
# C extensions
78
*.so
@@ -26,8 +27,6 @@ wheels/
2627
MANIFEST
2728

2829
# PyInstaller
29-
# Usually these files are written by a python script from a template
30-
# before PyInstaller builds the exe, so as to inject date/other infos into it.
3130
*.manifest
3231
*.spec
3332

@@ -38,6 +37,7 @@ pip-delete-this-directory.txt
3837
# Unit test / coverage reports
3938
htmlcov/
4039
.tox/
40+
.nox/
4141
.coverage
4242
.coverage.*
4343
.cache
@@ -56,13 +56,6 @@ coverage.xml
5656
local_settings.py
5757
db.sqlite3
5858

59-
# Flask stuff:
60-
instance/
61-
.webassets-cache
62-
63-
# Scrapy stuff:
64-
.scrapy
65-
6659
# Sphinx documentation
6760
docs/_build/
6861

@@ -103,3 +96,7 @@ venv.bak/
10396

10497
# mypy
10598
.mypy_cache/
99+
100+
# IDE
101+
.idea/
102+
.vscode/

.pre-commit-config.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
repos:
2+
- repo: local
3+
hooks:
4+
- id: ruff
5+
name: ruff
6+
entry: ruff check --fix
7+
language: system
8+
types: [python]
9+
exclude: ^tests/
10+
11+
- id: bandit
12+
name: bandit
13+
entry: bandit -c bandit.yml -r src/
14+
language: system
15+
types: [python]
16+
pass_filenames: false
17+
18+
- repo: https://github.com/pre-commit/pre-commit-hooks
19+
rev: v5.0.0
20+
hooks:
21+
- id: check-added-large-files
22+
- id: check-toml
23+
- id: check-yaml
24+
- id: end-of-file-fixer
25+
- id: trailing-whitespace
26+
27+
- repo: https://github.com/asottile/pyupgrade
28+
rev: v3.19.1
29+
hooks:
30+
- id: pyupgrade
31+
args: [--py311-plus]

MANIFEST.in

Lines changed: 0 additions & 4 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Expressions (CTE) to achieve this and is therefore not compatible with other dat
88

99
NOTE: Not all methods which would benefit from CTEs use them yet. **This project is a work in progress. Again, this project is a work in progress.** While functional, it is not yet fully optimized.
1010

11-
The primary purpose of this package is to *build* and *manipulate* DAGs. If you are looking for graph *analysis* or *visualization*, this is not the right package.
11+
The primary purpose of this package is to *build* and *manipulate* DAGs within a Django project. If you are looking for graph *analysis* or *visualization*, this may not be the right package.
1212

1313
Currently, django-postgresql-dag provides numerous methods for retrieving nodes, and a few for retrieving edges within the graph. In-progress are filters within the CTEs in order to limit the area of the graph to be searched, ability to easily export to NetworkX, and other improvements and utilities.
1414

bandit.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
skips:
2+
- B101 # assert_used - common in tests and Django
3+
- B105 # hardcoded_password_string - test credentials
4+
- B106 # hardcoded_password_funcarg
5+
- B311 # random - not used for crypto

docker-compose.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
volumes:
2+
local_postgres_data: {}
3+
4+
services:
5+
postgres:
6+
image: postgres:16
7+
container_name: postgres
8+
volumes:
9+
- local_postgres_data:/var/lib/postgresql/data:Z
10+
environment:
11+
- POSTGRES_PASSWORD=postgres
12+
- POSTGRES_USER=postgres
13+
- POSTGRES_DB=postgres
14+
ports:
15+
- "5433:5432"
16+
healthcheck:
17+
test: ["CMD-SHELL", "pg_isready -U postgres"]
18+
interval: 10s
19+
timeout: 5s
20+
retries: 5

manage.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
#!/usr/bin/env python
1+
"""Django's command-line utility for administrative tasks."""
22
import os
33
import sys
44

5-
if __name__ == "__main__":
6-
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")
7-
# os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'django_postgresql_dag.settings')
5+
6+
def main():
7+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "tests.settings")
88
try:
99
from django.core.management import execute_from_command_line
1010
except ImportError as exc:
@@ -14,3 +14,7 @@
1414
"forget to activate a virtual environment?"
1515
) from exc
1616
execute_from_command_line(sys.argv)
17+
18+
19+
if __name__ == "__main__":
20+
main()

noxfile.py

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
"""Nox sessions for django-postgresql-dag."""
2+
3+
import sys
4+
5+
import nox
6+
7+
DJANGO_STABLE_VERSION = "5.2"
8+
DJANGO_VERSIONS = ["4.2", "5.1", "5.2", "6.0"]
9+
PYTHON_STABLE_VERSION = "3.13"
10+
PYTHON_VERSIONS = ["3.11", "3.12", "3.13"]
11+
PACKAGE = "django_postgresql_dag"
12+
13+
nox.options.default_venv_backend = "uv"
14+
nox.options.sessions = ["pre-commit", "pip-audit", "tests"]
15+
16+
17+
@nox.session(name="pre-commit", python=PYTHON_STABLE_VERSION)
18+
def precommit(session: nox.Session) -> None:
19+
"""Run pre-commit hooks on all files."""
20+
session.install("pre-commit")
21+
session.run("pre-commit", "run", "--all-files")
22+
23+
24+
@nox.session(python=PYTHON_STABLE_VERSION)
25+
def pip_audit(session: nox.Session) -> None:
26+
"""Scan dependencies for known vulnerabilities."""
27+
session.install(".[dev]")
28+
session.install("pip-audit")
29+
session.run("pip-audit")
30+
31+
32+
@nox.session(
33+
python=PYTHON_VERSIONS,
34+
tags=["tests"],
35+
)
36+
@nox.parametrize("django", DJANGO_VERSIONS)
37+
def tests(session: nox.Session, django: str) -> None:
38+
"""Run the test suite across Python and Django versions."""
39+
# Django 6.0 requires Python 3.12+
40+
if django == "6.0" and session.python == "3.11":
41+
session.skip("Django 6.0 requires Python 3.12+")
42+
43+
session.install(".[dev]")
44+
session.install(f"django~={django}.0")
45+
session.run(
46+
"coverage",
47+
"run",
48+
"-m",
49+
"pytest",
50+
"-vv",
51+
*session.posargs,
52+
)
53+
54+
if sys.stdin.isatty():
55+
session.notify("coverage")
56+
57+
58+
@nox.session(python=PYTHON_STABLE_VERSION)
59+
def coverage(session: nox.Session) -> None:
60+
"""Combine and report coverage."""
61+
session.install("coverage[toml]")
62+
session.run("coverage", "combine", success_codes=[0, 1])
63+
session.run("coverage", "report")

0 commit comments

Comments
 (0)