]> git.ipfire.org Git - pbs.git/commitdiff
events: Add jobs
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 29 Apr 2023 11:36:30 +0000 (11:36 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 29 Apr 2023 11:36:30 +0000 (11:36 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/buildservice/events.py
src/templates/events/modules/system-message.html

index 0602c21632a1a02efccc1af72894f5637863821b..95f41d85f98c579b52325a769c0b59b601323bc5 100644 (file)
@@ -32,7 +32,7 @@ log = logging.getLogger("pbs.events")
 # WARNING        : 8
 # MAJOR INFO     : 5
 # MINOR INFO     : 4
-# DEBUG          : 0
+# DEBUG          : 1
 
 # The view returns the following fields
 # type (of the event)
@@ -41,6 +41,7 @@ log = logging.getLogger("pbs.events")
 # build
 # by_build
 # build_comment
+# job
 # user
 # by_user
 # repository
@@ -55,6 +56,7 @@ EVENTS_VIEW = """
                        builds.id AS build,
                        NULL::integer AS by_build,
                        NULL::integer AS build_comment,
+                       NULL::integer AS job,
                        NULL::integer AS user,
                        builds.owner_id AS by_user,
                        NULL::integer AS repository
@@ -79,6 +81,7 @@ EVENTS_VIEW = """
                        builds.id AS build,
                        NULL AS by_build,
                        NULL AS build_comment,
+                       NULL AS job,
                        NULL AS user,
                        NULL AS by_user,
                        NULL AS repository
@@ -97,6 +100,7 @@ EVENTS_VIEW = """
                        builds.id AS build,
                        NULL AS by_build,
                        NULL AS build_comment,
+                       NULL AS job,
                        NULL AS user,
                        builds.deleted_by AS by_user,
                        NULL AS repository
@@ -116,6 +120,7 @@ EVENTS_VIEW = """
                        builds.id AS build,
                        builds.deprecating_build_id AS by_build,
                        NULL AS build_comment,
+                       NULL AS job,
                        NULL AS user,
                        builds.deprecated_by AS by_user,
                        NULL AS repository
@@ -136,6 +141,7 @@ EVENTS_VIEW = """
                        build_comments.build_id AS build,
                        NULL AS by_build,
                        build_comments.id AS build_comment,
+                       NULL AS job,
                        NULL AS user,
                        build_comments.user_id AS by_user,
                        NULL AS repository
@@ -154,6 +160,7 @@ EVENTS_VIEW = """
                        build_watchers.build_id AS build,
                        NULL AS by_build,
                        NULL AS build_comment,
+                       NULL AS job,
                        build_watchers.user_id AS user,
                        NULL AS by_user,
                        NULL AS repository
@@ -170,6 +177,7 @@ EVENTS_VIEW = """
                        build_watchers.build_id AS build,
                        NULL AS by_build,
                        NULL AS build_comment,
+                       NULL AS job,
                        build_watchers.user_id AS user,
                        NULL AS by_user,
                        NULL AS repository
@@ -188,6 +196,7 @@ EVENTS_VIEW = """
                        repository_builds.build_id AS build,
                        NULL AS by_build,
                        NULL AS build_comment,
+                       NULL AS job,
                        NULL AS user,
                        repository_builds.added_by AS by_user,
                        repository_builds.repo_id AS repository
@@ -204,6 +213,7 @@ EVENTS_VIEW = """
                        repository_builds.build_id AS build,
                        NULL AS by_build,
                        NULL AS build_comment,
+                       NULL AS job,
                        NULL AS user,
                        repository_builds.removed_by AS by_user,
                        repository_builds.repo_id AS repository
@@ -211,6 +221,117 @@ EVENTS_VIEW = """
                        repository_builds
                WHERE
                        removed_at IS NOT NULL
+
+               UNION ALL
+
+               -- Jobs Creations
+               SELECT
+                       'job-created' AS type,
+                       jobs.created_at AS t,
+                       3 AS priority,
+                       jobs.build_id AS build,
+                       NULL AS by_build,
+                       NULL AS build_comment,
+                       jobs.id AS job,
+                       NULL AS user,
+                       NULL AS by_user,
+                       NULL AS repository
+               FROM
+                       jobs
+               WHERE
+                       jobs.deleted_at IS NULL
+
+               UNION ALL
+
+               -- Failed Jobs
+               SELECT
+                       'job-failed' AS type,
+                       jobs.finished_at AS t,
+                       5 AS priority,
+                       jobs.build_id AS build,
+                       NULL AS by_build,
+                       NULL AS build_comment,
+                       jobs.id AS job,
+                       NULL AS user,
+                       NULL AS by_user,
+                       NULL AS repository
+               FROM
+                       jobs
+               WHERE
+                       jobs.deleted_at IS NULL
+               AND
+                       jobs.finished_at IS NOT NULL
+               AND
+                       jobs.aborted IS FALSE
+               AND
+                       jobs.failed IS TRUE
+
+               UNION ALL
+
+               -- Finished Jobs
+               SELECT
+                       'job-finished' AS type,
+                       jobs.finished_at AS t,
+                       4 AS priority,
+                       jobs.build_id AS build,
+                       NULL AS by_build,
+                       NULL AS build_comment,
+                       jobs.id AS job,
+                       NULL AS user,
+                       NULL AS by_user,
+                       NULL AS repository
+               FROM
+                       jobs
+               WHERE
+                       jobs.deleted_at IS NULL
+               AND
+                       jobs.finished_at IS NOT NULL
+               AND
+                       jobs.aborted IS FALSE
+               AND
+                       jobs.failed IS FALSE
+
+               UNION ALL
+
+               -- Aborted Jobs
+               SELECT
+                       'job-aborted' AS type,
+                       jobs.finished_at AS t,
+                       4 AS priority,
+                       jobs.build_id AS build,
+                       NULL AS by_build,
+                       NULL AS build_comment,
+                       jobs.id AS job,
+                       NULL AS user,
+                       jobs.aborted_by AS by_user,
+                       NULL AS repository
+               FROM
+                       jobs
+               WHERE
+                       jobs.deleted_at IS NULL
+               AND
+                       jobs.aborted IS TRUE
+
+               UNION ALL
+
+               -- Dispatched Jobs
+               SELECT
+                       'job-dispatched' AS type,
+                       jobs.started_at AS t,
+                       1 AS priority,
+                       jobs.build_id AS build,
+                       NULL AS by_build,
+                       NULL AS build_comment,
+                       jobs.id AS job,
+                       NULL AS user,
+                       NULL AS by_user,
+                       NULL AS repository
+               FROM
+                       jobs
+               WHERE
+                       jobs.deleted_at IS NULL
+               AND
+                       jobs.started_at IS NOT NULL
        )
 """
 
@@ -225,6 +346,9 @@ class Events(base.Object):
                        # Build Comments
                        "build_comment" : self.backend.builds.comments.get_by_id,
 
+                       # Jobs
+                       "job"           : self.backend.jobs.get_by_id,
+
                        # Repositories
                        "repository" : self.backend.repos.get_by_id,
 
index cd22bb52b08d4e61496abd9b867c534f3359a689..bb32b1c7c9e3500c16ce89d18afeda9e3dd0b03e 100644 (file)
@@ -1,11 +1,11 @@
 <div class="media">
        {% block thumbnail %}
                <div class="media-left">
-                       {% if event.type == "build-failed" %}
+                       {% if event.type in ("build-failed", "job-failed") %}
                                <span class="icon is-large has-text-danger">
                                        <i class="fa-solid fa-3x fa-square-xmark"></i>
                                </span>
-                       {% elif event.type == "build-finished" %}
+                       {% elif event.type in ("build-finished", "job-finished") %}
                                <span class="icon is-large has-text-success">
                                        <i class="fa-solid fa-3x fa-square-check"></i>
                                </span>
                                {{ _("%s started watching this build") % event.user }}
                        {% elif event.type == "build-watcher-removed" %}
                                {{ _("%s stopped watching this build") % event.user }}
+                       {% elif event.type == "job-created" %}
+                               {{ _("Job Created") }}
+                       {% elif event.type == "job-failed" %}
+                               {{ _("Job Failed") }}
+                       {% elif event.type == "job-finished" %}
+                               {{ _("Job Finished") }}
+                       {% elif event.type == "job-aborted" %}
+                               {{ _("Job Aborted") }}
+                       {% elif event.type == "job-dispatched" %}
+                               {{ _("Job Dispatched") }}
                        {% elif event.type == "repository-build-added" %}
                                {{ _("Build has been added to repository %s") % event.repository }}
                        {% elif event.type == "repository-build-removed" %}
@@ -49,7 +59,7 @@
                <nav class="level">
                        <div class="level-left is-small">
                                {# Build #}
-                               {% if show_build and event.build %}
+                               {% if show_build and event.build and not event.job %}
                                        <a class="level-item" href="/builds/{{ event.build.uuid }}">
                                                {{ event.build }}
                                        </a>
                                        </a>
                                {% end %}
 
+                               {# Job #}
+                               {% if event.job %}
+                                       <a class="level-item" href="/builds/{{ event.job.build.uuid }}#{{ event.job.arch }}">
+                                               {{ event.job }}
+                                       </a>
+                               {% end %}
+
                                {# Repository #}
                                {% if event.repository %}
                                        <a class="level-item" href="{{ event.repository.url }}">