cli/pkg/qa/cmd_qa.go
Snider e813c1f07e feat(qa): add qa watch command for CI monitoring (#60)
* feat(qa): add qa watch command for CI monitoring (#47)

Implements `core qa watch` to monitor GitHub Actions after a push:
- Polls workflow runs for a commit until completion
- Shows live progress with pass/fail counts
- On failure, shows job name, failed step, and link to logs
- Exits with appropriate code (0 = passed, 1 = failed)

Usage:
  core qa watch              # Watch current repo's HEAD
  core qa watch --repo X     # Watch specific repo
  core qa watch --timeout 5m # Custom timeout

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix(qa): address CodeRabbit feedback on watch command

- Add length check before slicing commitSha to prevent panic on short SHAs
- Count all non-success conclusions as failures (cancelled, timed_out, etc.)
- Use errors.E/Wrap pattern for consistent error handling with operation context

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat(qa): add context-aware commands and log parsing

- Use exec.CommandContext with timeout context for all gh invocations
  so commands are cancelled when deadline expires
- Implement fetchErrorFromLogs using 'gh run view --log-failed'
  to extract first meaningful error line from failed workflows
- Pass context through call chain for proper timeout propagation

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 03:37:16 +00:00

43 lines
1 KiB
Go

// Package qa provides quality assurance workflow commands.
//
// Unlike `core dev` which is about doing work (commit, push, pull),
// `core qa` is about verifying work (CI status, reviews, issues).
//
// Commands:
// - watch: Monitor GitHub Actions after a push, report actionable data
//
// Future commands:
// - issues: Intelligent issue triage
// - review: PR review status with actionable next steps
// - health: Aggregate CI health across all repos
package qa
import (
"github.com/host-uk/core/pkg/cli"
"github.com/host-uk/core/pkg/i18n"
)
func init() {
cli.RegisterCommands(AddQACommands)
}
// Style aliases from shared package
var (
successStyle = cli.SuccessStyle
errorStyle = cli.ErrorStyle
warningStyle = cli.WarningStyle
dimStyle = cli.DimStyle
)
// AddQACommands registers the 'qa' command and all subcommands.
func AddQACommands(root *cli.Command) {
qaCmd := &cli.Command{
Use: "qa",
Short: i18n.T("cmd.qa.short"),
Long: i18n.T("cmd.qa.long"),
}
root.AddCommand(qaCmd)
// Subcommands
addWatchCommand(qaCmd)
}