[mod] disociate job from repo

This commit is contained in:
Laurent Peuch 2018-07-13 07:32:41 +02:00
parent ffd5eae5e8
commit d40beab8b2
3 changed files with 7 additions and 5 deletions

View file

@ -14,7 +14,8 @@ class Repo(peewee.Model):
class Job(peewee.Model):
repo = peewee.ForeignKeyField(Repo)
name = peewee.CharField()
url_or_path = peewee.CharField()
target_revision = peewee.CharField()
yunohost_version = peewee.CharField()

7
run.py
View file

@ -59,7 +59,8 @@ async def initialize_app_list():
print(f"Schedule a new build for {app_id}")
Job.create(
repo=repo,
name=f"{app_id} stable",
url_or_path=repo.url,
target_revision=app_data["git"]["revision"],
yunohost_version="stretch-stable",
state="scheduled",
@ -110,7 +111,7 @@ async def run_job(worker, job):
}, "jobs")
# fake stupid command, whould run CI instead
print(f"Starting job for {job.repo.name}...")
print(f"Starting job {job.name}...")
command = await asyncio.create_subprocess_shell("/usr/bin/tail /var/log/auth.log",
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE)
@ -123,7 +124,7 @@ async def run_job(worker, job):
# XXX stupid crap to stimulate long jobs
await asyncio.sleep(random.randint(1, 15))
# await asyncio.sleep(5)
print(f"Finished job for {job.repo.name}")
print(f"Finished job {job.name}")
await command.wait()
job.end_time = datetime.now()

View file

@ -20,7 +20,7 @@
<th>End time</th>
</tr>
<tr v-for="job in jobs" :id="job.id">
<td>{{job.repo.name}}</td>
<td>{{job.name}}</td>
<td>{{job.state}}</td>
<td>{{job.target_revision}}</td>
<td>{{job.yunohost_version}}</td>