Skip to content
This repository was archived by the owner on Jun 2, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions .github/change_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@

VERSION_PY = Path(__file__).parent.parent / 'defectdojo_api_generated' / '__init__.py'
VERSION_RE = re.compile(r"__version__ = '(.*?)'")
CLI_VERSION_PY = (
Path(__file__).parent.parent / 'packages' / 'cli' / 'src' / 'defectdojo_api_generated_cli' / '__init__.py'
)
CLI_DEPENDENCY_PYPROJECT = Path(__file__).parent.parent / 'packages' / 'cli' / 'pyproject.toml'
CLI_VERSION_RE = re.compile(r'(^version = ")([^"]+)(")', re.MULTILINE)
CLI_DEPENDENCY_RE = re.compile(r'("defectdojo-api-generated==)([^"]+)(")')


Expand All @@ -27,9 +25,8 @@ def main():

if args.set:
VERSION_PY.write_text(VERSION_RE.sub(f"__version__ = '{args.set}'", data))
cli_version_data = CLI_VERSION_PY.read_text()
CLI_VERSION_PY.write_text(VERSION_RE.sub(f"__version__ = '{args.set}'", cli_version_data))
cli_pyproject_data = CLI_DEPENDENCY_PYPROJECT.read_text()
cli_pyproject_data = CLI_VERSION_RE.sub(rf'\g<1>{args.set}\g<3>', cli_pyproject_data)
CLI_DEPENDENCY_PYPROJECT.write_text(CLI_DEPENDENCY_RE.sub(rf'\g<1>{args.set}\g<3>', cli_pyproject_data))
print(f'New version: {args.set}')

Expand Down
16 changes: 16 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,19 @@ jobs:
pip install${INDEX} defectdojo-api-generated-cli==${{ inputs.version }}
\`\`\`
EOF
if [ "${{ inputs.repository }}" != "pypi" ]; then
cat <<EOF >> ${GITHUB_STEP_SUMMARY}
Run with \`uvx\`
\`\`\`
uvx --with 'defectdojo-api-generated @ https://test-files.pythonhosted.org/packages/source/d/defectdojo-api-generated/defectdojo_api_generated-${{ inputs.version }}.tar.gz' \\
'defectdojo-api-generated-cli @ https://test-files.pythonhosted.org/packages/source/d/defectdojo-api-generated-cli/defectdojo_api_generated_cli-${{ inputs.version }}.tar.gz'
\`\`\`
EOF
else
cat <<EOF >> ${GITHUB_STEP_SUMMARY}
Run with \`uvx\`
\`\`\`
uvx defectdojo-api-generated-cli==${{ inputs.version }}
\`\`\`
EOF
fi
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ test-e2e:
uv run pytest tests/integration

testpub:
rm -fr dist
rm -rf dist packages/cli/dist
uv run pyproject-build
uv run twine upload --repository testpypi dist/*
uv run pyproject-build packages/cli
uv run twine upload --repository testpypi dist/* packages/cli/dist/*

schema:
uv run ./support/openapi/fetch_openapi.py --output ./support/openapi/openapi-new.json
Expand Down
8 changes: 2 additions & 6 deletions packages/cli/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,11 @@ dependencies = [
]

[project.scripts]
dojo = "defectdojo_api_generated_cli.__main__:main"
defectdojo-api-generated = "defectdojo_api_generated_cli.__main__:main"
dojo = "defectdojo_api_generated.cli.__main__:main"
defectdojo-api-generated-cli = "defectdojo_api_generated.cli.__main__:main"

[project.urls]
Homepage = "https://github.com/fopina/defectdojo-api-generated"

[tool.uv.sources]
defectdojo-api-generated = { path = "../.." }

[tool.setuptools.packages.find]
where = ["src"]
include = ["defectdojo_api_generated_cli"]
3 changes: 0 additions & 3 deletions packages/cli/src/defectdojo_api_generated_cli/__init__.py

This file was deleted.

6 changes: 0 additions & 6 deletions packages/cli/src/defectdojo_api_generated_cli/__main__.py

This file was deleted.

3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ Homepage = "https://github.com/fopina/defectdojo-api-generated"
[tool.setuptools.packages.find]
include = ["defectdojo_api_generated", "defectdojo_api_generated.*"]

[tool.setuptools.package-data]
"defectdojo_api_generated.cli" = ["config.example.toml"]

[tool.setuptools.dynamic]
version = {attr = "defectdojo_api_generated.__version__"}

Expand Down
17 changes: 7 additions & 10 deletions tests/unit/test_packaging.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import pathlib
import re
import unittest

try:
Expand All @@ -18,25 +17,23 @@ def test_library_package_has_no_console_scripts(self):

self.assertNotIn('scripts', pyproject['project'])

def test_cli_wrapper_package_owns_console_scripts(self):
def test_cli_distribution_points_console_scripts_to_library_entrypoint(self):
pyproject = tomllib.loads((ROOT / 'packages' / 'cli' / 'pyproject.toml').read_text())

self.assertEqual(
pyproject['project']['scripts'],
{
'dojo': 'defectdojo_api_generated_cli.__main__:main',
'defectdojo-api-generated': 'defectdojo_api_generated_cli.__main__:main',
'dojo': 'defectdojo_api_generated.cli.__main__:main',
'defectdojo-api-generated-cli': 'defectdojo_api_generated.cli.__main__:main',
},
)

def test_cli_wrapper_version_matches_library_version(self):
wrapper_init = (ROOT / 'packages' / 'cli' / 'src' / 'defectdojo_api_generated_cli' / '__init__.py').read_text()
match = re.search(r"__version__ = '([^']+)'", wrapper_init)
def test_cli_distribution_version_matches_library_version(self):
pyproject = tomllib.loads((ROOT / 'packages' / 'cli' / 'pyproject.toml').read_text())

self.assertIsNotNone(match)
self.assertEqual(match.group(1), defectdojo_api_generated.__version__)
self.assertEqual(pyproject['project']['version'], defectdojo_api_generated.__version__)

def test_cli_wrapper_dependency_matches_library_version(self):
def test_cli_distribution_dependency_matches_library_version(self):
pyproject = tomllib.loads((ROOT / 'packages' / 'cli' / 'pyproject.toml').read_text())

self.assertIn(
Expand Down
Loading