Skip to content
Snippets Groups Projects
Commit df421799 authored by Daniel Skýpala's avatar Daniel Skýpala
Browse files

Refresh: Split refresh and test_random

parent 84e533a6
Branches
No related tags found
No related merge requests found
from copy import deepcopy
from git import Repo
import json
from random import shuffle
import os
......@@ -7,17 +8,30 @@ import task_autotest.config as config
from task_autotest.util import path_to_str
from task_autotest.test import test_task_commit
def refresh() -> None:
repo = Repo(config.REPO_DIR)
repo.remotes.origin.pull()
tasks = deepcopy(config.TASKS)
shuffle(tasks)
def refresh() -> dict[str, str]:
repo.remotes.origin.pull()
for branch, task in tasks:
task_commits = {}
for branch, task in config.TASKS:
repo.git.checkout(branch)
commit_hash = repo.head.commit.hexsha
task_commits[task] = repo.head.commit.hexsha
return task_commits
def test_random(task_commits: dict[str, str]):
task_commits = list(task_commits.items())
shuffle(task_commits)
for task, commit_hash in task_commits:
if not os.path.exists(os.path.join(config.DATA_DIR, path_to_str(task), commit_hash)):
return test_task_commit(task, commit_hash)
return None
def run():
with open(os.path.join(DATA_DIR, "task_commits")) as f:
json.dump(f, task_commits := refresh())
test_random(task_commits)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment