From 3d2cd3d4ba8a169afb5f1c777ddaad407b5a0662 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Mon, 16 Dec 2024 17:53:48 +0100 Subject: [PATCH] refactor(utils): leverage strtobool Change-Id: Ibff24d023356bdc10a1a8347295d534c745c4d2d --- pytest_mergify/utils.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/pytest_mergify/utils.py b/pytest_mergify/utils.py index 775afc2..39d0e9a 100644 --- a/pytest_mergify/utils.py +++ b/pytest_mergify/utils.py @@ -3,12 +3,17 @@ CIProviderT = typing.Literal["github_actions", "circleci"] +SUPPORTED_CIs = { + "GITHUB_ACTIONS": "github_actions", + "CIRCLECI": "circleci", +} + def get_ci_provider() -> CIProviderT | None: - if os.getenv("GITHUB_ACTIONS") == "true": - return "github_actions" - if os.getenv("CIRCLECI") == "true": - return "circleci" + for envvar, name in SUPPORTED_CIs.items(): + if envvar in os.environ and strtobool(os.environ[envvar]): + return name + return None