From e0bf85851e4824cd02c40217401ba340602c0a88 Mon Sep 17 00:00:00 2001 From: codejedi365 Date: Sat, 22 Feb 2025 11:11:43 -0700 Subject: [PATCH 1/2] test(cli): add entrypoint script validation --- tests/e2e/test_main.py | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/tests/e2e/test_main.py b/tests/e2e/test_main.py index 42c04b118..fc65c7f21 100644 --- a/tests/e2e/test_main.py +++ b/tests/e2e/test_main.py @@ -1,6 +1,7 @@ from __future__ import annotations import json +import subprocess from pathlib import Path from textwrap import dedent from typing import TYPE_CHECKING @@ -12,7 +13,7 @@ from semantic_release import __version__ from semantic_release.cli.commands.main import main -from tests.const import MAIN_PROG_NAME, VERSION_SUBCMD +from tests.const import MAIN_PROG_NAME, SUCCESS_EXIT_CODE, VERSION_SUBCMD from tests.fixtures.repos import repo_w_no_tags_conventional_commits from tests.util import assert_exit_code, assert_successful_exit_code @@ -25,6 +26,30 @@ from tests.fixtures.git_repo import BuiltRepoResult +@pytest.mark.parametrize( + "project_script_name", + [ + "python-semantic-release", + "semantic-release", + "psr", + ], +) +def test_entrypoint_scripts(project_script_name: str): + # Setup + command = str.join(" ", [project_script_name, "--version"]) + expected_output = f"semantic-release, version {__version__}\n" + + # Act + proc = subprocess.run( # noqa: S602, PLW1510 + command, shell=True, text=True, capture_output=True + ) + + # Evaluate + assert SUCCESS_EXIT_CODE == proc.returncode # noqa: SIM300 + assert expected_output == proc.stdout + assert not proc.stderr + + def test_main_prints_version_and_exits(cli_runner: CliRunner): cli_cmd = [MAIN_PROG_NAME, "--version"] From f589b404b96ffdcfee7692c2cfd291375b8cb5cb Mon Sep 17 00:00:00 2001 From: codejedi365 Date: Sat, 22 Feb 2025 10:33:41 -0700 Subject: [PATCH 2/2] feat: add package name variant, `python-semantic-release`, project script Adds support for default implementation of `uvx` which matches script name with package name. Resolves: #1195 --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 35f8a8d04..8c12ebe05 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,6 +39,7 @@ dependencies = [ ] [project.scripts] +python-semantic-release = "semantic_release.__main__:main" semantic-release = "semantic_release.__main__:main" psr = "semantic_release.__main__:main"