Add a link to the latest build log in the status output

This commit is contained in:
Luca Beltrame 2022-01-23 18:13:31 +01:00
parent 41ccc99f67
commit 356fedb09a
Signed by: einar
GPG key ID: 4707F46E9EC72DEC

View file

@ -1,8 +1,6 @@
# (C)
import asyncio
from dataclasses import dataclass
import sys
from typing import Optional, List, Type
import aiohttp
@ -19,13 +17,20 @@ HEADER_TEMPLATE = """
{% if state %}
Only showing packages with {{ state }} state.
{% endif %}"""
REPO_TEMPLATE = """
#### {{ repo.name }} - {{ repo.arch }}
{% for package in repo.packages %}
{%if package.status != "disabled" %}
{% set build_log_url = "{0}/public/build/{1}/{2}/{3}/{4}/_log".format(
base_url,project, repo.name, repo.arch, package.name) %}
- {{ package.name }} - *[{{ package.status }}]({{ build_log_url }})*
{% else %}
- {{ package.name }} - *{{ package.status }}*
{% endif %}
{% endfor %}
"""
@ -50,6 +55,12 @@ class Config(BaseProxyConfig):
helper.base["api_url"] = "https://api.opensuse.org"
else:
helper.copy("api_url")
if "token" not in self:
helper.base["token"] = "CHANGEME"
else:
helper.copy("token")
helper.copy("username")
helper.copy("password")
@ -206,8 +217,12 @@ class OSCBot(Plugin):
header = self.template.from_string(HEADER_TEMPLATE)
message = header.render(state=state)
await evt.reply(message, markdown=True)
base_url = "https://build.opensuse.org" # TODO: Configure this
for repository in response:
body = self.template.from_string(REPO_TEMPLATE)
message = body.render(repo=repository)
message = body.render(repo=repository, project=project,
base_url=base_url)
await evt.respond(message, markdown=True)