Commit 643168c
Eric Bower
·
2026-05-06 20:49:43 -0400 EDT
parent e3aec66
chore: cleanup
M
main.go
+43,
-0
1@@ -120,6 +120,10 @@ func main() {
2
3 switch cmd {
4 case "runner":
5+ if flag.Arg(1) == "--help" || flag.Arg(1) == "help" {
6+ printRunnerHelp()
7+ return
8+ }
9 cfg.Logger.Debug("starting runner")
10 if err := RunRunner(cfg); err != nil {
11 cfg.Logger.Error("runner failed", "err", err)
12@@ -153,6 +157,34 @@ func main() {
13 }
14 }
15
16+func printRunnerHelp() {
17+ fmt.Println(`pici runner — execute a CI job from an event JSON payload.
18+
19+USAGE
20+ echo '<event-json>' | pici runner [flags]
21+ pici runner --event '<event-json>' [flags]
22+
23+EVENT JSON FIELDS
24+ type (required) Event type, e.g. "push", "merge_request"
25+ name (required) Repository name, used for session naming
26+ workspace (required) SSH source path to rsync, e.g. "git@github.com:user/repo.git"
27+ artifact_dest (optional) SSH destination for artifact sync, e.g. "user@host:/path"
28+ artifact_url (optional) Public URL for artifacts, e.g. "https://artifacts.pgs.sh/repo"
29+
30+EXAMPLE
31+ echo '{"type":"push","name":"myrepo","workspace":"git@github.com:user/myrepo.git"}' | pici runner
32+
33+FLAGS
34+ -pk <path> SSH private key for authenticating with pico services
35+ -ck <path> SSH certificate public key (required when using SSH certificates)
36+ -artifact-dir <path> Local directory to stage artifacts (default: /tmp/pici-artifacts)
37+ -event <json> Event JSON string (alternative to reading from stdin)
38+ -monitor-interval <dur> Interval for monitoring zmx sessions (default: 5s)
39+ -log-level <level> Log level: debug, info, warn, error (default: info)
40+ -structured Use structured key=value log output
41+ -status-filter <filter> Status output filter: terminal (default) or all`)
42+}
43+
44 func RunRunner(cfg *Cfg) error {
45 var payload string
46 if cfg.EventSource != nil {
47@@ -176,6 +208,17 @@ func RunRunner(cfg *Cfg) error {
48 return fmt.Errorf("unmarshal event: %w", err)
49 }
50
51+ // Validate required fields
52+ if eventData.Type == "" {
53+ return fmt.Errorf("event missing required field: type")
54+ }
55+ if eventData.Name == "" {
56+ return fmt.Errorf("event missing required field: name")
57+ }
58+ if eventData.Workspace == "" {
59+ return fmt.Errorf("event missing required field: workspace")
60+ }
61+
62 cfg.Logger.Info("received event", "type", eventData.Type, "repo", eventData.Name, "workspace", eventData.Workspace)
63
64 return eventHandler(cfg, &eventData)
A
run.fish
+11,
-0
1@@ -0,0 +1,11 @@
2+#!/usr/bin/env fish
3+
4+# Continuously subscribe to build events and feed them to pici runner.
5+# Usage: ./run.fish
6+
7+echo "subscribing to build events..."
8+ssh pipe sub build.event | while read -l event
9+ if test -n "$event"
10+ echo "$event" | pici runner
11+ end
12+end