Commit Graph
53 Commits
Author SHA1 Message Date
Lars Wirzenius eeb79ef090 feat(src/msg.rs): add RunId::as_str method
This makes it easier to use the run ID as a string, without creating a
whole new String value.

Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-08-02 18:33:27 +03:00
Lars Wirzenius 17828919ae fix(src/bin/cibtool.rs): ensure ref change event has a base commit
The trigger message given to the CI adapter to start a CI run must
have a list of commits. This requires the "ref changed" event to have
a base commit. The commits after the base commit to the tip commit in
the event become the list of commits in the trigger message.

"cibtool trigger" is given the tip commit with the "--commit" option.
Change it to use a parent commit of that as the base commit, or if
there is no parent commit (i.e., there is only the one commit in the
repository), the commit itself.

Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-07-31 09:55:19 +03:00
Lars Wirzenius 105a09a8db feat(src/msg.rs)! don't panic on missing commit or unknown type
Change Request::commit to not panic if the push or patch data has no
commits, or if the request is neither push nor patch. Instead, return
an appropriate error. A panic message isn't very helpful to users;
errors can have helpful messages.

This changes the method signature of an exported method and that is a
breaking change.

Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-07-31 09:54:56 +03:00
Lars Wirzenius f5edaff8f3 refactor(src/msg.rs): handle errors without panic in tests
Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-07-29 17:41:48 +03:00
Lars Wirzenius d82c077579 feat! return errors on fallible errors, instead of panic
This changes the public API of the src/events.rs module, so it's
technically a breaking change.

Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-07-29 17:19:58 +03:00
Lars Wirzenius 294a04f951 fix: internal documentation link
Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-07-17 16:32:38 +03:00
Lars Wirzenius 1010100c29 refactor: remove unnecessary variable
Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-06-18 20:36:22 +03:00
Lars Wirzenius c69c4c44ca refactor: rename variables for clarity
Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-06-18 20:36:22 +03:00
Lars Wirzenius b1820f3c2a refactor: simplify creating Result::Trigger
I find this easier to follow than keeping track of so many variables.

Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-06-18 20:36:22 +03:00
Lars Wirzenius 3a9f8ff3e2 refactor: simplify handling of parse_ref result
Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-06-18 20:36:22 +03:00
Lars Wirzenius e842e01ac1 refactor: make variable have an initial value
Clearer for me.

Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-06-18 20:36:22 +03:00
Lars Wirzenius b4484b946d refactor: move PatchEvent creation to its own function
For clarity.

Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-06-18 20:36:22 +03:00
Lars Wirzenius f38697e2d9 refactor: move creation of PushEvent to its own function
This is clearer for me.

Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-06-18 20:36:22 +03:00
Lars Wirzenius d84eccdcb6 refactor: drop unnecessary PathAction conversion from string
Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-06-18 20:36:22 +03:00
Lars Wirzenius 5fa43fc325 refactor: simplify how common fields Repository is created
Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-06-18 20:36:22 +03:00
Lars Wirzenius a216b84bd1 refactor: drop debug logging, to make code easier to grok
I want to debug the trigger message creation, and the `build_trigger`
method is long, and hard to follow. So I'll refactor it to be easier
for me to understand. First step: remove the `debug!` calls to make
the code shorter.

Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-06-18 20:35:14 +03:00
Lars Wirzenius c82fc3f657 fix: use the latest commit in a patch or push change
The commits in the trigger event are newest-first. When I wrote the
code I thought they were oldest-first. Mea culpa.

Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-06-06 14:40:02 +03:00
Michalis Zampetakis e3a90dfc19 Provide a parser function for parsing reference.
Currently supported handlers for puch and patch events.
2024-05-24 22:26:39 +03:00
Michalis Zampetakis 8adca82fe3 Change the way that the broker perceives a patch
Instead of checking for changes in patch cob, check if push is at
`/refs/heads/patches/`.

Adds AnyPushRef filter.
2024-05-23 21:15:43 +03:00
Lars Wirzenius fb51ce2bd9 feat: allow adapter to report an optional URL for a run
Also verify that the URL ends up in the HTML pages generated by the CI
broker.

Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-05-20 17:24:57 +03:00
Lars Wirzenius e243687658 feat: add shutdown event and debug logging for trigger building
Add a shutdown event to allow a clean shutdown of the CI broker, which
is useful for tests.

The added logging helps figure out what's going on, when there's a
problem communicating with the node or something else breaks when a
trigger message is constructed.

Also, handle the directory for status page not existing by silently
not writing a status page.

Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-05-07 19:17:56 +03:00
Lars Wirzenius a59b2dba82 refactor: use enum for patch action variants
Stringly typed things tend to break.

Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-04-15 20:44:00 +03:00
Lars Wirzenius 1e0c9ed755 feat! add version field to request messages
Each request message has a field "version" set to an integer. An
adapter can check that it gets the version of the message it knows how
to handle.

Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-04-02 09:32:17 +03:00
Lars Wirzenius 601abc94d3 feat! drop the RunResult::Error variant
It was never very clear how Failure and Error actually differ, and
making the choice was thus unnecessarily difficult for an adapter
implementation. Having just Failure is simpler.

We'll re-introduce other variants if there are actual use cases and
things aren't vague.

Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-04-02 09:18:42 +03:00
Lars Wirzenius 42603ef31f feat: add patch revisions to report pages
Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-03-19 17:07:42 +02:00
Lars Wirzenius 1c64e2eb04 feat: show who made patch/commit CI is run for
Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-03-18 10:54:19 +02:00
Lars Wirzenius 4c504912e3 feat: add Request::try_from_str for tests
Specifically, radicle-native-ci tests.

Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-03-12 17:30:35 +02:00
Lars Wirzenius eac7f53dff fix: serialize EventType to lowercase
Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-03-05 18:36:21 +02:00
Lars Wirzenius 6260b8117e refactor: reorder imports
Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-03-05 18:36:13 +02:00
Lars Wirzenius 68b589ce37 feat: use an enum for event types
Stringly typing isn't checked by the compiler.

Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-03-05 18:13:16 +02:00
Lars Wirzenius fee8700dc8 feat: add a RequestBuilder to create Request messages
A builder interface is easier to use I find.

Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-03-05 18:01:57 +02:00
Lars Wirzenius fd672cbdf7 chore: format code
Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-03-05 16:04:18 +02:00
Michalis Zampetakis 472ca9ba8a Adds branch name for push events 2024-03-05 12:55:06 +02:00
Lars Wirzenius f0cb3d2944 fix: call to create patch in test to use COB cache
Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-03-04 19:01:41 +02:00
Lars Wirzenius 443bf0b184 feat! generate HTML report pages
Instead of only a single JSON file, updated every so often, also
generate HTML pages that show CI broker status, and lists every
repository for which the broker has run CI.

This currently assumes the native CI adapter, but that can be fixed to
be more generic later.

Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-03-04 16:43:51 +02:00
Lars Wirzenius 13e2c2488e tests(src/msg.rs): use test helpers from test.rs
This simplifies the test code somewhat.

Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-02-02 17:39:46 +02:00
Lars Wirzenius fbd1911e2f feat(src/msg.rs): add a Response constructor from string slice
This will make it easier to process adapter output line by line.

Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-02-02 17:38:26 +02:00
Lars Wirzenius 1321c25f29 feat(src/msg.rs): add helpers to get repo, commit from Request
This relieves uses for a Request from having to unpack it with pattern
matching. The helpers are much more convenient, when they are sufficient.

Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-02-02 17:37:20 +02:00
Lars Wirzenius 84051a2f1d feat(src/msg.rs): make RunResult implement Eq
Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-02-02 17:36:40 +02:00
Lars Wirzenius b53cf99e22 feat(src/msg.rs): set a uuid as the RunId by default
This will be useful for tests in a near-future commit.

Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-02-02 17:35:57 +02:00
Lars Wirzenius f31ac159e0 refactor: combine event.rs and filter.rs
The division of concerns between the two was artificial and unclear.

Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-01-29 16:18:13 +02:00
Lars Wirzenius a6da02f852 refactor: move message related errors from error.rs to msg.rs
Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-01-26 17:16:27 +02:00
Lars Wirzenius 833be8d0cc docs: add documentation comments for everything in msg.src
FIXMEs mostly now.

Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-01-26 15:33:13 +02:00
jchrist c3d223d7fc feat(adapter): enrich adapter run context
Include context information to the adapter(s) about the trigger, distinguishing a trigger for a patch and a trigger for a push (possibly to a patch), according to the architecture.

Specifically, add push information for git pushes, including commit(s) and author.
For patches, add information about the specific patch that was updated, its revisions, along with the latest revision and the commits it includes.
2024-01-25 08:54:16 +02:00
Lars Wirzenius c7a2572e80 fix: adapt to radicle's Id->RepoId rename
Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-01-23 17:21:21 +02:00
Lars Wirzenius 7b31ac5c46 chore: make Request and Response cloneable
This helps native CI have better error messages.

Signed-off-by: Lars Wirzenius <liw@liw.fi>
2023-12-14 17:20:51 +02:00
Lars Wirzenius f37948149b refactor: error types
Have a top level error type that users of the library can import. Then
have a per-module error type so that errors returned by that module
can be as specific and precise as they can be.

Signed-off-by: Lars Wirzenius <liw@liw.fi>
2023-12-14 16:28:44 +02:00
Lars Wirzenius af03df8517 chore: drop anyhow in favor of just thiserror
Signed-off-by: Lars Wirzenius <liw@liw.fi>
2023-12-14 16:11:33 +02:00
Lars Wirzenius f31ff2718f fix: use the canonical names for Id, Oid
Signed-off-by: Lars Wirzenius <liw@liw.fi>
2023-12-14 13:35:02 +02:00
Lars Wirzenius 0014c6a4dd fix: handle all cases for RunResult
Signed-off-by: Lars Wirzenius <liw@liw.fi>
2023-12-14 13:29:12 +02:00