Skip to content

Commit 4d7644c

Browse files
authored
chore: remove MERGIFY_TESTS_TARGET_BRANCH and add GITHUB_REF_NAME environment variable (#734)
It shouldn't be necessary to configure this `MERGIFY_TESTS_TARGET_BRANCH` variable manually.
1 parent 0505d94 commit 4d7644c

File tree

2 files changed

+8
-19
lines changed

2 files changed

+8
-19
lines changed

mergify_cli/ci/cli.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def _process_tests_target_branch(
6565
"-ttb",
6666
help="The branch used to check if failing tests can be ignored with Mergify's Quarantine.",
6767
required=True,
68-
envvar=["MERGIFY_TESTS_TARGET_BRANCH", "GITHUB_BASE_REF", "GITHUB_REF"],
68+
envvar=["GITHUB_BASE_REF", "GITHUB_REF_NAME", "GITHUB_REF"],
6969
callback=_process_tests_target_branch,
7070
)
7171
@click.argument(
@@ -136,7 +136,7 @@ async def junit_upload( # noqa: PLR0913
136136
"-ttb",
137137
help="The branch used to check if failing tests can be ignored with Mergify's Quarantine.",
138138
required=True,
139-
envvar=["MERGIFY_TESTS_TARGET_BRANCH", "GITHUB_BASE_REF", "GITHUB_REF"],
139+
envvar=["GITHUB_BASE_REF", "GITHUB_REF_NAME", "GITHUB_REF"],
140140
callback=_process_tests_target_branch,
141141
)
142142
@click.argument(

mergify_cli/tests/ci/test_cli.py

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"CIRCLE_REPOSITORY_URL": "https://github.com/user/repo",
3939
"CIRCLE_SHA1": "3af96aa24f1d32fcfbb7067793cacc6dc0c6b199",
4040
"CIRCLE_JOB": "JOB",
41-
"MERGIFY_TESTS_TARGET_BRANCH": "main",
41+
"GITHUB_REF_NAME": "main",
4242
},
4343
id="CircleCI",
4444
),
@@ -123,21 +123,6 @@ def test_cli(env: dict[str, str], monkeypatch: pytest.MonkeyPatch) -> None:
123123
"main",
124124
id="GITHUB_BASE_REF takes precedence over GITHUB_REF",
125125
),
126-
pytest.param(
127-
{
128-
"GITHUB_EVENT_NAME": "push",
129-
"GITHUB_ACTIONS": "true",
130-
"MERGIFY_API_URL": "https://api.mergify.com",
131-
"MERGIFY_TOKEN": "abc",
132-
"GITHUB_REPOSITORY": "user/repo",
133-
"GITHUB_SHA": "3af96aa24f1d32fcfbb7067793cacc6dc0c6b199",
134-
"GITHUB_WORKFLOW": "JOB",
135-
"MERGIFY_TESTS_TARGET_BRANCH": "develop",
136-
"GITHUB_REF": "refs/heads/feature-branch",
137-
},
138-
"develop",
139-
id="MERGIFY_TESTS_TARGET_BRANCH takes precedence over GITHUB_REF",
140-
),
141126
pytest.param(
142127
{
143128
"GITHUB_EVENT_NAME": "push",
@@ -160,7 +145,11 @@ def test_tests_target_branch_environment_variable_processing(
160145
monkeypatch: pytest.MonkeyPatch,
161146
) -> None:
162147
"""Test that tests_target_branch environment variable processing works correctly."""
163-
for key in ["GITHUB_REF", "GITHUB_BASE_REF"]: # Override value from CI runner
148+
for key in [
149+
"GITHUB_REF",
150+
"GITHUB_REF_NAME",
151+
"GITHUB_BASE_REF",
152+
]: # Override value from CI runner
164153
monkeypatch.delenv(key, raising=False)
165154

166155
for key, value in env.items():

0 commit comments

Comments
 (0)