Commit Graph
9 Commits
Author SHA1 Message Date
Lars Wirzenius 2e2236aea7 fix: use node id from ref name as originating node id
Change CI event creation to set the `from_node` field to the node id
in the Git ref being updated. Previously we set it to the `remote`
field in the node event, but that is id of the node from which our
local node got the `RefsUpdated` event, not the node where the change
was originally made.

Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-12-05 08:20:04 +02:00
Lars Wirzenius bb9e9f27bc refactor: node and CI event and trigger message creation
Refactor the code the constructs CI events from node events, and
trigger messages from CI events, to debug why I'm having trouble with
patch events.

Also adjust debug logging so I have more insight of what's going on.

Also, make code clearer, less repetitive, and overall easier to
follow.
2024-12-05 08:20:04 +02:00
Lars Wirzenius 1bc0ad40dc feat: cibtool can add every type of CI event to event queue
Add support to "cibtool event add" for branch deletion, and patch
creation and update events. Use this in a scenario that adds every
type of event to the queue and processes them. This ensures the CI
broker can actually handle any kind of CI event.

Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-12-05 08:20:04 +02:00
Lars Wirzenius 768b966890 fix: drop non-logging stderr output outside tests
Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-11-12 15:11:37 +02:00
Lars Wirzenius d537fd39d1 feat: filter on originating node for an event
Add the `Node(nid)` event filter.

Add the `from_node` field to the `BranchDeleted` event so that it too
can be filtered based on node.

Adjust debug logging for event filtering so that it reports the
filtering decision.

Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-10-21 14:07:11 +03:00
Lars Wirzenius a0122d8842 feat! mark CI event enum type as non-exhaustive
This should make it easier to evolve the enums as it forces users to
handle unknown variants explicitly.

Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-10-11 08:41:50 +03:00
Lars Wirzenius 145e061aff feat: make CI events versioned
This will help us avoid breaking changes in the future, when CI events
need to be modified, and CI broker instances need to cope with the
event queues in their databases.

Previously we had

    enum CiEvent {
        BranchCreated { ... },
        BranchUpdatee { ... },
        ....
    }

Change that to:

    enum CiEvent {
        V1(CiEventV1),
    }

    enum CiEventV1 {
        BranchCreated { ... },
        BranchUpdatee { ... },
        ....
    }

This will allow us to add new version variants to CiEvent, without
losing access to the already enqueued V1 events.

Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-10-10 18:11:16 +03:00
Lars Wirzenius 47064e5785 chore: deny clippy warning about unwrap being used
An unwrap (or unwrap_err, or their expect variants) can result in run
time panics: unwrapping an Option that is None can't return a useful
result, so it panics. Similar for a Result. I've previously tried to
grep for uses of unwrap, but the clippy warning is much more precise.

Add "deny(clippy::unwrap_used)" to the top of src/lib.rs, so it
affects the whole crate. Then fix any places where unwrap is used.

It's OK to use unwrap in tests: if the value is expected, but isn't
there, the test should fail, and panic is a fine way to fail the test.

Everywhere else it's better to make sure unwrap can't fail, and if it
can, return a Result and have the caller handle that.

Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-10-09 10:16:41 +03:00
Lars Wirzenius 426a9d3315 feat: add new CI events and filter for them
These will eventually replace the old broker events.
2024-09-30 12:58:16 +03:00