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