diff --git a/cmd/openqa-mon/openqa-mon.go b/cmd/openqa-mon/openqa-mon.go index c87ae97..e189d66 100644 --- a/cmd/openqa-mon/openqa-mon.go +++ b/cmd/openqa-mon/openqa-mon.go @@ -15,6 +15,8 @@ import ( "github.com/grisu48/gopenqa" ) +const VERSION = "0.5" + // Remote instance type Remote struct { URI string @@ -29,6 +31,7 @@ func printHelp() { fmt.Println("OPTIONS") fmt.Println("") fmt.Println(" -h, --help Print this help message") + fmt.Println(" --version Display program version") fmt.Println(" -j, --jobs JOBS Display information only for the given JOBS") fmt.Println(" JOBS can be a single job id, a comma separated list (e.g. 42,43,1337)") fmt.Println(" or a job range (1335..1339 or 1335+4)") @@ -250,6 +253,9 @@ func main() { case "--help": printHelp() return + case "--version": + fmt.Println("openqa-mon version " + VERSION) + return case "--jobs": i++ if i >= len(args) { @@ -612,12 +618,25 @@ func FetchJobs(remotes []Remote, callback func(int, gopenqa.Job)) ([]Remote, err } // Fires a job notification, if notifications are enabled -func NotifyJobChanged(j gopenqa.Job) { +func NotifyJobsChanged(jobs []gopenqa.Job) { if config.Bell { bell() } if config.Notify { - notifySend(fmt.Sprintf("[%s] - Job %d %s", j.JobState(), j.ID, j.Name)) + notification := "" + if len(jobs) == 1 { + j := jobs[0] + notification = fmt.Sprintf("[%s] - Job %d %s", j.JobState(), j.ID, j.Name) + } else { + for _, j := range jobs { + notification += fmt.Sprintf("[%s] %s\n", j.JobState(), j.Name) + } + } + notification = strings.TrimSpace(notification) + + if notification != "" { + notifySend(notification) + } } } @@ -680,7 +699,8 @@ func continuousMonitoring(remotes []Remote) { tui.SetStatus("Initial job fetching ... ") for { - exists := make(map[int]bool, 0) // Keep track of existing jobs + exists := make(map[int]bool, 0) // Keep track of existing jobs + notifyJobs := make([]gopenqa.Job, 0) // jobs which fire a notification // Fetch new jobs. Update remotes (job id's) when necessary remotes, err = FetchJobs(remotes, func(id int, job gopenqa.Job) { exists[job.ID] = true @@ -692,13 +712,13 @@ func continuousMonitoring(remotes []Remote) { if j.JobState() == job.JobState() { return } - // Ignore trivial changes (uploading, assigned) + // Ignore trivial changes (uploading, assigned) and skipped jobs state := job.JobState() - if state == "uploading" || state == "assigned" { + if state == "uploading" || state == "assigned" || state == "skipped" || state == "cancelled" { return } // Notify about job update - NotifyJobChanged(job) + notifyJobs = append(notifyJobs, job) // Refresh tui after each job update tui.Model.SetJobs(jobs) tui.Update() @@ -711,6 +731,10 @@ func continuousMonitoring(remotes []Remote) { tui.Model.SetJobs(jobs) tui.Update() }) + if len(notifyJobs) > 0 { + NotifyJobsChanged(notifyJobs) + } + // Remove items which are not present anymore - (e.g. old children) jobs = uniqueJobs(filterJobs(jobs, func(job gopenqa.Job) bool { _, ok := exists[job.ID] diff --git a/cmd/openqa-mq/openqa-mq.go b/cmd/openqa-mq/openqa-mq.go index 0793307..b135c19 100644 --- a/cmd/openqa-mq/openqa-mq.go +++ b/cmd/openqa-mq/openqa-mq.go @@ -10,6 +10,8 @@ import ( "github.com/streadway/amqp" ) +const VERSION = "1.0" + func printUsage() { fmt.Printf("Usage: %s [REMOTE] [KEY]\n", os.Args[0]) fmt.Println(" REMOTE - RabbitMQ address (e.g. amqps://opensuse:opensuse@rabbit.opensuse.org)") @@ -38,6 +40,9 @@ func main() { if remote == "-h" || remote == "--help" { printUsage() os.Exit(0) + } else if remote == "--version" { + fmt.Println("openqa-mq version " + VERSION) + os.Exit(0) } // Provide some nice shortcuts diff --git a/cmd/openqa-revtui/openqa-revtui.go b/cmd/openqa-revtui/openqa-revtui.go index a1ae908..ba75933 100644 --- a/cmd/openqa-revtui/openqa-revtui.go +++ b/cmd/openqa-revtui/openqa-revtui.go @@ -268,6 +268,9 @@ func parseProgramArgs() error { if arg == "-h" || arg == "--help" { printUsage() os.Exit(0) + } else if arg == "--version" { + fmt.Println("openqa-revtui version " + VERSION) + os.Exit(0) } else if arg == "-c" || arg == "--config" { if i++; i >= n { return fmt.Errorf("Missing argument: %s", "config file") diff --git a/cmd/openqa-revtui/pc-review.toml b/cmd/openqa-revtui/pc-review.toml new file mode 120000 index 0000000..77509e0 --- /dev/null +++ b/cmd/openqa-revtui/pc-review.toml @@ -0,0 +1 @@ +../../pc-review.toml \ No newline at end of file