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