ci_manager/config/commands.rs
1//! The `commands` module contains the subcommands for the `gh-workflow-parser` CLI.
2
3use crate::*;
4
5pub mod locate_failure_log;
6
7#[derive(Debug, Subcommand)]
8pub enum Command {
9 /// Create an issue from a failed CI run
10 CreateIssueFromRun {
11 /// The repository to parse
12 #[arg(long, value_hint = ValueHint::Url)]
13 repo: String,
14 /// The workflow run ID
15 #[arg(short = 'r', long)]
16 run_id: String,
17 /// The issue label
18 #[arg(short, long)]
19 label: String,
20 /// The kind of workflow (e.g. Yocto)
21 #[arg(short, long)]
22 kind: WorkflowKind,
23 /// Title of the issue
24 #[arg(short, long)]
25 title: String,
26 /// Don't create the issue if a similar issue already exists
27 #[arg(short, long, default_value_t = true)]
28 no_duplicate: bool,
29 },
30
31 /// Locate the specific failure log in a failed build/test/other
32 LocateFailureLog {
33 /// The kind of CI step (e.g. Yocto)
34 #[arg(short, long)]
35 kind: StepKind,
36 /// Log file to search for the failure log (e.g. log.txt or read from stdin)
37 /// File to operate on (if not provided, reads from stdin)
38 #[arg(short = 'f', long, value_hint = ValueHint::FilePath)]
39 input_file: Option<PathBuf>,
40 },
41}
42
43/// The kind of workflow (e.g. Yocto)
44#[derive(ValueEnum, Display, Copy, Clone, Debug, PartialEq, Eq)]
45pub enum WorkflowKind {
46 #[value(name = "yocto", aliases = ["Yocto", "YOCTO"])]
47 Yocto,
48 #[value(name = "other", aliases = ["Other", "OTHER"])]
49 Other,
50}
51
52/// The kind of step in CI, e.g. Yocto, Pytest, Pre-commit, Docker build, etc.
53///
54/// This is used to take highly specific actions based on the kind of CI step that failed.
55/// e.g. if a Yocto build fails, we can locate the specific log of the failed task and
56/// create a GitHub issue with the log attached, or pass it to another tool for uploading it etc.
57#[derive(ValueEnum, Display, EnumString, Copy, Clone, Debug, PartialEq, Eq)]
58pub enum StepKind {
59 Yocto,
60 Other,
61}