From 806761eda71985630118185043a8b1c917c538e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20=C5=A0urda?= Date: Fri, 17 Dec 2021 11:22:09 +0800 Subject: [PATCH] Add find_artifacts --- multibuild.py | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/multibuild.py b/multibuild.py index 00bf8e9..17c9f32 100644 --- a/multibuild.py +++ b/multibuild.py @@ -1,4 +1,8 @@ #!/usr/bin/python3 +""" +Allow buildbot to run jobs dynamically defined a a project repo +Requires docker +""" # TODO: change "ghcontext" in master.cfg to interpolate the job name # TODO: write upload script @@ -7,18 +11,29 @@ # TODO: what to do about non-docker jobs from os import walk -from os.path import exists, join +from os.path import exists, isfile, join, listdir -def list_jobs(dir="."): +def list_jobs(directory=".buildbot"): + """ + list jobs found in a directory + """ results = [] - for d in next(walk(dir()))[1]: - if exists(join(dir, d, "Dockerfile")) \ - and (exists(join(dir, d, "build.sh")) - or exists(join(dir, d, "test.sh")) + for _ in next(walk(directory))[1]: + if exists(join(directory, _, "Dockerfile")) \ + and (exists(join(directory, _, "build.sh")) + or exists(join(directory, _, "test.sh")) ): - results.append(d) + results.append(_) return results +def find_artifacts(directory="out"): + """ + find artifacts (any file) in a directory + """ + for _ in listdir(directory): + if not isfile(join(directory, _)): + continue + return join(directory, _)