Add find_artifacts
Some checks failed
buildbot/travis_bionic Build done.

This commit is contained in:
Peter Šurda 2021-12-17 11:22:09 +08:00
parent 6cb6b47fd9
commit 806761eda7
Signed by: PeterSurda
GPG Key ID: 3E47497CF67ABB95

View File

@ -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, _)