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>
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.
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>
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>
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>
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>