mirror of
https://seed.radicle.dev/rad:zwTxygwuz5LDGBq255RA2CbNGrz8.git
synced 2026-10-18 19:30:29 +08:00
feat: allow configuring adapters in the cib configuration file
This makes it easier to specify several adapters, with varying configurations, by not having to put the configuration for each specification in a separate file. Signed-off-by: Lars Wirzenius <liw@liw.fi>
This commit is contained in:
+63
-2
@@ -49,8 +49,11 @@ queue_len_interval: 1min
|
||||
adapters:
|
||||
mcadapterface:
|
||||
command: ./adapter.sh
|
||||
config:
|
||||
foo: bar
|
||||
config_env: RADICLE_NATIVE_CI
|
||||
env:
|
||||
RADICLE_NATIVE_CI: native-ci.yaml
|
||||
PATH: /bin
|
||||
sensitive_env:
|
||||
API_KEY: xyzzy
|
||||
filters:
|
||||
@@ -127,7 +130,15 @@ set -eu
|
||||
cat > /dev/null
|
||||
echo '{"response":"triggered","run_id":{"id":"xyzzy"}}'
|
||||
echo '{"response":"finished","result":"success"}'
|
||||
echo "This is an adapter error: Mordor" 1>&2
|
||||
(
|
||||
echo "This is an adapter error: Mordor"
|
||||
echo "Environment:"
|
||||
env
|
||||
if [ "${RADICLE_NATIVE_CI:-}" != "" ]; then
|
||||
echo "Adapter config:"
|
||||
nl "$RADICLE_NATIVE_CI"
|
||||
fi
|
||||
) 1>&2
|
||||
~~~
|
||||
|
||||
# Custom scenario steps
|
||||
@@ -326,6 +337,25 @@ then command is successful
|
||||
~~~
|
||||
|
||||
|
||||
## Shows adapter specification
|
||||
|
||||
_Want:_ The CI broker can write out the specification for an adapter.
|
||||
|
||||
_Why:_ This is helpful for the node operator to verify that
|
||||
they have specified the adapter correctly.
|
||||
|
||||
_Who:_ `cib-devs`
|
||||
|
||||
~~~scenario
|
||||
given a Radicle node, with CI configured with broker.yaml and adapter dummy.sh
|
||||
when I run cib --config broker.yaml adapters --output adapters.json
|
||||
when I run jq . adapters.json
|
||||
then command is successful
|
||||
then stdout contains ""foo": "bar""
|
||||
then stdout contains ""config_env": "RADICLE_NATIVE_CI""
|
||||
~~~
|
||||
|
||||
|
||||
## Refuses config with an unknown field
|
||||
|
||||
_Want:_ The CI broker refused to load a configuration file that has
|
||||
@@ -395,6 +425,37 @@ then stdout contains ""id": "xyzzy""
|
||||
~~~
|
||||
|
||||
|
||||
## Runs adapter with configuration
|
||||
|
||||
_Want:_ CI broker can run its adapter and give it the configuration in
|
||||
the CI broker adapter specification.
|
||||
|
||||
_Why:_ Being able to embed the adapter configuration in the `cib`
|
||||
configuration file makes is more convenient for the node operators to
|
||||
specify different adapter configurations for different purposes.
|
||||
|
||||
_Who:_ `node-ops`
|
||||
|
||||
~~~scenario
|
||||
given a Radicle node, with CI configured with broker.yaml and adapter dummy.sh
|
||||
given a Git repository xyzzy in the Radicle node
|
||||
given the Radicle node emits a refsUpdated event for xyzzy
|
||||
when I run ./env.sh synthetic-events synt.sock event.json --log log.txt
|
||||
given a directory reports
|
||||
when I run ./env.sh cib --config broker.yaml process-events
|
||||
|
||||
then stderr contains "RADICLE_NATIVE_CI="
|
||||
then stderr contains "foo: bar"
|
||||
then stderr contains "API_KEY: xyzzy"
|
||||
|
||||
when I run cibtool --db ci-broker.db event list
|
||||
then stdout is empty
|
||||
|
||||
when I run cibtool --db ci-broker.db run list --json
|
||||
then stdout contains ""id": "xyzzy""
|
||||
~~~
|
||||
|
||||
|
||||
## Runs adapter without a report directory
|
||||
|
||||
_Want:_ CI broker can run without a report directory.
|
||||
|
||||
Reference in New Issue
Block a user