We need to parse the run info in the database as JSON to get at the
adapter run info. This fails if the run info can't be parsed. That can
happen if the database has run info from a development version. Change
`cibtool run remove` so that it takes only broker run ids by default
so that we can delete using those even if the run info is broken.
Allow removing by adapter run id with the `--adapter` option.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
If the run info can't be parsed as JSON, loading it will fail. Change
`cibtool run list` so that it only lists the run ids by default.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
Subplot's Rust lib/runcmd library currently sets HOME to the directory
in which a command is run. If the step is "when I run, in foo, git",
then git is run with HOME set to point to the sub-directory foo under
the per-scenario data directory. I suspect this is a bug in Subplot,
but until that is confirmed and fixed by Subplot, and the fix included
in a release, we can avoid that by running "env -C foo git" instead.
This has the effect of changing the working directory to foo before
running git, without affecting any environment variables, which is
what we want.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
This makes them more obvious than at the debug level. These are not
messages that repeat, so they won't be log spam.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
When we get a CI event, we parse the namespaced name in the event to
see if it's a patch, or branch update. However, if might not be a
either: it might, for example, be a sigrefs update. Create a
branch event only if it's a branch event. Previously we would assume
it's branch event if not a patch event, and return an error if it's
not actually a branch.
If it's not a patch or branch change, ignore the event, as there's
nothing useful we can do about it, at least for now.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
Don't log unstructured messages from various places in processing
events and the execution of a CI run. I think these are unnecessary
messages anyway, by now. If it turns out we need them, we'll add them
back as structured log messages.
Drop the now-unused logger::debug, debug2, trace, and trace2
functions, may the never return.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
Previously, we might not remove the event from the queue if something
went wrong while processing it. This could result in the CI broker
picking again in the future, and it might fail again, and repeat ad
nauseam.
It's better to remove the event from the queue at once, and log any
problems while processing it, and let humans deal with failures, and
decide if re-processing is needed.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
This means that even if the thread ends due to an error, the error
gets logged. This will help with diagnosing problems.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
This means that even if the thread ends due to an error, the error
gets logged. This will help with diagnosing problems.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
This means that even if the thread ends due to an error, the error
gets logged. This will help with diagnosing problems.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
This is a huge change, but it's mostly a few kinds of similar changes
in a lot of places. Unfortunately, they were not easy to tease apart
into small, easily reviewed commits.
Use the Git ref types created by the new refs module. Fix problems
this exposes.
The CiEvent enum variants for branch events now use the BranchName
type for branch names. In other words, they have a plain branch name.
The CiEvent::from_node_event constructor also always sets the branch
name to a plain branch name, instead of a name spaced ref for updated
or deleted branches. The ci_event.rs module's unit tests have been
fixed to use the correct kind of Git ref in each test. (It used to be
a mess.)
The CI event filter "Branch" now contains a BranchName, previously a
RefString. This should not break anything, as a RefString will always
work as a BranchName.
The DefaultBranch filter now works, because it compares plain branch
names, where it previously would compare a plain and a name spaced
branch name, and those are never equal.
"cibtool trigger" and "cibtool event add" now add branch events with a plain
branch instead of a name spaced ref.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
Add helper functions to construct plain branch names ("main"), full
branch refs ("refs/heads/main"), and namespaced full branch
names ("refs/namespaces/$NID/refs/heads/main").
Keeping track of while only using RefStrings is too hard to get right.
We need to use the types provided by the radicle crate: BranchName,
Qualified, and Namespaced. Even if I find the type names less than
obvious, they're much better than plain RefStrings.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
Very long RSS feeds can cause problems for some readers. Apparently
they forget they've already seen very old entries and show them as
new. To work around this, only include the ten newest CI runs.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
Also make runcmd and get_sources log what they do, to the admin log.
This originally comes from radicle-ci-ambient, the Radicle CI adapter
for Ambient.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
Also fix Db::remove_run, which has never actually worked, because the
run id column was named wrongly. Oops.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
Everything works, binary is just a bit bigger. To avoid duplicates
would require co-ordination between various parties in the dependency
graph, and while that'd be worthwhile, it's too much work for now.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
Can't do anything about it in this crate, the git-ref-format crate or
radicle-git-ext crate needs to change.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
Previously we imported the Oid type (for Git object identifiers)
different places. This was confusing, and also meant that upgrading a
dependency (radicle-git-ext) broke, because two types with the same
name imported from different versions of the same crate are different
types.
Change this so that radicle::git::Oid is the one true Oid type we use.
Signed-off-by: Lars Wirzenius <liw@liw.fi>