Skip to content

Help page redesign #312

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Jun 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 0 additions & 27 deletions docs/commands.md

This file was deleted.

6 changes: 6 additions & 0 deletions docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@ $ cargo sqlx prepare -- --all-targets

After that, you should commit the changes to the `.sqlx` directory.

## Updating commands
When modifying commands, make sure to update both:

1. The help page in `templates/help.html`
2. The `@bors help` command output in `src/bors/handlers/help.rs`

## Logs in tests
By default, logs are disabled in tests. To enable them, add `#[traced_test]`
on top of the test function.
Expand Down
3 changes: 2 additions & 1 deletion src/bin/bors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
);
Expand Down Expand Up @@ -184,6 +184,7 @@ fn try_main(opts: Opts) -> anyhow::Result<()> {
WebhookSecret::new(opts.webhook_secret),
repos,
db,
opts.cmd_prefix,
);
let server_process = webhook_server(state);

Expand Down
4 changes: 4 additions & 0 deletions src/bors/command/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ impl FromStr for RollupMode {
}

/// Bors command specified by a user.
///
/// When modifying commands, remember to also update:
/// - `templates/help.html` (HTML help page)
/// - `src/bors/handlers/help.rs` (the `@bors help` command output)
#[derive(Debug, PartialEq)]
pub enum BorsCommand {
/// Approve a commit.
Expand Down
4 changes: 4 additions & 0 deletions src/bors/handlers/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ You can use the following commands:
- `r-`: Unapprove this PR
- `p=<priority>` or `priority=<priority>`: Set the priority of this PR
- `rollup=<never|iffy|maybe|always>`: Set the rollup status of the PR
- `rollup`: Short for `rollup=always`
- `rollup-`: Short for `rollup=maybe`
- `delegate=<try|review>`: Delegate permissions for running try builds or approving to the PR author
- `try` allows the PR author to start try builds.
- `review` allows the PR author to both start try builds and approve the PR.
Expand Down Expand Up @@ -95,6 +97,8 @@ mod tests {
- `r-`: Unapprove this PR
- `p=<priority>` or `priority=<priority>`: Set the priority of this PR
- `rollup=<never|iffy|maybe|always>`: Set the rollup status of the PR
- `rollup`: Short for `rollup=always`
- `rollup-`: Short for `rollup=maybe`
- `delegate=<try|review>`: Delegate permissions for running try builds or approving to the PR author
- `try` allows the PR author to start try builds.
- `review` allows the PR author to both start try builds and approve the PR.
Expand Down
12 changes: 11 additions & 1 deletion src/github/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ pub struct ServerState {
webhook_secret: WebhookSecret,
repositories: HashMap<GithubRepoName, Arc<RepositoryState>>,
db: Arc<PgDbClient>,
cmd_prefix: String,
}

impl ServerState {
Expand All @@ -50,19 +51,25 @@ impl ServerState {
webhook_secret: WebhookSecret,
repositories: HashMap<GithubRepoName, Arc<RepositoryState>>,
db: Arc<PgDbClient>,
cmd_prefix: String,
) -> Self {
Self {
repository_event_queue,
global_event_queue,
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<ServerState>;
Expand Down Expand Up @@ -113,7 +120,10 @@ async fn help_handler(State(state): State<ServerStateRef>) -> impl IntoResponse
});
}

HtmlTemplate(HelpTemplate { repos })
HtmlTemplate(HelpTemplate {
repos,
cmd_prefix: state.get_cmd_prefix().to_string(),
})
}

async fn queue_handler(
Expand Down
2 changes: 2 additions & 0 deletions src/github/webhook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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
}
Expand Down
1 change: 1 addition & 0 deletions src/templates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ where
#[template(path = "help.html")]
pub struct HelpTemplate {
pub repos: Vec<RepositoryView>,
pub cmd_prefix: String,
}

pub struct RepositoryView {
Expand Down
5 changes: 5 additions & 0 deletions src/tests/mocks/bors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/tests/mocks/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
160 changes: 159 additions & 1 deletion templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,167 @@
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>{% block title %}{% endblock %}</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Fira+Sans:ital,wght@0,300;0,400;0,500;0,600;0,700;1,300;1,400;1,500;1,600;1,700&family=Fira+Mono:wght@400;500;700&display=swap" rel="stylesheet">
<style>
*,
*::before,
*::after {
box-sizing: border-box;
}

* {
margin: 0;
}

body {
display: flex;
justify-content: center;
padding: var(--space-m);

line-height: 1.5;
font-family: "Fira Sans", sans-serif;
/* Improve text rendering for macOS */
-webkit-font-smoothing: antialiased;
}

html {
font-size: clamp(14px, 2.5vw, 16px);
}

input, button, textarea, select {
font: inherit;
}

/* Avoid text overflow */
p, h1, h2, h3, h4, h5, h6 {
overflow-wrap: break-word;
}

/* Improve line wrapping */
h1, h2, h3, h4, h5, h6 {
text-wrap: balance;
}

:root {
/* Spacing */
--space-4xs: 0.125rem;
--space-3xs: 0.25rem;
--space-2xs: 0.5rem;
--space-xs: 0.75rem;
--space-s: 1rem;
--space-m: 1.5rem;

/* Color palette */
--color-primary: #28607f;
--color-primary-hover: #3a7ba8;
--color-primary-active: #1e2650;

/* Code */
--color-code-bg: #f6f8fa;
--color-code-text: #383838;

/* Neutral colors */
--color-border-muted: #e1e4e8;
--color-text-muted: #a8b2bb;
--color-bg-higlight: #fafafa;

/* Typography */
--text-sm: 0.875rem;
--text-base: 1rem;
--text-lg: 1.125rem;
--text-xl: 1.25rem;
--text-2xl: 1.5rem;
--text-3xl: 1.875rem;

/* Radius */
--radius-sm: 0.25rem;
}

/* Typography */

h1 {
font-size: clamp(var(--text-2xl), 4vw, var(--text-3xl));
font-weight: 600;
line-height: 1.2;
margin-block-end: var(--space-s);
}

h2 {
font-size: clamp(var(--text-xl), 3vw, var(--text-2xl));
font-weight: 600;
line-height: 1.3;
margin-block: var(--space-m) var(--space-xs);
}

h3 {
font-size: clamp(var(--text-lg), 2.5vw, var(--text-xl));
font-weight: 500;
line-height: 1.4;
margin-block: var(--space-s) var(--space-2xs);
}

p {
font-size: var(--text-base);
margin-block-end: var(--space-s);
}

/* Links */

a {
color: var(--color-primary);
text-decoration: none;
}

a:hover {
color: var(--color-primary-hover);
text-decoration: underline;
}

a:active {
color: var(--color-primary-active);
}

a:focus-visible {
outline: 2px solid var(--color-primary);
outline-offset: 2px;
border-radius: var(--radius-sm);
}

code {
font-family: "Fira Mono", monospace;
font-size: var(--text-sm);
font-weight: 400;
background-color: var(--color-code-bg);
color: var(--color-code-text);
padding: var(--space-4xs) var(--space-3xs);
border-radius: var(--radius-sm);
overflow-wrap: break-word;
tab-size: 4;
}

/* Tables */

table {
font-size: var(--text-sm);
border-collapse: collapse;
inline-size: 100%;
}

th {
font-weight: 600;
text-align: start;
}

.empty::before {
content: "-";
color: var(--color-text-muted);
}
</style>
{% block head %}{% endblock %}
</head>
<body>
{% block body %}{% endblock %}
</body>
</html>
</html>
Loading