Skip to content
Merged
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
34 changes: 5 additions & 29 deletions contest/results-faker.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,43 +15,19 @@
Config:

[input]
branches=/path/to/branches.json,/path/to/branches2.json
infos=/path/to/infos.json,/path/to/infos2.json
branches=/path/to/branches.json
[output]
dir=/path/to/output
url_pfx=relative/within/server
info=/path/to/info.json
"""

def combine_infos(config):
paths = config.get("input", "infos", fallback="").split(',')
if not paths or not paths[0]:
return

infos = {}
for path in paths:
with open(path, "r") as fp:
infos.update(json.load(fp))

# atomic write needed
path = config.get("output", "info")
tmp = path + '.new'
with open(tmp, 'w') as fp:
json.dump(infos, fp)
os.rename(tmp, path)


def main() -> None:
config = configparser.ConfigParser()
config.read(['faker.config'])

combine_infos(config)

branches = []
paths = config.get("input", "branches")
for path in paths.split(','):
with open(path, "r") as fp:
branches += json.load(fp)
path = config.get("input", "branches")
with open(path, "r") as fp:
branches = json.load(fp)

branches = sorted(branches, key=lambda x: x["date"])

Expand Down Expand Up @@ -85,7 +61,7 @@ def main() -> None:
if br["url"].startswith('https://github.com') and tail > 0:
br_url = br["url"][:tail] + "/commits/" + br["url"][tail + 5:]
else:
br_url = "https://netdev.bots.linux.dev/contest/branches.json"
br_url = "https://netdev.bots.linux.dev/contest/" + os.path.basename(path)

run["results"] = [
{"test": "branch-created", "group": "---", "result": "pass", "link": br_url}
Expand Down
Loading