summaryrefslogtreecommitdiff
path: root/test/runner
diff options
context:
space:
mode:
authorMatt Clay <matt@mystile.com>2018-11-14 11:30:48 -0800
committerMatt Clay <matt@mystile.com>2018-11-14 12:27:40 -0800
commitaa7fe919d319fe45e068e94f6e2de7162d8921fe (patch)
tree76f16472d18617a0fa846d8cb1288a50cbb45f41 /test/runner
parentd6bf45cd9d62e59923df13ffb71900f7dde92497 (diff)
downloadansible-aa7fe919d319fe45e068e94f6e2de7162d8921fe.tar.gz
Fix ansible-test merge change detection.
Diffstat (limited to 'test/runner')
-rw-r--r--test/runner/lib/changes.py15
-rw-r--r--test/runner/lib/git.py18
2 files changed, 22 insertions, 11 deletions
diff --git a/test/runner/lib/changes.py b/test/runner/lib/changes.py
index e4e223b3e7..ca31219b9c 100644
--- a/test/runner/lib/changes.py
+++ b/test/runner/lib/changes.py
@@ -106,17 +106,10 @@ class ShippableChanges(object):
display.warning('Unable to find project. Cannot determine changes. All tests will be executed.')
return None
- merge_runs = sorted(merge_runs, key=lambda r: r['createdAt'])
- known_commits = set()
- last_successful_commit = None
-
- for merge_run in merge_runs:
- commit_sha = merge_run['commitSha']
- if commit_sha not in known_commits:
- known_commits.add(commit_sha)
- if merge_run['statusCode'] == 30:
- if git.is_valid_ref(commit_sha):
- last_successful_commit = commit_sha
+ successful_commits = set(run['commitSha'] for run in merge_runs if run['statusCode'] == 30)
+ commit_history = git.get_rev_list(max_count=100)
+ ordered_successful_commits = [commit for commit in commit_history if commit in successful_commits]
+ last_successful_commit = ordered_successful_commits[0] if ordered_successful_commits else None
if last_successful_commit is None:
display.warning('No successful commit found. All tests will be executed.')
diff --git a/test/runner/lib/git.py b/test/runner/lib/git.py
index 387a87f4d2..a06e4c8162 100644
--- a/test/runner/lib/git.py
+++ b/test/runner/lib/git.py
@@ -59,6 +59,24 @@ class Git(object):
cmd = ['symbolic-ref', '--short', 'HEAD']
return self.run_git(cmd).strip()
+ def get_rev_list(self, commits=None, max_count=None):
+ """
+ :type commits: list[str] | None
+ :type max_count: int | None
+ :rtype: list[str]
+ """
+ cmd = ['rev-list']
+
+ if commits:
+ cmd += commits
+ else:
+ cmd += ['HEAD']
+
+ if max_count:
+ cmd += ['--max-count', '%s' % max_count]
+
+ return self.run_git_split(cmd)
+
def get_branch_fork_point(self, branch):
"""
:type branch: str