| |
echo "This is an adapter error: Mordor" 1>&2
|
| |
~~~
|
| |
|
| - |
## A `refsFetched` node event
|
| - |
|
| - |
This is a node event from the node to signal that some git refs have
|
| - |
changed in repository.
|
| - |
|
| - |
~~~{#refsfetched.json .file .json}
|
| - |
{
|
| - |
"type": "refsFetched",
|
| - |
"remote": "z6MkgEMYod7Hxfy9qCvDv5hYHkZ4ciWmLFgfvm3Wn1b2w2FV",
|
| - |
"rid": "rad:zwTxygwuz5LDGBq255RA2CbNGrz8",
|
| - |
"updated": [
|
| - |
{
|
| - |
"updated": {
|
| - |
"name": "refs/namespaces/DUMMYNID/refs/heads/main",
|
| - |
"old": "0000000000000000000000000000000000000000",
|
| - |
"new": "0000000000000000000000000000000000000000"
|
| - |
}
|
| - |
}
|
| - |
]
|
| - |
}
|
| - |
~~~
|
| - |
|
| - |
## Set rid in `refsFetched` event
|
| - |
|
| - |
This is a helper script that reads a `refsFetched` event and changes
|
| - |
its `rid` field to be the id of the given repository. It also sets the
|
| - |
`name` field for updated refs to include the repository ID. It writes
|
| - |
the message back to its file.
|
| - |
|
| - |
~~~{#set-rid .file .python}
|
| - |
#!/usr/bin/python3
|
| - |
|
| - |
import json, sys
|
| - |
from subprocess import run, PIPE
|
| - |
|
| - |
filename = sys.argv[1]
|
| - |
cwd = sys.argv[2]
|
| - |
|
| - |
p = run(["rad", "."], check=True, capture_output=True, cwd=cwd)
|
| - |
rid = p.stdout.decode().strip()
|
| - |
|
| - |
p = run(["rad", "self", "--nid"], check=True, capture_output=True, cwd=cwd)
|
| - |
nid = p.stdout.decode().strip()
|
| - |
|
| - |
p = run(["git", "rev-parse", "HEAD"], check=True, capture_output=True, cwd=cwd)
|
| - |
oid = p.stdout.decode().strip()
|
| - |
|
| - |
o = json.load(open(filename))
|
| - |
|
| - |
o["rid"] = rid
|
| - |
|
| - |
if "updated" in o:
|
| - |
x = o["updated"]
|
| - |
for oo in x:
|
| - |
name = oo["updated"]["name"]
|
| - |
oo["updated"]["name"] = nid.join(name.split("DUMMYNID"))
|
| - |
oo["updated"]["new"] = oid
|
| - |
o["updated"] = x
|
| - |
|
| - |
with open(filename, "w") as f:
|
| - |
json.dump(o, fp=f, indent=4)
|
| - |
~~~
|
| - |
|
| - |
## Set environment variables and run command
|
| - |
|
| - |
To avoid having to repeat environment variables to set up and use a
|
| - |
Radicle node for verification scenarios, we provide a script that
|
| - |
sets them and runs a command.
|
| - |
|
| - |
~~~{#radenv.sh .file .sh}
|
| - |
#!/bin/bash
|
| - |
|
| - |
set -euo pipefail
|
| - |
|
| - |
homedir="$(pwd)/homedir"
|
| - |
|
| - |
env \
|
| - |
SRCDIR="$CARGO_MANIFEST_DIR" \
|
| - |
PATH=~/.radicle/bin:"$PATH" \
|
| - |
HOME="$homedir" \
|
| - |
RAD_PASSPHRASE=secret \
|
| - |
RAD_HOME="$homedir/.radicle" \
|
| - |
RAD_SOCKET=synt.sock \
|
| - |
"$@"
|
| - |
~~~
|
| - |
|
| - |
|
| - |
## Set up a node with repository
|
| - |
|
| - |
Most of our verification scenarios will need to set up a Radicle node
|
| - |
and a test repository there. Rather than repeat it in every scenario,
|
| - |
we use this helper script.
|
| - |
|
| - |
~~~{#setup-node.sh .file .sh}
|
| - |
#!/bin/bash
|
| - |
|
| - |
set -xeuo pipefail
|
| - |
|
| - |
mkdir -p "$HOME"
|
| - |
|
| - |
rad auth --alias brokertest
|
| - |
|
| - |
git config --global user.email radicle@example.com
|
| - |
git config --global user.name TestyMcTestFace
|
| - |
git init -b main testy
|
| - |
|
| - |
cd testy
|
| - |
echo "test file" > test.txt
|
| - |
|
| - |
git add .
|
| - |
git commit -am test
|
| - |
git status
|
| - |
git show
|
| - |
rad init --name testy --description test --default-branch main --private --no-confirm --no-seed
|
| - |
rad inspect --identity
|
| - |
rad id list
|
| - |
~~~
|
| - |
|
| |
# Custom scenario steps
|
| |
|
| |
In this document we use scenarios to show how to verify that the CI
|