mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2026-01-26 01:14:27 +01:00
Rearrange tests & fix CI (#4596)
* Rearrange tests into unit/integration/challenge categories * Fix linting + `tests.challenges` imports * Fix obscured duplicate test in test_url_validation.py * Move VCR conftest to tests.vcr * Specify tests to run & their order (unit -> integration -> challenges) in CI * Fail Docker CI when tests fail * Fix import & linting errors in tests * Fix `get_text_summary` * Fix linting errors * Clean up pytest args in CI * Remove bogus tests from GoCodeo
This commit is contained in:
committed by
GitHub
parent
8a881f70a3
commit
dafbd11686
43
tests/challenges/utils/build_current_score.py
Normal file
43
tests/challenges/utils/build_current_score.py
Normal file
@@ -0,0 +1,43 @@
|
||||
import glob
|
||||
import json
|
||||
import os
|
||||
from typing import Any, Dict
|
||||
|
||||
|
||||
def deep_merge(source: Dict[Any, Any], dest: Dict[Any, Any]) -> Dict[Any, Any]:
|
||||
for key, value in source.items():
|
||||
if isinstance(value, Dict):
|
||||
dest[key] = deep_merge(value, dest.get(key, {}))
|
||||
else:
|
||||
dest[key] = value
|
||||
return dest
|
||||
|
||||
|
||||
import collections
|
||||
|
||||
|
||||
def recursive_sort_dict(data: dict) -> dict:
|
||||
for key, value in data.items():
|
||||
if isinstance(value, dict):
|
||||
data[key] = recursive_sort_dict(value)
|
||||
return collections.OrderedDict(sorted(data.items()))
|
||||
|
||||
# setup
|
||||
|
||||
|
||||
cwd = os.getcwd() # get current working directory
|
||||
new_score_filename_pattern = os.path.join(cwd, "tests/challenges/new_score_*.json")
|
||||
current_score_filename = os.path.join(cwd, "tests/challenges/current_score.json")
|
||||
|
||||
merged_data: Dict[str, Any] = {}
|
||||
for filename in glob.glob(new_score_filename_pattern):
|
||||
with open(filename, "r") as f_new:
|
||||
data = json.load(f_new)
|
||||
merged_data = deep_merge(
|
||||
data, merged_data
|
||||
) # deep merge the new data with the merged data
|
||||
os.remove(filename) # remove the individual file
|
||||
sorted_data = recursive_sort_dict(merged_data)
|
||||
|
||||
with open(current_score_filename, "w") as f_current:
|
||||
json.dump(sorted_data, f_current, indent=4)
|
||||
Reference in New Issue
Block a user