Skip to content

Commit 4219202

Browse files
committed
Show PR number and commit type for currently benchmarked commit
1 parent 039219b commit 4219202

File tree

2 files changed

+64
-14
lines changed

2 files changed

+64
-14
lines changed

site/frontend/src/pages/status/data.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
interface Commit {
1+
export interface Commit {
22
sha: string;
33
date: string;
44
type: "Try" | "Master";
@@ -16,15 +16,15 @@ interface Step {
1616
current_progress: number;
1717
}
1818

19-
type Artifact =
19+
export type Artifact =
2020
| {
2121
Commit: Commit;
2222
}
2323
| {
2424
Tag: string;
2525
};
2626

27-
type MissingReason =
27+
export type MissingReason =
2828
| {
2929
Master: {
3030
pr: number;
@@ -34,6 +34,7 @@ type MissingReason =
3434
}
3535
| {
3636
Try: {
37+
pr: number;
3738
parent_sha: string;
3839
include: string | null;
3940
exclude: string | null;

site/frontend/src/pages/status/page.vue

Lines changed: 60 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {getJson} from "../../utils/requests";
33
import {STATUS_DATA_URL} from "../../urls";
44
import {withLoading} from "../../utils/loading";
55
import {computed, ref, Ref} from "vue";
6-
import {StatusResponse} from "./data";
6+
import {Artifact, Commit, MissingReason, StatusResponse} from "./data";
77
88
async function loadStatus(loading: Ref<boolean>) {
99
data.value = await withLoading(loading, () =>
@@ -28,20 +28,47 @@ function formatDuration(seconds: number): string {
2828
return s;
2929
}
3030
31-
function commitUrl(commit: {sha: string}): string {
32-
return `<a href="https://github.com/rust-lang/rust/commit/${
33-
commit.sha
34-
}">${commit.sha.substring(0, 13)}</a>`;
31+
function getArtifactPr(reason: MissingReason): number {
32+
if (reason.hasOwnProperty("InProgress")) {
33+
return getArtifactPr(reason["InProgress"]);
34+
} else if (reason.hasOwnProperty("Master")) {
35+
return reason["Master"].pr;
36+
} else if (reason.hasOwnProperty("Try")) {
37+
return reason["Try"].pr;
38+
} else {
39+
throw new Error(`Unknown missing reason ${reason}`);
40+
}
3541
}
3642
37-
function formatArtifact(artifact: any): string {
38-
if (artifact.Commit) {
39-
return commitUrl(artifact.Commit);
43+
function getArtifactSha(artifact: Artifact): string {
44+
if (artifact.hasOwnProperty("Commit")) {
45+
return artifact["Commit"].sha;
46+
} else if (artifact.hasOwnProperty("Tag")) {
47+
return artifact["Tag"];
4048
} else {
41-
return artifact.Tag;
49+
throw new Error(`Unknown artifact ${artifact}`);
4250
}
4351
}
4452
53+
function commitUrlAsHtml(sha: string): string {
54+
return `<a href="https://github.com/rust-lang/rust/commit/${sha}">${sha.substring(
55+
0,
56+
13
57+
)}</a>`;
58+
}
59+
60+
function pullRequestUrlAsHtml(pr: number): string {
61+
return `<a href="https://github.com/rust-lang/rust/pull/${pr}">#${pr}</a>`;
62+
}
63+
64+
function formatCommitAsHtml(commit: Commit, reason: MissingReason): string {
65+
const url = commitUrlAsHtml(commit.sha);
66+
const type = commit.type === "Try" ? "try" : "master";
67+
const pr = getArtifactPr(reason);
68+
69+
return `${pullRequestUrlAsHtml(pr)} (${type}): ${url}`;
70+
}
71+
4572
function formatReason(reason: any): string {
4673
if (typeof reason == "string") {
4774
return reason;
@@ -81,6 +108,20 @@ const timeLeft = computed(() => {
81108
const recentEndDate = computed(() => {
82109
return new Date(data.value.most_recent_end * 1000);
83110
});
111+
const currentCommitAndReason: Ref<[Commit, MissingReason] | null> = computed(
112+
() => {
113+
const current = data.value?.current ?? null;
114+
if (current === null) return null;
115+
const sha = getArtifactSha(current.artifact);
116+
117+
for (const [commit, reason] of data.value.missing) {
118+
if (commit.sha === sha && reason.hasOwnProperty("InProgress")) {
119+
return [commit, reason["InProgress"]];
120+
}
121+
}
122+
return null;
123+
}
124+
);
84125
85126
const loading = ref(true);
86127
@@ -94,7 +135,15 @@ loadStatus(loading);
94135
<div v-if="data.current !== null">
95136
<p>
96137
Currently benchmarking:
97-
<span v-html="formatArtifact(data.current.artifact)"></span>.<br />
138+
<span
139+
v-html="
140+
formatCommitAsHtml(
141+
currentCommitAndReason[0],
142+
currentCommitAndReason[1]
143+
)
144+
"
145+
></span
146+
>.<br />
98147
Time left: {{ formatDuration(timeLeft) }}
99148
</p>
100149
<table>
@@ -164,7 +213,7 @@ loadStatus(loading);
164213
<tbody>
165214
<tr v-for="[commit, reason] in data.missing">
166215
<td>{{ new Date(commit.date).toLocaleString() }}</td>
167-
<td v-html="commitUrl(commit)"></td>
216+
<td v-html="commitUrlAsHtml(commit.sha)"></td>
168217
<td v-html="formatReason(reason)"></td>
169218
</tr>
170219
</tbody>

0 commit comments

Comments
 (0)