#ci #radicle #broker #node #adapter #filter #system

build radicle-ci-broker

add integration to CI engins or systems to a Radicle node

1 unstable release

0.1.0 Apr 3, 2024

#233 in Build Utils

Download history 95/week @ 2024-03-28 52/week @ 2024-04-04 6/week @ 2024-04-11

153 downloads per month
Used in radicle-native-ci

MIT/Apache and GPL-3.0-or-later

110KB
2.5K SLoC

radicle-ci-broker

Add integration to CI engines/systems/services to Radicle, a distributed git hosting and collaboration system.

This is not quite production ready code yet, but it will eventually become a thing that listens for changes in a Radicle node, and triggers CI on the relevant ones.

Architecture

See the doc directory for architecture documentation. Quick summary: the CI broker gets events from the Radicle node, filters them based on its own config, and for any event that gets past the filter, runs the configured adapter executable. The broker and adapter use a simple JSON based message protocol over stdin/stdout. Each CI system has its own adapter.

Binaries

The crate contains several binaries:

  • ci-broker --- the actual CI broker
    • this is the only one you need to care about, the rest are for debugging
  • broker-messages --- helper program to print sample messages between the broker and adapters
  • filter-events --- a helper program to see what events a CI broker config allows
  • list_runs --- list all CI runs in a broker database
  • pagegen -- helper program to produce sample report pages
    • mostly only useful for testing changes to the page generating code

Packaging

There is simple, simplistic, rudimentary, personal-use-only packaging for Debian in the debian directory, used by Lars to build packages for his own use.

Running tests

To run the test suite for the CI broker:

cargo test

(The usual way, for a Rust program.)

Configuration

The configuration file is named on the command line. It is a YAML file, for example:

default_adapter: native
db: ci-broker.sqlite
adapters:
  native:
    command: radicle-native-ci
    env:
      RADICLE_NATIVE_CI: /home/liw/radicle/radicle-native-ci/x/config.yaml
filters:
  - !And
    - !Repository "rad:z2e6URdt1we1iG1BCVqtx8QVgsX4a"
    - !Or
      - !Branch "main"
      - !AnyPatchRef

Or if you only want to filter for patch COB updates (e.g. comments), to the specified repository:

default_adapter: native
db: ci-broker.sqlite
adapters:
  native:
    command: radicle-native-ci
    env:
      RADICLE_NATIVE_CI: /home/liw/radicle/radicle-native-ci/x/config.yaml
filters:
  - !And
    - !Repository "rad:z2e6URdt1we1iG1BCVqtx8QVgsX4a"
    - !And
      - !AnyPatch
      - !Not 
        - !AnyPatchRef 

This runs the native CI engine as an adapter, on any repository events that pass the filter. The filter allows any changes to the main branch or any Radicle patch, on the specified repository.

License

Radicle CI broker is distributed under the terms of both the MIT license and the Apache License (Version 2.0).

See LICENSE-APACHE and LICENSE-MIT for details.

Dependencies

~53MB
~1M SLoC