Auto merge of #28093 - jdm:no-dups, r=SimonSapin

Disallow duplicate taskcluster artifacts.

Taskcluster has started complaining if the task's payload contains duplicate artifacts. These changes strip them out and add automated tests that detect them in the future.
This commit is contained in:
bors-servo 2021-01-24 20:18:40 -05:00 committed by GitHub
commit 639e686bfa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 3 deletions

View file

@ -698,12 +698,13 @@ def wpt_chunks(platform, make_chunk_task, build_task, total_chunks, processes,
--tracker-api default \
--reporter-api default
""")
task.with_artifacts(*[
all_artifacts = set([
"%s/%s" % (repo_dir, word)
for script in task.scripts
for word in script.split()
if word.endswith(".log")
])
task.with_artifacts(*all_artifacts)
task.find_or_create("%s_%swpt_%s.%s" % (
platform.replace(" ", "_").lower(),
job_id_prefix.replace("-", "_"),

View file

@ -387,7 +387,10 @@ class GenericWorkerTask(Task):
Paths are relative to the tasks home directory.
"""
self.artifacts.extend((type, path) for path in paths)
for path in paths:
if (type, path) in self.artifacts:
raise ValueError("Duplicate artifact: " + path) # pragma: no cover
self.artifacts.append(tuple((type, path)))
return self
def with_features(self, *names):
@ -736,13 +739,19 @@ class DockerWorkerTask(UnixTaskMixin, Task):
with_docker_image = chaining(setattr, "docker_image")
with_max_run_time_minutes = chaining(setattr, "max_run_time_minutes")
with_artifacts = chaining(append_to_attr, "artifacts")
with_script = chaining(append_to_attr, "scripts")
with_early_script = chaining(prepend_to_attr, "scripts")
with_caches = chaining(update_attr, "caches")
with_env = chaining(update_attr, "env")
with_capabilities = chaining(update_attr, "capabilities")
def with_artifacts(self, *paths):
for path in paths:
if path in self.artifacts:
raise ValueError("Duplicate artifact: " + path) # pragma: no cover
self.artifacts.append(path)
return self
def build_worker_payload(self):
"""
Return a `docker-worker` worker payload.