Radish alpha
r
Radicle CI broker
Radicle
Git (anonymous pull)
Log in to clone via SSH
fix: "cibtool run add" sets the state if successful
Lars Wirzenius committed 1 year ago
commit 13ce97b1f0ed902076fc6c81d6c84a9b9b790701
parent e58d4c3af68e96a4686af29b387f354a3ab39450
3 files changed +19 -2
modified ci-broker.md
@@ -890,6 +890,7 @@ 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 --triggered --timestamp 2024-07-09T02:00:00
when I run cibtool --db x.db run list --json
then stdout contains "rad:zwTxygwuz5LDGBq255RA2CbNGrz8"
+
then stdout contains ""state": "triggered""
~~~

## Add information about run that's running to database
@@ -908,6 +909,7 @@ 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"
+
then stdout contains ""state": "running""
~~~


@@ -927,6 +929,8 @@ 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 ""state": "finished""
+
then stdout contains ""result": "success""
then stdout contains "rad:zwTxygwuz5LDGBq255RA2CbNGrz8"
~~~

@@ -946,6 +950,8 @@ 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 ""state": "finished""
+
then stdout contains ""result": "failure""
then stdout contains "rad:zwTxygwuz5LDGBq255RA2CbNGrz8"

when I run cibtool --db x.db run list --adapter-run-id abracadabra
modified src/bin/cibtool.rs
@@ -287,4 +287,7 @@ enum CibToolError {

    #[error("one of --id or --id-file is required")]
    MissingId,
+

+
    #[error("programming error: confused about state and result of run")]
+
    AddRunConfusion,
}
modified src/bin/cibtoolcmd/run.rs
@@ -70,12 +70,20 @@ impl Leaf for AddRun {
            run.set_adapter_info_url(url);
        }

-
        if self.success {
+
        if self.triggered {
+
            run.set_state(RunState::Triggered);
+
            run.unset_result();
+
        } else if self.running {
+
            run.set_state(RunState::Running);
+
            run.unset_result();
+
        } else if self.success {
            run.set_result(RunResult::Success);
+
            run.set_state(RunState::Finished);
        } else if self.failure {
            run.set_result(RunResult::Failure);
+
            run.set_state(RunState::Finished);
        } else {
-
            run.unset_result();
+
            return Err(CibToolError::AddRunConfusion);
        }

        db.push_run(&run)?;