gitlab-ci: make explicit tracie is gitlab specific

Tracie main script and traces.yml file talk about repo(sitory) when it
actually means GitLab's project.

Since the script is GitLab's API specific, make it clear.

Signed-off-by: Andres Gomez <agomez@igalia.com>
Reviewed-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Reviewed-by: Rohan Garg <rohan.garg@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4496>
This commit is contained in:
Andres Gomez
2020-04-08 23:52:14 +03:00
parent 1ca91683e2
commit acf7e73be5
2 changed files with 13 additions and 21 deletions

View File

@@ -1,5 +1,5 @@
traces-db: traces-db:
repo: "https://gitlab.freedesktop.org/gfx-ci/tracie/traces-db" gitlab-project-url: "https://gitlab.freedesktop.org/gfx-ci/tracie/traces-db"
commit: "d3b1efe0cd69ef6ae40a29a14ed733ee0ba0cb4c" commit: "d3b1efe0cd69ef6ae40a29a14ed733ee0ba0cb4c"
traces: traces:

View File

@@ -36,12 +36,8 @@ def replay(trace_path, device_name):
log_file = files[0] log_file = files[0]
return hashlib.md5(Image.open(image_file).tobytes()).hexdigest(), image_file, log_file return hashlib.md5(Image.open(image_file).tobytes()).hexdigest(), image_file, log_file
def download_metadata(repo_url, repo_commit, trace_path): def gitlab_download_metadata(project_url, repo_commit, trace_path):
# The GitLab API doesn't want the .git postfix url = parse.urlparse(project_url)
url = repo_url
if url.endswith(".git"):
url = url[:-4]
url = parse.urlparse(url)
url_path = url.path url_path = url.path
if url_path.startswith("/"): if url_path.startswith("/"):
@@ -57,7 +53,7 @@ def download_metadata(repo_url, repo_commit, trace_path):
return oid, size return oid, size
def download_trace(repo_url, repo_commit, trace_path, oid, size): def gitlfs_download_trace(repo_url, repo_commit, trace_path, oid, size):
headers = { headers = {
"Accept": "application/vnd.git-lfs+json", "Accept": "application/vnd.git-lfs+json",
"Content-Type": "application/vnd.git-lfs+json" "Content-Type": "application/vnd.git-lfs+json"
@@ -74,10 +70,6 @@ def download_trace(repo_url, repo_commit, trace_path, oid, size):
] ]
} }
# The LFS API really wants the .git postfix...
if not repo_url.endswith(".git"):
repo_url += ".git"
r = requests.post(repo_url + "/info/lfs/objects/batch", headers=headers, json=json) r = requests.post(repo_url + "/info/lfs/objects/batch", headers=headers, json=json)
url = r.json()["objects"][0]["actions"]["download"]["href"] url = r.json()["objects"][0]["actions"]["download"]["href"]
open(TRACES_DB_PATH + trace_path, "wb").write(requests.get(url).content) open(TRACES_DB_PATH + trace_path, "wb").write(requests.get(url).content)
@@ -89,9 +81,9 @@ def checksum(filename, hash_factory=hashlib.sha256, chunk_num_blocks=128):
h.update(chunk) h.update(chunk)
return h.hexdigest() return h.hexdigest()
def ensure_trace(repo_url, repo_commit, trace): def gitlab_ensure_trace(project_url, repo_commit, trace):
trace_path = TRACES_DB_PATH + trace['path'] trace_path = TRACES_DB_PATH + trace['path']
if repo_url is None: if project_url is None:
assert(repo_commit is None) assert(repo_commit is None)
assert(os.path.exists(trace_path)) assert(os.path.exists(trace_path))
return return
@@ -101,16 +93,16 @@ def ensure_trace(repo_url, repo_commit, trace):
if os.path.exists(trace_path): if os.path.exists(trace_path):
local_oid = checksum(trace_path) local_oid = checksum(trace_path)
remote_oid, size = download_metadata(repo_url, repo_commit, trace['path']) remote_oid, size = gitlab_download_metadata(project_url, repo_commit, trace['path'])
if not os.path.exists(trace_path) or local_oid != remote_oid: if not os.path.exists(trace_path) or local_oid != remote_oid:
print("[check_image] Downloading trace %s" % (trace['path']), end=" ", flush=True) print("[check_image] Downloading trace %s" % (trace['path']), end=" ", flush=True)
download_time = time.time() download_time = time.time()
download_trace(repo_url, repo_commit, trace['path'], remote_oid, size) gitlfs_download_trace(project_url + ".git", repo_commit, trace['path'], remote_oid, size)
print("took %ds." % (time.time() - download_time), flush=True) print("took %ds." % (time.time() - download_time), flush=True)
def check_trace(repo_url, repo_commit, device_name, trace, expectation): def gitlab_check_trace(project_url, repo_commit, device_name, trace, expectation):
ensure_trace(repo_url, repo_commit, trace) gitlab_ensure_trace(project_url, repo_commit, trace)
result = {} result = {}
result[trace['path']] = {} result[trace['path']] = {}
@@ -157,10 +149,10 @@ def main():
y = yaml.safe_load(f) y = yaml.safe_load(f)
if "traces-db" in y: if "traces-db" in y:
repo = y["traces-db"]["repo"] project_url = y["traces-db"]["gitlab-project-url"]
commit_id = y["traces-db"]["commit"] commit_id = y["traces-db"]["commit"]
else: else:
repo = None project_url = None
commit_id = None commit_id = None
traces = y['traces'] traces = y['traces']
@@ -169,7 +161,7 @@ def main():
for trace in traces: for trace in traces:
for expectation in trace['expectations']: for expectation in trace['expectations']:
if expectation['device'] == args.device_name: if expectation['device'] == args.device_name:
ok, result = check_trace(repo, commit_id, args.device_name, trace, expectation) ok, result = gitlab_check_trace(project_url, commit_id, args.device_name, trace, expectation)
all_ok = all_ok and ok all_ok = all_ok and ok
results.update(result) results.update(result)