Radish alpha
r
rad:zwTxygwuz5LDGBq255RA2CbNGrz8
Radicle CI broker
Radicle
Git
feat! "cibtool run add" run state option change
Merged liw opened 1 year ago

Make the “cibtool run add” options to set the state of a CI run be more logical. There are now four:

  • –triggered
  • –running
  • –success
  • –failure

That is, drop the –running option. This allows the clap configuration to specify that one of those four is required. I could not find a way to specify that if –running was present, one of –success and –failure was required, but that’s OK: the –running option didn’t actually help to make things easier for the user.

Signed-off-by: Lars Wirzenius liw@liw.fi

2 files changed +70 -20 a80ab49d 2cc1dc4b
modified ci-broker.md
@@ -433,7 +433,7 @@ given file setup-node.sh
when I run bash radenv.sh bash setup-node.sh

given an installed cibtool
-
when I run cibtool --db x.db run add --id x --repo rad:zwTxygwuz5LDGBq255RA2CbNGrz8 --alias x --url https://x/1 --branch main --commit f1815dde6ae406d8fe3cec0b96c4486766342716 --who x --finished --failure --timestamp 2024-07-09T02:00:00
+
when I run cibtool --db x.db run add --id x --repo rad:zwTxygwuz5LDGBq255RA2CbNGrz8 --alias x --url https://x/1 --branch main --commit f1815dde6ae406d8fe3cec0b96c4486766342716 --who x --failure --timestamp 2024-07-09T02:00:00

given a directory reports
when I run bash radenv.sh cibtool --db x.db report --output-dir reports
@@ -766,11 +766,10 @@ done

echo OK
~~~
-
# Acceptance criteria for event queue management
+
# Acceptance criteria for management tool

-
The CI builder database contains a queue of broker events. The
-
`cibtool` management tool can be used to examine and manipulate the
-
queue.
+
The `cibtool` management tool can be used to examine and change the CI
+
broker database, and thus indirectly manage what the CI broker does.

## Events can be queued and removed from queue

@@ -854,10 +853,9 @@ then stdout contains "main"
~~~


-
## Add CI run information to database
+
## Add information about triggered run to database

-
_Want:_ `cibtool` can add information about a CI run, possibly
-
one that is imaginary.
+
_Want:_ `cibtool` can add information about a triggered CI run.

_Why:_ This is primarily needed for testing.

@@ -868,7 +866,64 @@ given an installed cibtool
when I run cibtool --db x.db run list
then stdout is exactly ""

-
when I run cibtool --db x.db run add --id x --repo rad:zwTxygwuz5LDGBq255RA2CbNGrz8 --alias x --url https://x/1 --branch main --commit f1815dde6ae406d8fe3cec0b96c4486766342716 --who x --finished --failure --timestamp 2024-07-09T02:00:00
+
when I run cibtool --db x.db run add --id x --repo rad:zwTxygwuz5LDGBq255RA2CbNGrz8 --alias x --url https://x/1 --branch main --commit f1815dde6ae406d8fe3cec0b96c4486766342716 --who x --triggered --timestamp 2024-07-09T02:00:00
+
when I run cibtool --db x.db run list --json
+
then stdout contains "rad:zwTxygwuz5LDGBq255RA2CbNGrz8"
+
~~~
+

+
## Add information about run that's running to database
+

+
_Want:_ `cibtool` can add information about a CI run that's running.
+

+
_Why:_ This is primarily needed for testing.
+

+
_Who:_ Lars.
+

+
~~~scenario
+
given an installed cibtool
+
when I run cibtool --db x.db run list
+
then stdout is exactly ""
+

+
when I run cibtool --db x.db run add --id x --repo rad:zwTxygwuz5LDGBq255RA2CbNGrz8 --alias x --url https://x/1 --branch main --commit f1815dde6ae406d8fe3cec0b96c4486766342716 --who x --running --timestamp 2024-07-09T02:00:00
+
when I run cibtool --db x.db run list --json
+
then stdout contains "rad:zwTxygwuz5LDGBq255RA2CbNGrz8"
+
~~~
+

+

+
## Add information about run that's finished successfully to database
+

+
_Want:_ `cibtool` can add information about a CI run that's finished
+
successfully.
+

+
_Why:_ This is primarily needed for testing.
+

+
_Who:_ Lars.
+

+
~~~scenario
+
given an installed cibtool
+
when I run cibtool --db x.db run list
+
then stdout is exactly ""
+

+
when I run cibtool --db x.db run add --id x --repo rad:zwTxygwuz5LDGBq255RA2CbNGrz8 --alias x --url https://x/1 --branch main --commit f1815dde6ae406d8fe3cec0b96c4486766342716 --who x --success --timestamp 2024-07-09T02:00:00
+
when I run cibtool --db x.db run list --json
+
then stdout contains "rad:zwTxygwuz5LDGBq255RA2CbNGrz8"
+
~~~
+

+

+
## Add information about run that's finished in failure to database
+

+
_Want:_ `cibtool` can add information about a CI run that's failed.
+

+
_Why:_ This is primarily needed for testing.
+

+
_Who:_ Lars.
+

+
~~~scenario
+
given an installed cibtool
+
when I run cibtool --db x.db run list
+
then stdout is exactly ""
+

+
when I run cibtool --db x.db run add --id x --repo rad:zwTxygwuz5LDGBq255RA2CbNGrz8 --alias x --url https://x/1 --branch main --commit f1815dde6ae406d8fe3cec0b96c4486766342716 --who x --failure --timestamp 2024-07-09T02:00:00
when I run cibtool --db x.db run list --json
then stdout contains "rad:zwTxygwuz5LDGBq255RA2CbNGrz8"

modified src/bin/cibtool.rs
@@ -585,25 +585,20 @@ struct AddRun {
    who: Option<String>,

    /// Set the state of the CI run to "triggered".
-
    #[clap(long, required_unless_present_any = ["running", "finished"])]
+
    #[clap(long, required_unless_present_any = ["running", "success", "failure"])]
    triggered: bool,

    /// Set the state of the CI run to "running".
    #[clap(long)]
-
    #[clap(long, required_unless_present_any = ["triggered", "finished"])]
+
    #[clap(long, required_unless_present_any = ["triggered", "success", "failure"])]
    running: bool,

-
    /// Set the state of the CI run to "finished".
-
    #[clap(long)]
-
    #[clap(long, required_unless_present_any = ["triggered", "running"])]
-
    finished: bool,
-

-
    /// Mark the finished CI run as successful.
-
    #[clap(long, required_unless_present = "failure")]
+
    /// Mark the CI run as finished and successful.
+
    #[clap(long, required_unless_present_any = ["triggered", "running", "failure"])]
    success: bool,
-
    /// Mark the finished CI run as having failed.

-
    #[clap(long, required_unless_present = "success")]
+
    /// Mark the CI run as finished and failed.
+
    #[clap(long, required_unless_present_any = ["triggered", "running", "success"])]
    failure: bool,
}