feat: HasFile event filter predicte

Signed-off-by: Lars Wirzenius <liw@liw.fi>
This commit is contained in:
Lars Wirzenius
2025-02-04 18:46:19 +02:00
parent c7ae4fbb23
commit 623e590c2c
2 changed files with 92 additions and 3 deletions
+49
View File
@@ -236,6 +236,8 @@ The Git repository must exist.
~~~scenario
then directory reppy exists
then directory reppy/.git exists
then file reppy/file.dat exists
then file reppy/foobar does not exist
when I run, in reppy, git show
then stdout matches regex ^commit
~~~
@@ -1230,6 +1232,53 @@ triggers:
~~~
## Filter predicate `HasFile`
_Want:_ We can allow an event if its commit contains a file or
directory by this name.
_Why:_ This is so that the user can choose a suitable adapter.
~~~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 file config.yaml from filter-hasfile-missing.yaml
when I run cibtool --db ci-broker.db event add --repo xyzzy --ref main --commit HEAD --kind branch-created
when I run ./env.sh cib --config config.yaml queued
when I run cibtool --db ci-broker.db run list --json
then stdout doesn't contain "main"
given file config.yaml from filter-hasfile.yaml
when I run cibtool --db ci-broker.db event add --repo xyzzy --ref main --commit HEAD --kind branch-created
when I run ./env.sh cib --config config.yaml queued
when I run cibtool --db ci-broker.db run list --json
then stdout contains "main"
~~~
~~~{#filter-hasfile.yaml .file .json}
db: ci-broker.db
adapters:
default:
command: ./adapter.sh
triggers:
- adapter: default
filters:
- !HasFile "file.dat"
~~~
~~~{#filter-hasfile-missing.yaml .file .json}
db: ci-broker.db
adapters:
default:
command: ./adapter.sh
triggers:
- adapter: default
filters:
- !HasFile "does-not-exist"
~~~
# Acceptance criteria for test tooling
The event synthesizer is a helper to feed the CI broker node events in