Skip to content
This repository was archived by the owner on Jun 2, 2026. It is now read-only.

Commit 84eb0eb

Browse files
authored
extra: dojo CLI (#48)
1 parent 7cbd5bb commit 84eb0eb

20 files changed

Lines changed: 1605 additions & 39 deletions

File tree

.github/workflows/test.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
runs-on: ubuntu-latest
3838
strategy:
3939
matrix:
40-
python-version: ['3.9', '3.12']
40+
python-version: ['3.9', '3.10', '3.12']
4141
steps:
4242
- name: Checkout
4343
uses: actions/checkout@v4
@@ -50,7 +50,7 @@ jobs:
5050
- name: Install dependencies
5151
run: |
5252
pip install uv
53-
uv sync --dev
53+
uv sync --dev --extra cli
5454
5555
- name: Run unit tests
5656
run: |
@@ -71,12 +71,12 @@ jobs:
7171
- name: Set up Python
7272
uses: actions/setup-python@v5
7373
with:
74-
python-version: "3.10"
74+
python-version: "3.12"
7575

7676
- name: Install dependencies
7777
run: |
7878
pip install uv
79-
uv sync --dev
79+
uv sync --dev --extra cli
8080
8181
- name: Run e2e tests
8282
run: |

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ celerybeat.pid
103103

104104
# Environments
105105
.env
106-
.venv
106+
.venv*
107107
env/
108108
/venv/
109109
ENV/

AGENTS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ The codebase is mostly generated. The important mental model is:
6868
- `tests/data/`
6969
Fixtures for integration scenarios, such as import/reimport payloads.
7070

71+
ALWAYS use unittest.TestCase to write new tests unless you really cannot.
72+
7173
### Local integration environment
7274

7375
- `support/integration/docker-compose.yml`

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
This project uses `uv`, so set up the virtualenv by running
44

55
```
6-
uv sync --dev
6+
uv sync --dev --extra cli
77
```
88

99
Use `make test` to make sure all tests pass before pushing.

Makefile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,21 @@ lint-check:
66
uv run ruff format --diff
77
uv run ruff check
88

9+
.venv39: export VIRTUAL_ENV=.venv39
10+
.venv39:
11+
uv sync --dev --extra cli --python 3.9 --active
12+
13+
test39: .venv39
14+
test39: export VIRTUAL_ENV=.venv39
15+
test39:
16+
uv run --active pytest --cov
17+
18+
test39-e2e: .venv39
19+
test39-e2e: export VIRTUAL_ENV=.venv39
20+
test39-e2e: export DD_INTEGRATION_TESTS=1
21+
test39-e2e:
22+
uv run --active pytest tests/integration/test_e2e.py
23+
924
test:
1025
if [ -n "$(GITHUB_RUN_ID)" ]; then \
1126
uv run pytest --cov --cov-report=xml --junitxml=junit.xml -o junit_family=legacy; \
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
"""Command-line entrypoint for defectdojo_api_generated."""
2+
3+
import importlib
4+
import pkgutil
5+
import sys
6+
from pathlib import Path
7+
8+
9+
def discover_commands():
10+
# str() required because of py3.10
11+
for _, module_name, _ in pkgutil.iter_modules([str(Path(__file__).parent / 'commands')]):
12+
importlib.import_module(f'{__package__}.commands.{module_name}')
13+
14+
15+
def load_cli():
16+
try:
17+
from .commands.cli import CLI
18+
except ModuleNotFoundError as exc:
19+
print(
20+
'The DefectDojo CLI requires extra dependencies. '
21+
'Install them using "defectdojo-api-generated[cli]" as package',
22+
file=sys.stderr,
23+
)
24+
raise SystemExit(1) from exc
25+
26+
return CLI
27+
28+
29+
def main():
30+
CLI = load_cli()
31+
discover_commands()
32+
CLI.click()
33+
34+
35+
if __name__ == '__main__':
36+
main()

0 commit comments

Comments
 (0)