Radicle Workers (CI/CD) example workflow ======================================== First thing is to setup some configuration for the repo. *.radicle/ci.yaml* ``` .radicle/workers.yaml { "jobs": [{ "name": "Check", "on": "patch.revision", "container": "./radicle/Dockerfile", "run": ["cargo", "check", "--all"], }, { "name": "Build release", "on": "patch.merge", "container": "./radicle/Dockerfile", "run" ["scripts/release.sh"] }] } ``` ``` $ git add .radicle/ci.yaml $ git commit -m "Add CI configuration" $ git push rad ``` Now let's setup our device to run jobs. The top-level command here is called "worker", because it manages all kinds of jobs. ``` $ rad worker start ✓ Workers started in the background $ rad worker status No jobs running. ``` Let's trigger a "Check" job: ``` $ git commit -m "Nothing special" --allow-empty $ git push rad HEAD:refs/patches ✓ Patch 90c77f2c33b7e472e058de4a586156f8a7fec7d6 opened ✓ Worker 42d894a83c9c356552a57af09ccdbd5587a99045 started ``` We can check the status of the job at any time: ``` $ rad worker show 42d894a83c9c356552a57af09ccdbd5587a99045 ╭────────────────────────────────────────────────────╮ │ Job Check │ │ Worker 42d894a83c9c356552a57af09ccdbd5587a99045 │ │ Repo rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji │ │ By z6MknSL…StBU8Vi (you) │ │ Status running │ ├────────────────────────────────────────────────────┤ │ ● started by z6MknSL…StBU8Vi (you) 1 minute ago │ │ ● running `cargo check --all` 1 minute ago │ ╰────────────────────────────────────────────────────╯ ``` We can also see it in the global status output: ``` $ rad worker status ╭─────────────────────────────────────────────────────────────────╮ │ Worker Job Repo Status │ ├─────────────────────────────────────────────────────────────────┤ │ 42d894a Check rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji running │ ╰─────────────────────────────────────────────────────────────────╯ ``` We can also check the logs: ``` $ rad worker logs 42d894a83c9c356552a57af09ccdbd5587a99045 Checking radicle v0.2.0 (../heartwood/radicle) Checking radicle-cli v0.8.0 (../heartwood/radicle-cli) Checking radicle-node v0.2.0 (../heartwood/radicle-node) ... ``` Finally, we can see the status of the "Check" job on our patch: ``` $ rad patch show 90c77f2c33b7e472e058de4a586156f8a7fec7d6 ╭────────────────────────────────────────────────────╮ │ Title Define power requirements │ │ Patch 90c77f2c33b7e472e058de4a586156f8a7fec7d6 │ │ Author z6MknSL…StBU8Vi (you) │ │ Status open │ ├────────────────────────────────────────────────────┤ │ ? Check (job running) since 3 minutes │ ├────────────────────────────────────────────────────┤ │ ● opened by z6MknSL…StBU8Vi (you) 4 minutes ago │ ╰────────────────────────────────────────────────────╯ ``` Until the job has successfully completed, we can't merge the patch: ``` $ git push rad master error: worker 42d894a is still running To rad://z42hL2jL4XNk6K8oHQaSWfMgCL7ji/z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi ! [remote rejected] master -> master ``` Let's wait a little and try again: ``` $ rad worker show 42d894a83c9c356552a57af09ccdbd5587a99045 ╭────────────────────────────────────────────────────╮ │ Job Check │ │ Worker 42d894a83c9c356552a57af09ccdbd5587a99045 │ │ Repo rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji │ │ By z6MknSL…StBU8Vi (you) │ │ Status running │ ├────────────────────────────────────────────────────┤ │ ● started by z6MknSL…StBU8Vi (you) 3 minute ago │ │ ● running `cargo check --all` 3 minute ago │ │ ✓ completed successfully 1 minute ago │ ╰────────────────────────────────────────────────────╯ ``` Great, we can now merge the patch. ``` $ git push rad master ``` --- If the job failed and needed to be restarted, we could run `rad worker restart <id>`. To configure on which repositories a node's workers should run, we could imagine a command like `rad worker watch <rid>` and `rad worker unwatch <rid>`. This could configure the repositories inside storage, or alternatively, a separate sqlite3 database could be used to store worker-related information.