Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use deterministic workdir ids #243

Merged
merged 6 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions src/python/merge_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def merge_analyzer( # pylint: disable=too-many-locals
Merges two branches and returns the result.
Args:
args (Tuple[str,pd.Series,Path]): A tuple containing the repo slug,
the merge data, and the cache path.
the merge data (which is side-effected), and the cache path.
Returns:
dict: A dictionary containing the merge result.
"""
Expand All @@ -58,10 +58,20 @@ def merge_analyzer( # pylint: disable=too-many-locals
return merge_data

cache_data = {}
repo_left = Repository(repo_slug, cache_directory=cache_directory)
repo_right = Repository(repo_slug, cache_directory=cache_directory)
left_success, _ = repo_left.checkout(merge_data["left"])
right_success, _ = repo_right.checkout(merge_data["right"])
left_sha = merge_data["left"]
right_sha = merge_data["right"]
repo_left = Repository(
repo_slug,
cache_directory=cache_directory,
workdir_id="left-" + left_sha + "-" + right_sha,
)
repo_right = Repository(
repo_slug,
cache_directory=cache_directory,
workdir_id="right-" + left_sha + "-" + right_sha,
)
left_success, _ = repo_left.checkout(left_sha)
right_success, _ = repo_right.checkout(right_sha)

# Compute diff size in lines between left and right
assert repo_left.repo_path.exists()
Expand Down
6 changes: 5 additions & 1 deletion src/python/merge_differ.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@ def get_merge_fingerprint(
return None, None
left = merge_data["left"]
right = merge_data["right"]
repo = Repository(repo_slug, cache_directory=cache_directory)
repo = Repository(
repo_slug,
cache_directory=cache_directory,
workdir_id="merge-differ-" + left + "-" + right,
)
(
merge_status,
merge_fingerprint,
Expand Down
13 changes: 11 additions & 2 deletions src/python/merge_tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ def merge_tester(args: Tuple[str, pd.Series, Path]) -> pd.Series:
merge_data["parents pass"] = False
for branch in ["left", "right"]:
commit_sha = merge_data[branch]
repo = Repository(repo_slug, cache_directory=cache_directory)
repo = Repository(
repo_slug,
cache_directory=cache_directory,
workdir_id="test-" + branch + "-" + commit_sha,
)
test_result, test_coverage, tree_fingerprint = repo.checkout_and_test(
commit_sha, TIMEOUT_TESTING_PARENT, N_TESTS
)
Expand All @@ -77,7 +81,12 @@ def merge_tester(args: Tuple[str, pd.Series, Path]) -> pd.Series:
merge_data["parents pass"] = True

for merge_tool in MERGE_TOOL:
repo = Repository(repo_slug, cache_directory=cache_directory)
repo = Repository(
repo_slug,
cache_directory=cache_directory,
workdir_id=f"merge-tester-{merge_tool.name}-"
+ f'{merge_data["left"]}-{merge_data["right"]}',
)
(
result,
merge_fingerprint,
Expand Down
2 changes: 1 addition & 1 deletion src/python/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ def __init__(
self,
repo_slug: str,
cache_directory: Path = Path(""),
workdir_id=uuid.uuid4().hex, # uuid4 is a random UID
) -> None:
"""Initializes the repository.
Args:
Expand All @@ -121,7 +122,6 @@ def __init__(
"""
self.repo_slug = repo_slug
self.path = REPOS_PATH / repo_slug.split("/")[1]
workdir_id = uuid.uuid4().hex
self.workdir = WORKDIR_DIRECTORY / workdir_id
self.workdir.mkdir(parents=True, exist_ok=True)
self.repo_path = self.workdir / self.path.name
Expand Down
6 changes: 5 additions & 1 deletion src/python/test_repo_heads.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ def head_passes_tests(args: Tuple[pd.Series, Path]) -> TEST_STATE:
print("test_repo_heads:", repo_slug, ": head_passes_tests : started")

try:
repo = Repository(repo_slug, cache_directory=cache)
repo = Repository(
repo_slug,
cache_directory=cache,
workdir_id="head-" + repo_info["head hash"],
)
except FileNotFoundError as e:
print("test_repo_heads:", repo_slug, ": head_passes_tests :", e)
return TEST_STATE.Git_checkout_failed
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/merge_tools/resolve-adjacent-conflicts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
# kdiff3 --auto --cs "ShowInfoDialogs=0" base.txt parent1.txt parent2.txt -o merged.txt
# Also, the `--auto` option is ignored for folder comparison.

DEBUG=1
DEBUG=0

if [ "$#" -eq 0 ] ; then
readarray -t files < <(grep -l -r '^<<<<<<< HEAD' .)
Expand Down