Skip to content

Commit 11276aa

Browse files
Nest CLA Assistant retry command (#5313)
## Summary - Move `cargo ci retry-cla-assistant` under `cargo ci cla-assistant retry`. - Rename the helper module to `cla_assistant.rs`. - Update the Retry CLA Assistant workflow and generated `cargo ci` docs. ## Verification - `cargo fmt --all` - `cargo check -p ci` - `cargo ci self-docs --check` - `git diff --check` Co-authored-by: clockwork-labs-bot <clockwork-labs-bot@users.noreply.github.com>
1 parent dc20faa commit 11276aa

4 files changed

Lines changed: 48 additions & 11 deletions

File tree

.github/workflows/retry-cla-assistant.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,6 @@ jobs:
7777
run: |
7878
while read -r pr_number; do
7979
if [ -n "${pr_number}" ]; then
80-
cargo ci retry-cla-assistant --pr-number "${pr_number}"
80+
cargo ci cla-assistant retry --pr-number "${pr_number}"
8181
fi
8282
done < "${{ steps.prs.outputs.path }}"

tools/ci/README.md

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,11 +254,22 @@ Usage: docs
254254

255255
- `--help`: Print help
256256

257-
### `retry-cla-assistant`
257+
### `cla-assistant`
258258

259259
**Usage:**
260260
```bash
261-
Usage: retry-cla-assistant [OPTIONS] --pr-number <PR_NUMBER>
261+
Usage: cla-assistant <COMMAND>
262+
```
263+
264+
**Options:**
265+
266+
- `--help`: Print help
267+
268+
#### `retry`
269+
270+
**Usage:**
271+
```bash
272+
Usage: retry [OPTIONS] --pr-number <PR_NUMBER>
262273
```
263274

264275
**Options:**
@@ -267,6 +278,17 @@ Usage: retry-cla-assistant [OPTIONS] --pr-number <PR_NUMBER>
267278
- `--repo <REPO>`: Repository in `owner/name` form. Defaults to GITHUB_REPOSITORY
268279
- `--help`: Print help
269280

281+
#### `help`
282+
283+
**Usage:**
284+
```bash
285+
Usage: help [COMMAND]...
286+
```
287+
288+
**Options:**
289+
290+
- `subcommand <COMMAND>`: Print help for the subcommand(s)
291+
270292
### `help`
271293

272294
**Usage:**
Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,22 @@ use std::collections::BTreeMap;
22
use std::env;
33

44
use anyhow::{anyhow, bail, Context, Result};
5-
use clap::Args;
5+
use clap::{Args, Subcommand};
66
use reqwest::blocking::Client;
77
use reqwest::header::{HeaderMap, HeaderValue, ACCEPT, AUTHORIZATION, USER_AGENT};
88
use serde::de::DeserializeOwned;
99
use serde::Deserialize;
1010

1111
const CLA_CONTEXT: &str = "license/cla";
1212

13+
#[derive(Subcommand)]
14+
pub(crate) enum ClaAssistantCmd {
15+
/// Retries CLA Assistant if `license/cla` is the only remaining PR blocker.
16+
Retry(RetryArgs),
17+
}
18+
1319
#[derive(Args)]
14-
pub(crate) struct RetryClaAssistantArgs {
20+
pub(crate) struct RetryArgs {
1521
/// Pull request number to check.
1622
#[arg(long)]
1723
pub(crate) pr_number: u64,
@@ -21,7 +27,13 @@ pub(crate) struct RetryClaAssistantArgs {
2127
pub(crate) repo: Option<String>,
2228
}
2329

24-
pub(crate) fn run(args: RetryClaAssistantArgs) -> Result<()> {
30+
pub(crate) fn run(cmd: ClaAssistantCmd) -> Result<()> {
31+
match cmd {
32+
ClaAssistantCmd::Retry(args) => retry(args),
33+
}
34+
}
35+
36+
fn retry(args: RetryArgs) -> Result<()> {
2537
let repo = args
2638
.repo
2739
.or_else(|| env::var("GITHUB_REPOSITORY").ok())

tools/ci/src/main.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ use std::{env, fs};
1313
const README_PATH: &str = "tools/ci/README.md";
1414

1515
mod ci_docs;
16+
mod cla_assistant;
1617
mod keynote_bench;
17-
mod retry_cla_assistant;
1818
mod smoketest;
1919
mod util;
2020

@@ -368,8 +368,11 @@ enum CiCmd {
368368
VersionUpgradeCheck,
369369
/// Builds the docs site.
370370
Docs,
371-
/// Retries CLA Assistant if `license/cla` is the only remaining PR blocker.
372-
RetryClaAssistant(retry_cla_assistant::RetryClaAssistantArgs),
371+
/// Interacts with CLA Assistant.
372+
ClaAssistant {
373+
#[command(subcommand)]
374+
cmd: cla_assistant::ClaAssistantCmd,
375+
},
373376
}
374377

375378
fn run_all_clap_subcommands(skips: &[String]) -> Result<()> {
@@ -775,8 +778,8 @@ fn main() -> Result<()> {
775778
run_docs_build()?;
776779
}
777780

778-
Some(CiCmd::RetryClaAssistant(args)) => {
779-
retry_cla_assistant::run(args)?;
781+
Some(CiCmd::ClaAssistant { cmd }) => {
782+
cla_assistant::run(cmd)?;
780783
}
781784

782785
None => run_all_clap_subcommands(&cli.skip)?,

0 commit comments

Comments
 (0)