Skip to content

Commit 2aaad35

Browse files
authored
Merge pull request #2098 from Urgau/gha-logs-improv-all
Bunch of improvements and fixes around our GHA logs viewer
2 parents a4795fb + f0d576b commit 2aaad35

File tree

4 files changed

+18
-8
lines changed

4 files changed

+18
-8
lines changed

src/gha_logs.rs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,12 @@ async fn process_logs(
130130

131131
let html = format!(
132132
r###"<!DOCTYPE html>
133-
<html>
133+
<html lang="en" translate="no">
134134
<head>
135-
<title>{log_uuid} - triagebot</title>
136135
<meta charset="UTF-8">
137136
<meta name="viewport" content="width=device-width, initial-scale=1.0">
138-
<link rel="icon" sizes="32x32" type="image/png" href="https://rust-lang.org/static/images/favicon-32x32.png">
137+
<title>{log_id} - {owner}/{repo}</title>
138+
<link rel="icon" sizes="32x32" type="image/png" href="https://www.rust-lang.org/static/images/favicon-32x32.png">
139139
<style>
140140
body {{
141141
font: 14px SFMono-Regular, Consolas, Liberation Mono, Menlo, monospace;
@@ -144,14 +144,18 @@ async fn process_logs(
144144
white-space: pre;
145145
}}
146146
.timestamp {{
147-
color: unset;
147+
color: #848484;
148148
text-decoration: none;
149149
}}
150150
.timestamp:hover {{
151151
text-decoration: underline;
152152
}}
153153
.error-marker {{
154154
scroll-margin-bottom: 15vh;
155+
color: #e5534b;
156+
}}
157+
.warning-marker {{
158+
color: #c69026;
155159
}}
156160
</style>
157161
<script type="module" nonce="{nonce}">
@@ -179,6 +183,11 @@ async fn process_logs(
179183
html = html.replace(/##\[error\]/g, () =>
180184
`<a id="error-${{++errorCounter}}" class="error-marker">##[error]</a>`
181185
);
186+
187+
// 4.b Add a span around every "##[warning]" string
188+
html = html.replace(/##\[warning\]/g, () =>
189+
`<span class="warning-marker">##[warning]</span>`
190+
);
182191
183192
// 5. Add the html to the DOM
184193
var cdiv = document.getElementById("console");
@@ -207,7 +216,9 @@ async fn process_logs(
207216
.header(CONTENT_TYPE, "text/html; charset=utf-8")
208217
.header(
209218
CONTENT_SECURITY_POLICY,
210-
format!("script-src 'nonce-{nonce}' {ANSI_UP_URL}"),
219+
format!(
220+
"default-src 'none'; script-src 'nonce-{nonce}' 'self'; style-src 'unsafe-inline'; img-src www.rust-lang.org"
221+
),
211222
)
212223
.body(Body::from(html))?);
213224
}

src/gha_logs/ansi_up@6.0.6.min.js

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/github.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ impl GithubClient {
9292
req: Request,
9393
sleep: Duration,
9494
remaining_attempts: u32,
95-
) -> BoxFuture<Result<Response, reqwest::Error>> {
95+
) -> BoxFuture<'_, Result<Response, reqwest::Error>> {
9696
#[derive(Debug, serde::Deserialize)]
9797
struct RateLimit {
9898
#[allow(unused)]

src/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::borrow::Cow;
22

33
/// Pluralize (add an 's' sufix) to `text` based on `count`.
4-
pub fn pluralize(text: &str, count: usize) -> Cow<str> {
4+
pub fn pluralize(text: &str, count: usize) -> Cow<'_, str> {
55
if count == 1 {
66
text.into()
77
} else {

0 commit comments

Comments
 (0)