From 7bafe2e7cbdcb8a1b797e2ecc42f90f7e8c4e845 Mon Sep 17 00:00:00 2001 From: Sakibul Islam Date: Fri, 13 Jun 2025 11:11:09 +0100 Subject: [PATCH 01/14] Add base styles --- templates/base.html | 152 ++++++++++++++++++++++++++++++++++++++- templates/help.html | 28 +------- templates/not_found.html | 19 +++-- templates/queue.html | 140 +++++++++++++++++++----------------- 4 files changed, 239 insertions(+), 100 deletions(-) diff --git a/templates/base.html b/templates/base.html index 438eb070..33af2f96 100644 --- a/templates/base.html +++ b/templates/base.html @@ -4,9 +4,159 @@ {% block title %}{% endblock %} + + + + {% block head %}{% endblock %} {% block body %}{% endblock %} - \ No newline at end of file + diff --git a/templates/help.html b/templates/help.html index 9f0316bf..67d2a50a 100644 --- a/templates/help.html +++ b/templates/help.html @@ -4,32 +4,6 @@ {% block head %} {% endblock %} {% block body %} -

Page not found

-

Go back to the index

+
+

Page not found

+

Go back to the index

+
{% endblock %} diff --git a/templates/queue.html b/templates/queue.html index b61fb9d9..bfc6843c 100644 --- a/templates/queue.html +++ b/templates/queue.html @@ -4,82 +4,90 @@ {% block head %} {% endblock %} {% block body %} -

- Bors queue - {{ repo_name }} - {% if tree_state.is_closed() %} - {% if let Some(comment_source) = tree_state.comment_source() %} - {% if let Some(priority) = tree_state.priority() %} - [TREECLOSED below priority {{ priority }}] +
+

+ Bors queue - {{ repo_name }} + {% if tree_state.is_closed() %} + {% if let Some(comment_source) = tree_state.comment_source() %} + {% if let Some(priority) = tree_state.priority() %} + [TREECLOSED below priority {{ priority }}] + {% endif %} {% endif %} {% endif %} - {% endif %} -

+

-

- {{ stats.total_count }} total, {{ stats.approved_count }} approved, - {{ stats.rolled_up_count }} rolled up -

+

+ {{ stats.total_count }} total, {{ stats.approved_count }} approved, + {{ stats.rolled_up_count }} rolled up +

- - - - - - - - - - - - +
#StatusMergeableTitleAuthorAssigneesApproved byPriorityRollup
+ + + + + + + + + + + - - {% for pr in prs %} - - - + {% for pr in prs %} + + + - - - - - - - - - {% endfor %} - -
#StatusMergeableTitleAuthorAssigneesApproved byPriorityRollup
- {{ pr.number.0 }} - - {% if let Some(try_build) = pr.try_build %} - {{ try_build.status }} (try) - {% else %} - {% if pr.is_approved() %} - approved +
+ {{ pr.number.0 }} + + {% if let Some(try_build) = pr.try_build %} + {{ try_build.status }} (try) + {% else %} + {% if pr.is_approved() %} + approved + {% endif %} {% endif %} - {% endif %} - - {% match pr.mergeable_state %} - {% when Mergeable %} - yes - {% when HasConflicts %} - no - {% when Unknown %} - {% endmatch %} - {{ pr.title }}{{ pr.author }}{{ pr.assignees|join(", ") }} - {% if let Some(approver) = pr.approver() %} - {{ approver }} - {% endif %} - {{ pr.priority.unwrap_or(0) }} - {% if let Some(rollup) = pr.rollup %} - {{ rollup }} - {% endif %} -
+ + + {% match pr.mergeable_state %} + {% when Mergeable %} + yes + {% when HasConflicts %} + no + {% when Unknown %} + {% endmatch %} + + {{ pr.title }} + {{ pr.author }} + {{ pr.assignees|join(", ") }} + + {% if let Some(approver) = pr.approver() %} + {{ approver }} + {% endif %} + + {{ pr.priority.unwrap_or(0) }} + + {% if let Some(rollup) = pr.rollup %} + {{ rollup }} + {% endif %} + + + {% endfor %} + + + {% endblock %} From c5d0922e9aeca95d781381a69ff16d5b9e3df8f7 Mon Sep 17 00:00:00 2001 From: Sakibul Islam Date: Fri, 13 Jun 2025 11:23:26 +0100 Subject: [PATCH 02/14] Add queue page design --- templates/base.html | 4 +- templates/help.html | 226 +++++++++++++++++++++++---------------- templates/not_found.html | 2 - templates/queue.html | 4 - 4 files changed, 136 insertions(+), 100 deletions(-) diff --git a/templates/base.html b/templates/base.html index 33af2f96..e4734516 100644 --- a/templates/base.html +++ b/templates/base.html @@ -21,6 +21,7 @@ body { display: flex; justify-content: center; + padding: var(--space-m); line-height: 1.5; font-family: "Fira Sans", sans-serif; @@ -76,7 +77,7 @@ --text-2xl: 1.5rem; --text-3xl: 1.875rem; - /* Border radius */ + /* Radius */ --radius-sm: 0.25rem; } @@ -143,6 +144,7 @@ } /* Tables */ + table { font-size: var(--text-sm); border-collapse: collapse; diff --git a/templates/help.html b/templates/help.html index 67d2a50a..3342c1f5 100644 --- a/templates/help.html +++ b/templates/help.html @@ -1,109 +1,149 @@ {% extends "base.html" %} -{% block title %}Bors{% endblock %} +{% block title %}Help - Bors{% endblock %} {% block head %} -{% endblock %} + main { + max-width: 50rem; + } -{% block body %} -
-

Bors

+ table { + margin-block: var(--space-m); + } -

Repositories

+ tbody tr:last-child td { + border-bottom: none; + } -
    - {% for repo in repos %} -
  • - {{ repo.name }} - {% if repo.treeclosed %} [TREECLOSED] {% endif %} -
  • - {% endfor %} -
+ th, + td { + padding: var(--space-xs) var(--space-s); + border-bottom: 1px solid var(--color-border-muted); + word-break: break-all; + overflow-wrap: break-word; + } -
+ th { + background-color: var(--color-bg-higlight); + } -

Bors Cheatsheet

+ ul { + margin-block: var(--space-s); + padding-inline-start: var(--space-m); + } -

Commands

+ li { + margin-block-end: var(--space-2xs); + } + +{% endblock %} + +{% block body %} +
+

Bors

-

- Here's a quick reference for the commands bors accepts. Commands must be - posted as comments on the PR they refer to. Comments may include - multiple commands. Bors will only listen to official reviewers that it - is configured to listen to. A comment must mention the GitHub account - bors is configured to use (e.g. for the Rust project this is - @bors). -

+

Repositories

+
    + {% for repo in repos %} +
  • + {{ repo.name }} + {% if repo.treeclosed %} [TREECLOSED] {% endif %} +
  • + {% endfor %} +
-
    -
  • info: Get information about the current PR.
  • -
  • - ping: Send a ping to bors to check that it responds. -
  • -
  • help: Print help message with available commands.
  • -
  • - rollup=<never|iffy|maybe|always>: Mark the PR as - "always", "maybe", "iffy", or "never" rollup-able. -
  • -
  • rollup: Short for rollup=always.
  • -
  • rollup-: Short for rollup=maybe.
  • -
  • - p=<priority>: Set the priority of the approved PR - (defaults to 0). -
  • -
  • - r=<user>: Approve a PR on behalf of specified user. -
  • -
  • r+: Approve a PR.
  • -
  • r-: Unapprove a PR.
  • -
  • - try: Start a try build based on the most recent commit - from the main branch. -
  • -
  • - try parent=<sha>: Start a try build based on the - specified parent commit. -
  • -
  • - try parent=last: Start a try build based on the parent - commit of the last try build. -
  • -
  • - try jobs=<job1,job2,...>: Start a try build with - specific CI jobs (up to 10). -
  • -
  • try cancel: Cancel a running try build.
  • -
  • - delegate=<try|review>: Delegate try or review - permissions to the PR author. -
  • -
  • - delegate+: Delegate review permissions to the PR author. -
  • -
  • - delegate-: Remove any previously granted delegation. -
  • -
+

Commands

+

Commands must be posted as comments on the PR and mention the bot account (e.g. @bors).

-

Examples

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
CommandDescription
infoGet information about the current PR
pingSend a ping to bors to check responsiveness
helpPrint help message with available commands
rollup=<never|iffy|maybe|always>Mark the PR as "always", "maybe", "iffy", or "never" rollup-able
rollupShort for rollup=always
rollup-Short for rollup=maybe
p=<priority>Set the priority of the approved PR (defaults to 0)
r=<user>Approve the PR on behalf of the specified user
r+Approve the PR and add it to the merge queue
r-Reject the PR and remove it from the merge queue
retryRetry the failed build
retry-Cancel the retry
tryRun the build without merging
try-Cancel the try build
delegate=Delegate approval authority to another user
delegate-Remove delegated approval authority
treeclosed=Close the tree to new PRs
treeclosed-Reopen the tree to new PRs
-
    -
  • @bors r+ p=1
  • -
  • @bors try parent=abcd123
  • -
  • @bors rollup=always
  • -
  • @bors delegate=review
  • -
  • @bors delegate=try
  • -
  • - @bors try @rust-timer queue: Short-hand for compile-perf - benchmarking of PRs. -
  • -
-
+

Examples

+ + {% endblock %} diff --git a/templates/not_found.html b/templates/not_found.html index f7525ce2..ec032942 100644 --- a/templates/not_found.html +++ b/templates/not_found.html @@ -7,9 +7,7 @@ main { display: flex; flex-direction: column; - justify-content: center; align-items: center; - min-height: 100vh; margin: 0; text-align: center; } diff --git a/templates/queue.html b/templates/queue.html index bfc6843c..9c5e693d 100644 --- a/templates/queue.html +++ b/templates/queue.html @@ -4,13 +4,9 @@ {% block head %} From dd851c6eb405e50a7b0d8e13d94cbd8885cf94a6 Mon Sep 17 00:00:00 2001 From: Sakibul Islam Date: Fri, 13 Jun 2025 15:07:08 +0100 Subject: [PATCH 03/14] Use `cmd_prefix` in help.html --- src/bin/bors.rs | 3 ++- src/github/server.rs | 12 +++++++++++- src/github/webhook.rs | 2 ++ src/templates.rs | 1 + src/tests/mocks/bors.rs | 5 +++++ src/tests/mocks/mod.rs | 1 + templates/help.html | 8 ++++---- 7 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/bin/bors.rs b/src/bin/bors.rs index 75536df2..91bf1239 100644 --- a/src/bin/bors.rs +++ b/src/bin/bors.rs @@ -131,7 +131,7 @@ fn try_main(opts: Opts) -> anyhow::Result<()> { let db = Arc::new(db); let ctx = BorsContext::new( - CommandParser::new(opts.cmd_prefix), + CommandParser::new(opts.cmd_prefix.clone()), db.clone(), repos.clone(), ); @@ -184,6 +184,7 @@ fn try_main(opts: Opts) -> anyhow::Result<()> { WebhookSecret::new(opts.webhook_secret), repos, db, + opts.cmd_prefix.clone(), ); let server_process = webhook_server(state); diff --git a/src/github/server.rs b/src/github/server.rs index 241d1b48..e4e0a0e1 100644 --- a/src/github/server.rs +++ b/src/github/server.rs @@ -41,6 +41,7 @@ pub struct ServerState { webhook_secret: WebhookSecret, repositories: HashMap>, db: Arc, + cmd_prefix: String, } impl ServerState { @@ -50,6 +51,7 @@ impl ServerState { webhook_secret: WebhookSecret, repositories: HashMap>, db: Arc, + cmd_prefix: String, ) -> Self { Self { repository_event_queue, @@ -57,12 +59,17 @@ impl ServerState { webhook_secret, repositories, db, + cmd_prefix, } } pub fn get_webhook_secret(&self) -> &WebhookSecret { &self.webhook_secret } + + pub fn get_cmd_prefix(&self) -> &str { + &self.cmd_prefix + } } pub type ServerStateRef = Arc; @@ -113,7 +120,10 @@ async fn help_handler(State(state): State) -> impl IntoResponse }); } - HtmlTemplate(HelpTemplate { repos }) + HtmlTemplate(HelpTemplate { + repos, + cmd_prefix: state.get_cmd_prefix().to_string(), + }) } async fn queue_handler( diff --git a/src/github/webhook.rs b/src/github/webhook.rs index 2e712c3a..44978f2d 100644 --- a/src/github/webhook.rs +++ b/src/github/webhook.rs @@ -513,6 +513,7 @@ mod tests { use crate::github::webhook::GitHubWebhook; use crate::github::webhook::WebhookSecret; use crate::tests::io::load_test_file; + use crate::tests::mocks::default_cmd_prefix; use crate::tests::webhook::{TEST_WEBHOOK_SECRET, create_webhook_request}; #[tokio::test] @@ -1613,6 +1614,7 @@ mod tests { WebhookSecret::new(TEST_WEBHOOK_SECRET.to_string()), repos, db, + default_cmd_prefix(), )); GitHubWebhook::from_request(request, &server_ref).await } diff --git a/src/templates.rs b/src/templates.rs index 0a51750a..b0904007 100644 --- a/src/templates.rs +++ b/src/templates.rs @@ -25,6 +25,7 @@ where #[template(path = "help.html")] pub struct HelpTemplate { pub repos: Vec, + pub cmd_prefix: String, } pub struct RepositoryView { diff --git a/src/tests/mocks/bors.rs b/src/tests/mocks/bors.rs index 450120cb..cc9c0e2c 100644 --- a/src/tests/mocks/bors.rs +++ b/src/tests/mocks/bors.rs @@ -30,6 +30,10 @@ use crate::tests::mocks::workflow::{ CheckSuite, GitHubCheckRunEventPayload, GitHubCheckSuiteEventPayload, GitHubWorkflowEventPayload, TestWorkflowStatus, Workflow, WorkflowEvent, WorkflowEventKind, }; + +pub fn default_cmd_prefix() -> String { + "@bors".to_string() +} use crate::tests::mocks::{ Branch, ExternalHttpMock, GitHubState, Repo, User, default_pr_number, default_repo_name, }; @@ -142,6 +146,7 @@ impl BorsTester { WebhookSecret::new(TEST_WEBHOOK_SECRET.to_string()), repos.clone(), db.clone(), + default_cmd_prefix(), ); let app = create_app(state); let bors = tokio::spawn(bors_process); diff --git a/src/tests/mocks/mod.rs b/src/tests/mocks/mod.rs index cf65a765..2e292d5e 100644 --- a/src/tests/mocks/mod.rs +++ b/src/tests/mocks/mod.rs @@ -13,6 +13,7 @@ use crate::tests::mocks::github::GitHubMockServer; use crate::tests::mocks::permissions::TeamApiMockServer; pub use bors::BorsBuilder; +pub use bors::default_cmd_prefix; pub use bors::run_test; pub use comment::Comment; pub use permissions::Permissions; diff --git a/templates/help.html b/templates/help.html index 3342c1f5..b6f3bd4a 100644 --- a/templates/help.html +++ b/templates/help.html @@ -54,7 +54,7 @@

Repositories

Commands

-

Commands must be posted as comments on the PR and mention the bot account (e.g. @bors).

+

Commands must be posted as comments on the PR and mention the bot account ({{ cmd_prefix }}).

@@ -141,9 +141,9 @@

Commands

Examples

    -
  • @bors r+ p=1
  • -
  • @bors try parent=abc123
  • -
  • @bors try @rust-timer queue: Short-hand for compile-perf benchmarking of PRs.
  • +
  • {{ cmd_prefix }} r+ p=1
  • +
  • {{ cmd_prefix }} try parent=abc123
  • +
  • {{ cmd_prefix }} try @rust-timer queue: Short-hand for compile-perf benchmarking of PRs.
{% endblock %} From ea1a9ba9ad37d011f0e6c84ddad0b61af579039b Mon Sep 17 00:00:00 2001 From: Sakibul Islam Date: Fri, 13 Jun 2025 15:11:08 +0100 Subject: [PATCH 04/14] Increase page content width --- templates/help.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/templates/help.html b/templates/help.html index b6f3bd4a..57363716 100644 --- a/templates/help.html +++ b/templates/help.html @@ -5,7 +5,8 @@ {% block head %} {% block head %}{% endblock %} diff --git a/templates/help.html b/templates/help.html index 307eb0ff..25d5e4df 100644 --- a/templates/help.html +++ b/templates/help.html @@ -13,6 +13,11 @@ margin-block: var(--space-m); } + .table-wrapper { + overflow-x: auto; + margin-block: var(--space-m); + } + tbody tr:last-child td { border-bottom: none; } @@ -21,8 +26,7 @@ td { padding: var(--space-xs) var(--space-s); border-bottom: 1px solid var(--color-border-muted); - word-break: break-all; - overflow-wrap: break-word; + white-space: nowrap; } th { @@ -57,88 +61,109 @@

Repositories

Commands

Commands must be posted as comments on the PR and mention the bot account ({{ cmd_prefix }}).

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CommandDescription
infoGet information about the current PR
pingSend a ping to bors to check responsiveness
helpPrint help message with available commands
rollup=<never|iffy|maybe|always>Mark the PR as "always", "maybe", "iffy", or "never" rollup-able
rollupShort for rollup=always
rollup-Short for rollup=maybe
p=<priority>Set the priority of the approved PR (defaults to 0)
r=<user>Approve the PR on behalf of the specified user
r+Approve the PR and add it to the merge queue
r-Reject the PR and remove it from the merge queue
retryRetry the failed build
retry-Cancel the retry
tryRun the build without merging
try-Cancel the try build
delegate+Delegate approval authority to another user
delegate-Remove delegated approval authority
treeclosed=Close the tree to new PRs
treeclosed-Reopen the tree to new PRs
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
CommandPermissionsDescription
infoGet information about the current PR
pingSend a ping to bors to check responsiveness
helpPrint help message with available commands
rollup=<never|iffy|maybe|always>reviewMark the PR as "always", "maybe", "iffy", or "never" rollup-able
rollupreviewShort for rollup=always
rollup-reviewShort for rollup=maybe
p=<priority>reviewSet the priority of the approved PR (defaults to 0)
r=<user>reviewApprove the PR on behalf of the specified user
r+reviewApprove the PR and add it to the merge queue
r-reviewReject the PR and remove it from the merge queue
retryreviewRetry the failed build
retry-reviewCancel the retry
trytryRun the build without merging
try-tryCancel the try build
delegate+reviewDelegate approval authority to another user
delegate-reviewRemove delegated approval authority
treeclosed=reviewClose the tree to new PRs
treeclosed-reviewReopen the tree to new PRs
+

Examples

    From ddb54548bdcc64f315b87606e9d3fc318bd86b78 Mon Sep 17 00:00:00 2001 From: Sakibul Islam Date: Fri, 13 Jun 2025 16:20:30 +0100 Subject: [PATCH 09/14] Decrease help page max-width just a little --- templates/help.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/help.html b/templates/help.html index 25d5e4df..b2456e4f 100644 --- a/templates/help.html +++ b/templates/help.html @@ -5,7 +5,7 @@ {% block head %}