~sircmpwn/builds.sr.ht

builds.sr.ht/buildsrht/templates/job.html -rw-r--r-- 6.3 KiB
48fa5794Dhruvin Gandhi alpine: run setup-timezone conditionally 10 days ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
{% extends "layout-full.html" %}
{% block title %}
<title>
  build #{{ job.id }} - {{ job.status.value }}
</title>
{% endblock %}
{% block head %}
{% if job.status.value == "pending" or job.status.value == "queued" %}
<meta id="refresh" http-equiv="refresh" content="10">
{% endif %}
{% if job.status.value == "running" %}
<meta id="refresh" http-equiv="refresh" content="5">
{% endif %}
{% endblock %}
{% block body %} 
<div class="container-fluid">
  <section class="row">
    <div class="col-lg-3 col-md-12">
      <h2>
        #{{ job.id }}
        <span class="pull-right">
          {{icon(icon_map.get(job.status), cls=status_map.get(job.status, ""))}}
          {{ job.status.value }}
        </span>
      </h2>
      <dl>
        {% if job.note %}
        <p>{{ job.note | md }}</p>
        {% endif %}
        <dt>Owner</dt>
        <dd>
          <a href="/~{{ job.owner.username }}">
            ~{{ job.owner.username }}
          </a>
        </dd>
        <dt>Created</dt>
        <dd>{{ job.created | date }}</dd>
        <dt>Updated</dt>
        <dd>{{ job.updated | date }}</dd>
        <dt>Build manifest</dt>
        <dd><a href="/api/jobs/{{ job.id }}/manifest">view manifest »</a></dd>
      </dl>
      {% if current_user and job.status.value in [
        "success", "failed", "timeout", "cancelled"
      ] and not payment_required %}
      <form style="margin-bottom: 0.5rem" method="POST" action="/submit">
        {{csrf_token()}}
        <input
          type="hidden"
          name="note"
          value="Resubmission of build [#{{job.id}}](/~{{ job.owner.username }}/job/{{ job.id }})"
        />
        <button class="btn btn-primary btn-block">
          Resubmit build
          {{ icon("caret-right") }}
        </button>
        <input type="hidden" name="manifest" value="{{job.manifest}}" />
      </form>
      <form>
        <a
          href="{{ url_for("jobs.resubmit_GET", job_id=job.id) }}"
          class="btn btn-default btn-block"
        >
          Edit &amp; resubmit
          {{ icon("caret-right") }}
        </a>
      </form>
      {% elif (current_user and
        (current_user.id == job.owner_id or current_user.user_type.value == "admin") and
        job.status.value == "running") %}
      <form method="POST" action="{{ url_for("jobs.cancel", job_id=job.id) }}">
        {{csrf_token()}}
        <button class="btn btn-danger btn-block">
          Cancel build
        </button>
      </form>
      {% endif %}
      {% if any(job.artifacts) %}
      <h4>Artifacts</h4>
      <table class="table table-sm">
      {% for artifact in job.artifacts %}
        <tr>
          <td style="
              max-width: 200px;
              overflow-x: hidden;
              text-overflow: ellipsis;
          ">
            <span title="{{artifact.path}}">
              {{artifact.name}}
            </span>
          </td>
          <td>
            {{naturalsize(artifact.size, binary=True)}}
          </td>
          <td>
            {% if artifact.created > min_artifact_date %}
            <a
              rel="noopener nofollow"
              href="{{artifact.url}}"
            >download »</a>
            {% else %}
            <span class="text-muted">(pruned after 90 days)</span>
            {% endif %}
          </td>
        </tr>
      {% endfor %}
      </table>
      <div class="alert alert-warning">
        Build artifacts are pruned after 90 days.
      </div>
      {% endif %}
      <h4>Tasks</h4>
      <table class="table table-sm">
        <tr class="text-muted">
          <td></td>
          <td>
            <a href="#setup">view log »</a>
          </td>
        </tr>
      {% for task in sort_tasks(job.tasks) %}
        <tr>
          <td>
            <span title="{{ task.status.value }}">
              {{icon(icon_map.get(task.status), cls=status_map.get(task.status, ""))}}
              {{task.name}}
            </span>
          </td>
          <td>
            <a href="#task-{{ task.name }}">view log »</a>
          </td>
        </tr>
      {% endfor %}
      </table>
      <a href="#bottom">go to bottom »</a><br>
      <a class="to-top" href="#">go to top »</a>
    </div>
    <div class="col-lg-9 col-md-12">
      {% if current_user and current_user.id == job.owner_id %}
      {% if (job.status.value == "failed" and
          datetime.utcnow() < job.updated + timedelta(minutes=10)) %}
      <div class="alert alert-danger">
        <strong>This build job failed.</strong> You may log into the failed
        build environment within 10 minutes to examine the results with the
        following command:
        <pre
          style="margin-bottom: 0; margin-top: 1rem;"
          >ssh -t {{build_user}}@{{job.runner}} connect {{job.id}}</pre>
      </div>
      {% endif %}
      {% endif %}
      {% if job.status.value != "queued" %}
        {% for log in logs %}
        <details open>
          {% if log["name"] %}
          <summary id="task-{{log["name"]}}">{{ log["name"] }}</summary>
          {% else %}
          <summary id="setup" class="text-muted">setup</summary>
          {% endif %}
          <table class="table-code">
            <tr>
              {{log["log"]}}
            </tr>
          </table>
        </details>
        {% endfor %}
      {% endif %}
      {% if job.status.value == "success" or job.status.value == "failed" %}
      <div class="alert {{ "alert-success" if job.status.value == "success" else "alert-danger" }}">
        Build complete: <strong>{{ job.status.value }}</strong> {{ job.updated | date }}
        (took {{(job.updated - job.created) | date}})
      </div>
      {% endif %}
      <a id="bottom"></a>
    </div>
  </section>
</div>
{% endblock %}
{% block scripts %}
<script>
// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-3.0-only
(function() {
  document.addEventListener("DOMContentLoaded", function() {
    var meta_refresh = document.getElementById("refresh");
    if (meta_refresh) {
      var timeout = parseInt(meta_refresh.getAttribute("content"));
      meta_refresh.parentNode.removeChild(meta_refresh);
      window.setTimeout(function() {
        location.reload();
      }, timeout * 1000);
    }
    if (window.location.hash === "#bottom") {
      window.setTimeout(function() {
        document.documentElement.scrollTop = document.documentElement.scrollHeight;
      }, 100);
    }
  });
})();
// @license-end
</script>
{% endblock %}