Commit 643168c

Eric Bower  ·  2026-05-06 20:49:43 -0400 EDT
parent e3aec66
chore: cleanup
2 files changed,  +54, -0
+43, -0
......@@ -120,6 +120,10 @@ func main() {
120120
121121 switch cmd {
122122 case "runner":
123+ if flag.Arg(1) == "--help" || flag.Arg(1) == "help" {
124+ printRunnerHelp()
125+ return
126+ }
123127 cfg.Logger.Debug("starting runner")
124128 if err := RunRunner(cfg); err != nil {
125129 cfg.Logger.Error("runner failed", "err", err)
......@@ -153,6 +157,34 @@ func main() {
153157 }
154158 }
155159
160+func printRunnerHelp() {
161+ fmt.Println(`pici runner — execute a CI job from an event JSON payload.
162+
163+USAGE
164+ echo '<event-json>' | pici runner [flags]
165+ pici runner --event '<event-json>' [flags]
166+
167+EVENT JSON FIELDS
168+ type (required) Event type, e.g. "push", "merge_request"
169+ name (required) Repository name, used for session naming
170+ workspace (required) SSH source path to rsync, e.g. "git@github.com:user/repo.git"
171+ artifact_dest (optional) SSH destination for artifact sync, e.g. "user@host:/path"
172+ artifact_url (optional) Public URL for artifacts, e.g. "https://artifacts.pgs.sh/repo"
173+
174+EXAMPLE
175+ echo '{"type":"push","name":"myrepo","workspace":"git@github.com:user/myrepo.git"}' | pici runner
176+
177+FLAGS
178+ -pk <path> SSH private key for authenticating with pico services
179+ -ck <path> SSH certificate public key (required when using SSH certificates)
180+ -artifact-dir <path> Local directory to stage artifacts (default: /tmp/pici-artifacts)
181+ -event <json> Event JSON string (alternative to reading from stdin)
182+ -monitor-interval <dur> Interval for monitoring zmx sessions (default: 5s)
183+ -log-level <level> Log level: debug, info, warn, error (default: info)
184+ -structured Use structured key=value log output
185+ -status-filter <filter> Status output filter: terminal (default) or all`)
186+}
187+
156188 func RunRunner(cfg *Cfg) error {
157189 var payload string
158190 if cfg.EventSource != nil {
......@@ -176,6 +208,17 @@ func RunRunner(cfg *Cfg) error {
176208 return fmt.Errorf("unmarshal event: %w", err)
177209 }
178210
211+ // Validate required fields
212+ if eventData.Type == "" {
213+ return fmt.Errorf("event missing required field: type")
214+ }
215+ if eventData.Name == "" {
216+ return fmt.Errorf("event missing required field: name")
217+ }
218+ if eventData.Workspace == "" {
219+ return fmt.Errorf("event missing required field: workspace")
220+ }
221+
179222 cfg.Logger.Info("received event", "type", eventData.Type, "repo", eventData.Name, "workspace", eventData.Workspace)
180223
181224 return eventHandler(cfg, &eventData)
+11, -0
......@@ -0,0 +1,11 @@
1+#!/usr/bin/env fish
2+
3+# Continuously subscribe to build events and feed them to pici runner.
4+# Usage: ./run.fish
5+
6+echo "subscribing to build events..."
7+ssh pipe sub build.event | while read -l event
8+ if test -n "$event"
9+ echo "$event" | pici runner
10+ end
11+end