Skip to content

Commit 0710915

Browse files
committed
Add test for [skip ci] in commit but not PR title
1 parent 1c3b526 commit 0710915

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

tests/python/unittest/test_ci.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def run(self, *args):
3737
if proc.returncode != 0:
3838
raise RuntimeError(f"git command failed: '{args}'")
3939

40-
def test(commands, should_skip, why):
40+
def test(commands, should_skip, pr_title, why):
4141
with tempfile.TemporaryDirectory() as dir:
4242
git = TempGit(dir)
4343
# Jenkins git is too old and doesn't have 'git init --initial-branch'
@@ -51,14 +51,15 @@ def test(commands, should_skip, why):
5151
git.run(*command)
5252
pr_number = "1234"
5353
proc = subprocess.run(
54-
[str(skip_ci_script), "--pr", pr_number, "--pr-title", "[skip ci] test"], cwd=dir
54+
[str(skip_ci_script), "--pr", pr_number, "--pr-title", pr_title], cwd=dir
5555
)
5656
expected = 0 if should_skip else 1
5757
assert proc.returncode == expected, why
5858

5959
test(
6060
commands=[],
6161
should_skip=False,
62+
pr_title="[skip ci] test",
6263
why="ci should not be skipped",
6364
)
6465

@@ -67,6 +68,7 @@ def test(commands, should_skip, why):
6768
["commit", "--allow-empty", "--message", "[skip ci] commit 1"],
6869
],
6970
should_skip=False,
71+
pr_title="[skip ci] test",
7072
why="ci should not be skipped on main",
7173
)
7274

@@ -76,16 +78,28 @@ def test(commands, should_skip, why):
7678
["commit", "--allow-empty", "--message", "[skip ci] commit 1"],
7779
],
7880
should_skip=True,
81+
pr_title="[skip ci] test",
7982
why="ci should be skipped on a branch with [skip ci] in the last commit",
8083
)
8184

85+
test(
86+
commands=[
87+
["checkout", "-b", "some_new_branch"],
88+
["commit", "--allow-empty", "--message", "[skip ci] commit 1"],
89+
],
90+
should_skip=False,
91+
pr_title="[no skip ci] test",
92+
why="ci should not be skipped on a branch with [skip ci] in the last commit but not the PR title",
93+
)
94+
8295
test(
8396
commands=[
8497
["checkout", "-b", "some_new_branch"],
8598
["commit", "--allow-empty", "--message", "[skip ci] commit 1"],
8699
["commit", "--allow-empty", "--message", "commit 2"],
87100
],
88101
should_skip=False,
102+
pr_title="[skip ci] test",
89103
why="ci should not be skipped on a branch without [skip ci] in the last commit",
90104
)
91105

@@ -96,6 +110,7 @@ def test(commands, should_skip, why):
96110
["commit", "--allow-empty", "--message", "commit 2"],
97111
],
98112
should_skip=False,
113+
pr_title="[skip ci] test",
99114
why="ci should not be skipped on a branch without [skip ci] in the last commit",
100115
)
101116

@@ -108,6 +123,7 @@ def test(commands, should_skip, why):
108123
["commit", "--allow-empty", "--message", "commit 4"],
109124
],
110125
should_skip=False,
126+
pr_title="[skip ci] test",
111127
why="ci should not be skipped on a branch without [skip ci] in the last commit",
112128
)
113129

0 commit comments

Comments
 (0)