For several releases already, `cib` has refused to start if the
database has any "broker events". Broker events were a predecessor for
CI events, and they haven't been supported by the CI broker since
0.7.0, from October 2024.
Drop the Db method to query the database for queued broker events.
Also drop the creation of a table for that queue.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
Add a check for auditing the project via `cargo audit`.
Note that a RUSTSEC is ignored due to it not affecting the project – this is
recoreded in `.cargo/audit.toml`.
Adds a `flake.nix` for building and testing the radicle-ci-broker using Nix.
Auditing and license denial configurations are also added as part of the `nix
flake check`s.
Note that one of the tests is ignore as part of the nextest check, since it
relies on using the Git repository itself. This is discouraged, since the check
runs in a sandboxed environment.
While setting up a Nix flake, a series of tests were failing due to shell
invocations. The falling were the changes required:
- Use `!#/bin/sh` instead of `!#/bin/bash`
- Use `$$` instead of `$BASHPID`
- Use `true` and `false` instead of `/bin/true` and `/bin/false`
It was also noted that the `git-remote-helper` is needed alongside the `rad`
binary for some of the acceptance tests to work.
A trigger is a condition (filter) when to run CI using a specific
adapter. Change the configuration to allow them, and make the old list
of filters and default adapter be optional. This way, the user can use
either or both.
CI is run for each of:
- top level filter matches, using default adapter
- trigger filter matches, using the adapter specified in the trigger
To be clear, this can mean that CI is run many times for one CI event.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
Construct the collection, and give it to the queue processor, which is
the only part that needs to know what adapters there are.
For now, only the default adapter is used, but this makes a space from
which to pick a different for each CI run.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
This is preparation for allowing many triggers: we will want to allow
any number of triggers allow a single change, resulting in a different
CI run for each. Change the code that picks an adapter to be able to
pick any number of them, and then run all of them. Even if one fails,
run the rest.
This will potentially mean run the same adapter many times, although
it's meant to allow running a different adapter for each trigger.
Running the same adapter many times may be pointless, but we can't
reliably know that, only the user can. It depends on the adapter, the
change, and what the user is trying to achieve. So for now we don't
worry about that. If it turns out to be important, we can later add a
way to say each adapter will only be run once.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
Move CI event filtering from the queue adder to the queue processor.
This is ground work for supporting different adapters for different
runs.
Later, each "trigger" will have a separate filter, and if the filter
allows an event, the adapter for that trigger is run. However, we have
no way to communicate the chosen adapter via the event queue in the
database, without making a breaking database schema, which I would
prefer to avoid.
Instead, we add all events into the queue, and filter when we remove
them from the queue. This may be a little wasteful in terms of disk
space and I/O, if there are very large numbers of events. If this
turns out to be too expensive, we'll revert this change and do a
breaking schema change.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
Remove the default adapter from Broker, and make callers give the
adapter to use to the Broker::execute_ci method each time. This is
ground work for allowing different adapters for different CI runs.
There's no need for Broker to know about any adapters, except the one
it is currently running.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
The broker overall only supports the default adapter. When we add
support for using an adapter other than the default one, it'll not be
per repository.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
Make struct Config fields private and introduces getter methods to
access them. This will make it easier to change the CI broker to be
able to run different adapters for different changes.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
The configuration file can have a field `queue_len_interval`, and
defaults to 10 seconds. This should reduce log spam.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
Previously, we failed to capture all of stderr from the adapter if the
adapter sent messages to its stdout could not be parsed, or otherwise
meant the CI broker deduced the CI run had failed. Now we read all of
stderr (module time limits) before returning an error result.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
Add subcommand "cibtool log" to extract cib log messages from journald
logs, and pretty print them. Optionally with some very rudimentary
filtering based on log level, message kind, or broker run id.
Example:
sudo journalctl -S today -u radicle-ci-broker -o json | cibtool log --log-level info
Signed-off-by: Lars Wirzenius <liw@liw.fi>