2026-01-30 20:02:03 +00:00
|
|
|
package php
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
"path/filepath"
|
|
|
|
|
"strings"
|
|
|
|
|
"sync"
|
|
|
|
|
|
2026-01-31 11:39:19 +00:00
|
|
|
"github.com/host-uk/core/pkg/cli"
|
2026-01-30 20:02:03 +00:00
|
|
|
"github.com/host-uk/core/pkg/framework"
|
|
|
|
|
"github.com/host-uk/core/pkg/i18n"
|
|
|
|
|
"github.com/host-uk/core/pkg/process"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// QARunner orchestrates PHP QA checks using pkg/process.
|
|
|
|
|
type QARunner struct {
|
|
|
|
|
dir string
|
|
|
|
|
fix bool
|
|
|
|
|
service *process.Service
|
|
|
|
|
core *framework.Core
|
|
|
|
|
|
|
|
|
|
// Output tracking
|
|
|
|
|
outputMu sync.Mutex
|
|
|
|
|
checkOutputs map[string][]string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// NewQARunner creates a QA runner for the given directory.
|
|
|
|
|
func NewQARunner(dir string, fix bool) (*QARunner, error) {
|
|
|
|
|
// Create a Core with process service for the QA session
|
|
|
|
|
core, err := framework.New(
|
|
|
|
|
framework.WithName("process", process.NewService(process.Options{})),
|
|
|
|
|
)
|
|
|
|
|
if err != nil {
|
2026-01-31 11:39:19 +00:00
|
|
|
return nil, cli.WrapVerb(err, "create", "process service")
|
2026-01-30 20:02:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
svc, err := framework.ServiceFor[*process.Service](core, "process")
|
|
|
|
|
if err != nil {
|
2026-01-31 11:39:19 +00:00
|
|
|
return nil, cli.WrapVerb(err, "get", "process service")
|
2026-01-30 20:02:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
runner := &QARunner{
|
|
|
|
|
dir: dir,
|
|
|
|
|
fix: fix,
|
|
|
|
|
service: svc,
|
|
|
|
|
core: core,
|
|
|
|
|
checkOutputs: make(map[string][]string),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return runner, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// BuildSpecs creates RunSpecs for the given QA checks.
|
|
|
|
|
func (r *QARunner) BuildSpecs(checks []string) []process.RunSpec {
|
|
|
|
|
specs := make([]process.RunSpec, 0, len(checks))
|
|
|
|
|
|
|
|
|
|
for _, check := range checks {
|
|
|
|
|
spec := r.buildSpec(check)
|
|
|
|
|
if spec != nil {
|
|
|
|
|
specs = append(specs, *spec)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return specs
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// buildSpec creates a RunSpec for a single check.
|
|
|
|
|
func (r *QARunner) buildSpec(check string) *process.RunSpec {
|
|
|
|
|
switch check {
|
|
|
|
|
case "audit":
|
|
|
|
|
return &process.RunSpec{
|
|
|
|
|
Name: "audit",
|
|
|
|
|
Command: "composer",
|
|
|
|
|
Args: []string{"audit", "--format=summary"},
|
|
|
|
|
Dir: r.dir,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case "fmt":
|
2026-02-05 18:14:59 +00:00
|
|
|
m := getMedium()
|
refactor(cli): move commands from cmd/ to pkg/ with self-registration
Implements defence in depth through build variants - only compiled code
exists in the binary. Commands now self-register via cli.RegisterCommands()
in their init() functions, mirroring the i18n.RegisterLocales() pattern.
Structure changes:
- cmd/{ai,build,ci,dev,docs,doctor,go,php,pkg,sdk,setup,test,vm}/ → pkg/*/cmd_*.go
- cmd/core_dev.go, cmd/core_ci.go → cmd/variants/{full,ci,php,minimal}.go
- Added pkg/cli/commands.go with RegisterCommands API
- Updated pkg/cli/runtime.go to attach registered commands
Build variants:
- go build → full (21MB, all 13 command groups)
- go build -tags ci → ci (18MB, build/ci/sdk/doctor)
- go build -tags php → php (14MB, php/doctor)
- go build -tags minimal → minimal (11MB, doctor only)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 21:55:55 +00:00
|
|
|
formatter, found := DetectFormatter(r.dir)
|
2026-01-30 20:02:03 +00:00
|
|
|
if !found {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
refactor(cli): move commands from cmd/ to pkg/ with self-registration
Implements defence in depth through build variants - only compiled code
exists in the binary. Commands now self-register via cli.RegisterCommands()
in their init() functions, mirroring the i18n.RegisterLocales() pattern.
Structure changes:
- cmd/{ai,build,ci,dev,docs,doctor,go,php,pkg,sdk,setup,test,vm}/ → pkg/*/cmd_*.go
- cmd/core_dev.go, cmd/core_ci.go → cmd/variants/{full,ci,php,minimal}.go
- Added pkg/cli/commands.go with RegisterCommands API
- Updated pkg/cli/runtime.go to attach registered commands
Build variants:
- go build → full (21MB, all 13 command groups)
- go build -tags ci → ci (18MB, build/ci/sdk/doctor)
- go build -tags php → php (14MB, php/doctor)
- go build -tags minimal → minimal (11MB, doctor only)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 21:55:55 +00:00
|
|
|
if formatter == FormatterPint {
|
2026-01-30 20:02:03 +00:00
|
|
|
vendorBin := filepath.Join(r.dir, "vendor", "bin", "pint")
|
|
|
|
|
cmd := "pint"
|
2026-02-05 18:14:59 +00:00
|
|
|
if m.IsFile(vendorBin) {
|
2026-01-30 20:02:03 +00:00
|
|
|
cmd = vendorBin
|
|
|
|
|
}
|
|
|
|
|
args := []string{}
|
|
|
|
|
if !r.fix {
|
|
|
|
|
args = append(args, "--test")
|
|
|
|
|
}
|
|
|
|
|
return &process.RunSpec{
|
|
|
|
|
Name: "fmt",
|
|
|
|
|
Command: cmd,
|
|
|
|
|
Args: args,
|
|
|
|
|
Dir: r.dir,
|
|
|
|
|
After: []string{"audit"},
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
|
2026-01-30 20:06:51 +00:00
|
|
|
case "stan":
|
2026-02-05 18:14:59 +00:00
|
|
|
m := getMedium()
|
refactor(cli): move commands from cmd/ to pkg/ with self-registration
Implements defence in depth through build variants - only compiled code
exists in the binary. Commands now self-register via cli.RegisterCommands()
in their init() functions, mirroring the i18n.RegisterLocales() pattern.
Structure changes:
- cmd/{ai,build,ci,dev,docs,doctor,go,php,pkg,sdk,setup,test,vm}/ → pkg/*/cmd_*.go
- cmd/core_dev.go, cmd/core_ci.go → cmd/variants/{full,ci,php,minimal}.go
- Added pkg/cli/commands.go with RegisterCommands API
- Updated pkg/cli/runtime.go to attach registered commands
Build variants:
- go build → full (21MB, all 13 command groups)
- go build -tags ci → ci (18MB, build/ci/sdk/doctor)
- go build -tags php → php (14MB, php/doctor)
- go build -tags minimal → minimal (11MB, doctor only)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 21:55:55 +00:00
|
|
|
_, found := DetectAnalyser(r.dir)
|
2026-01-30 20:02:03 +00:00
|
|
|
if !found {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
vendorBin := filepath.Join(r.dir, "vendor", "bin", "phpstan")
|
|
|
|
|
cmd := "phpstan"
|
2026-02-05 18:14:59 +00:00
|
|
|
if m.IsFile(vendorBin) {
|
2026-01-30 20:02:03 +00:00
|
|
|
cmd = vendorBin
|
|
|
|
|
}
|
|
|
|
|
return &process.RunSpec{
|
2026-01-30 20:06:51 +00:00
|
|
|
Name: "stan",
|
2026-01-30 20:02:03 +00:00
|
|
|
Command: cmd,
|
|
|
|
|
Args: []string{"analyse", "--no-progress"},
|
|
|
|
|
Dir: r.dir,
|
|
|
|
|
After: []string{"fmt"},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case "psalm":
|
2026-02-05 18:14:59 +00:00
|
|
|
m := getMedium()
|
refactor(cli): move commands from cmd/ to pkg/ with self-registration
Implements defence in depth through build variants - only compiled code
exists in the binary. Commands now self-register via cli.RegisterCommands()
in their init() functions, mirroring the i18n.RegisterLocales() pattern.
Structure changes:
- cmd/{ai,build,ci,dev,docs,doctor,go,php,pkg,sdk,setup,test,vm}/ → pkg/*/cmd_*.go
- cmd/core_dev.go, cmd/core_ci.go → cmd/variants/{full,ci,php,minimal}.go
- Added pkg/cli/commands.go with RegisterCommands API
- Updated pkg/cli/runtime.go to attach registered commands
Build variants:
- go build → full (21MB, all 13 command groups)
- go build -tags ci → ci (18MB, build/ci/sdk/doctor)
- go build -tags php → php (14MB, php/doctor)
- go build -tags minimal → minimal (11MB, doctor only)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 21:55:55 +00:00
|
|
|
_, found := DetectPsalm(r.dir)
|
2026-01-30 20:02:03 +00:00
|
|
|
if !found {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
vendorBin := filepath.Join(r.dir, "vendor", "bin", "psalm")
|
|
|
|
|
cmd := "psalm"
|
2026-02-05 18:14:59 +00:00
|
|
|
if m.IsFile(vendorBin) {
|
2026-01-30 20:02:03 +00:00
|
|
|
cmd = vendorBin
|
|
|
|
|
}
|
|
|
|
|
args := []string{"--no-progress"}
|
|
|
|
|
if r.fix {
|
|
|
|
|
args = append(args, "--alter", "--issues=all")
|
|
|
|
|
}
|
|
|
|
|
return &process.RunSpec{
|
|
|
|
|
Name: "psalm",
|
|
|
|
|
Command: cmd,
|
|
|
|
|
Args: args,
|
|
|
|
|
Dir: r.dir,
|
2026-01-30 20:06:51 +00:00
|
|
|
After: []string{"stan"},
|
2026-01-30 20:02:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case "test":
|
2026-02-05 18:14:59 +00:00
|
|
|
m := getMedium()
|
2026-01-30 20:02:03 +00:00
|
|
|
// Check for Pest first, fall back to PHPUnit
|
|
|
|
|
pestBin := filepath.Join(r.dir, "vendor", "bin", "pest")
|
|
|
|
|
phpunitBin := filepath.Join(r.dir, "vendor", "bin", "phpunit")
|
|
|
|
|
|
feat: infrastructure packages and lint cleanup (#281)
* ci: consolidate duplicate workflows and merge CodeQL configs
Remove 17 duplicate workflow files that were split copies of the
combined originals. Each family (CI, CodeQL, Coverage, PR Build,
Alpha Release) had the same job duplicated across separate
push/pull_request/schedule/manual trigger files.
Merge codeql.yml and codescan.yml into a single codeql.yml with
a language matrix covering go, javascript-typescript, python,
and actions — matching the previous default setup coverage.
Remaining workflows (one per family):
- ci.yml (push + PR + manual)
- codeql.yml (push + PR + schedule, all languages)
- coverage.yml (push + PR + manual)
- alpha-release.yml (push + manual)
- pr-build.yml (PR + manual)
- release.yml (tag push)
- agent-verify.yml, auto-label.yml, auto-project.yml
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat: add collect, config, crypt, plugin packages and fix all lint issues
Add four new infrastructure packages with CLI commands:
- pkg/config: layered configuration (defaults → file → env → flags)
- pkg/crypt: crypto primitives (Argon2id, AES-GCM, ChaCha20, HMAC, checksums)
- pkg/plugin: plugin system with GitHub-based install/update/remove
- pkg/collect: collection subsystem (GitHub, BitcoinTalk, market, papers, excavate)
Fix all golangci-lint issues across the entire codebase (~100 errcheck,
staticcheck SA1012/SA1019/ST1005, unused, ineffassign fixes) so that
`core go qa` passes with 0 issues.
Closes #167, #168, #170, #250, #251, #252, #253, #254, #255, #256
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 11:34:43 +00:00
|
|
|
var cmd string
|
2026-02-05 18:14:59 +00:00
|
|
|
if m.IsFile(pestBin) {
|
2026-01-30 20:02:03 +00:00
|
|
|
cmd = pestBin
|
2026-02-05 18:14:59 +00:00
|
|
|
} else if m.IsFile(phpunitBin) {
|
2026-01-30 20:02:03 +00:00
|
|
|
cmd = phpunitBin
|
|
|
|
|
} else {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-30 20:06:51 +00:00
|
|
|
// Tests depend on stan (or psalm if available)
|
|
|
|
|
after := []string{"stan"}
|
refactor(cli): move commands from cmd/ to pkg/ with self-registration
Implements defence in depth through build variants - only compiled code
exists in the binary. Commands now self-register via cli.RegisterCommands()
in their init() functions, mirroring the i18n.RegisterLocales() pattern.
Structure changes:
- cmd/{ai,build,ci,dev,docs,doctor,go,php,pkg,sdk,setup,test,vm}/ → pkg/*/cmd_*.go
- cmd/core_dev.go, cmd/core_ci.go → cmd/variants/{full,ci,php,minimal}.go
- Added pkg/cli/commands.go with RegisterCommands API
- Updated pkg/cli/runtime.go to attach registered commands
Build variants:
- go build → full (21MB, all 13 command groups)
- go build -tags ci → ci (18MB, build/ci/sdk/doctor)
- go build -tags php → php (14MB, php/doctor)
- go build -tags minimal → minimal (11MB, doctor only)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 21:55:55 +00:00
|
|
|
if _, found := DetectPsalm(r.dir); found {
|
2026-01-30 20:02:03 +00:00
|
|
|
after = []string{"psalm"}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return &process.RunSpec{
|
|
|
|
|
Name: "test",
|
|
|
|
|
Command: cmd,
|
|
|
|
|
Args: []string{},
|
|
|
|
|
Dir: r.dir,
|
|
|
|
|
After: after,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case "rector":
|
2026-02-05 18:14:59 +00:00
|
|
|
m := getMedium()
|
refactor(cli): move commands from cmd/ to pkg/ with self-registration
Implements defence in depth through build variants - only compiled code
exists in the binary. Commands now self-register via cli.RegisterCommands()
in their init() functions, mirroring the i18n.RegisterLocales() pattern.
Structure changes:
- cmd/{ai,build,ci,dev,docs,doctor,go,php,pkg,sdk,setup,test,vm}/ → pkg/*/cmd_*.go
- cmd/core_dev.go, cmd/core_ci.go → cmd/variants/{full,ci,php,minimal}.go
- Added pkg/cli/commands.go with RegisterCommands API
- Updated pkg/cli/runtime.go to attach registered commands
Build variants:
- go build → full (21MB, all 13 command groups)
- go build -tags ci → ci (18MB, build/ci/sdk/doctor)
- go build -tags php → php (14MB, php/doctor)
- go build -tags minimal → minimal (11MB, doctor only)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 21:55:55 +00:00
|
|
|
if !DetectRector(r.dir) {
|
2026-01-30 20:02:03 +00:00
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
vendorBin := filepath.Join(r.dir, "vendor", "bin", "rector")
|
|
|
|
|
cmd := "rector"
|
2026-02-05 18:14:59 +00:00
|
|
|
if m.IsFile(vendorBin) {
|
2026-01-30 20:02:03 +00:00
|
|
|
cmd = vendorBin
|
|
|
|
|
}
|
|
|
|
|
args := []string{"process"}
|
|
|
|
|
if !r.fix {
|
|
|
|
|
args = append(args, "--dry-run")
|
|
|
|
|
}
|
|
|
|
|
return &process.RunSpec{
|
|
|
|
|
Name: "rector",
|
|
|
|
|
Command: cmd,
|
|
|
|
|
Args: args,
|
|
|
|
|
Dir: r.dir,
|
|
|
|
|
After: []string{"test"},
|
|
|
|
|
AllowFailure: true, // Dry-run returns non-zero if changes would be made
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case "infection":
|
2026-02-05 18:14:59 +00:00
|
|
|
m := getMedium()
|
refactor(cli): move commands from cmd/ to pkg/ with self-registration
Implements defence in depth through build variants - only compiled code
exists in the binary. Commands now self-register via cli.RegisterCommands()
in their init() functions, mirroring the i18n.RegisterLocales() pattern.
Structure changes:
- cmd/{ai,build,ci,dev,docs,doctor,go,php,pkg,sdk,setup,test,vm}/ → pkg/*/cmd_*.go
- cmd/core_dev.go, cmd/core_ci.go → cmd/variants/{full,ci,php,minimal}.go
- Added pkg/cli/commands.go with RegisterCommands API
- Updated pkg/cli/runtime.go to attach registered commands
Build variants:
- go build → full (21MB, all 13 command groups)
- go build -tags ci → ci (18MB, build/ci/sdk/doctor)
- go build -tags php → php (14MB, php/doctor)
- go build -tags minimal → minimal (11MB, doctor only)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 21:55:55 +00:00
|
|
|
if !DetectInfection(r.dir) {
|
2026-01-30 20:02:03 +00:00
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
vendorBin := filepath.Join(r.dir, "vendor", "bin", "infection")
|
|
|
|
|
cmd := "infection"
|
2026-02-05 18:14:59 +00:00
|
|
|
if m.IsFile(vendorBin) {
|
2026-01-30 20:02:03 +00:00
|
|
|
cmd = vendorBin
|
|
|
|
|
}
|
|
|
|
|
return &process.RunSpec{
|
|
|
|
|
Name: "infection",
|
|
|
|
|
Command: cmd,
|
|
|
|
|
Args: []string{"--min-msi=50", "--min-covered-msi=70", "--threads=4"},
|
|
|
|
|
Dir: r.dir,
|
|
|
|
|
After: []string{"test"},
|
|
|
|
|
AllowFailure: true,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Run executes all QA checks and returns the results.
|
refactor(cli): move commands from cmd/ to pkg/ with self-registration
Implements defence in depth through build variants - only compiled code
exists in the binary. Commands now self-register via cli.RegisterCommands()
in their init() functions, mirroring the i18n.RegisterLocales() pattern.
Structure changes:
- cmd/{ai,build,ci,dev,docs,doctor,go,php,pkg,sdk,setup,test,vm}/ → pkg/*/cmd_*.go
- cmd/core_dev.go, cmd/core_ci.go → cmd/variants/{full,ci,php,minimal}.go
- Added pkg/cli/commands.go with RegisterCommands API
- Updated pkg/cli/runtime.go to attach registered commands
Build variants:
- go build → full (21MB, all 13 command groups)
- go build -tags ci → ci (18MB, build/ci/sdk/doctor)
- go build -tags php → php (14MB, php/doctor)
- go build -tags minimal → minimal (11MB, doctor only)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 21:55:55 +00:00
|
|
|
func (r *QARunner) Run(ctx context.Context, stages []QAStage) (*QARunResult, error) {
|
2026-01-30 20:02:03 +00:00
|
|
|
// Collect all checks from all stages
|
|
|
|
|
var allChecks []string
|
|
|
|
|
for _, stage := range stages {
|
refactor(cli): move commands from cmd/ to pkg/ with self-registration
Implements defence in depth through build variants - only compiled code
exists in the binary. Commands now self-register via cli.RegisterCommands()
in their init() functions, mirroring the i18n.RegisterLocales() pattern.
Structure changes:
- cmd/{ai,build,ci,dev,docs,doctor,go,php,pkg,sdk,setup,test,vm}/ → pkg/*/cmd_*.go
- cmd/core_dev.go, cmd/core_ci.go → cmd/variants/{full,ci,php,minimal}.go
- Added pkg/cli/commands.go with RegisterCommands API
- Updated pkg/cli/runtime.go to attach registered commands
Build variants:
- go build → full (21MB, all 13 command groups)
- go build -tags ci → ci (18MB, build/ci/sdk/doctor)
- go build -tags php → php (14MB, php/doctor)
- go build -tags minimal → minimal (11MB, doctor only)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 21:55:55 +00:00
|
|
|
checks := GetQAChecks(r.dir, stage)
|
2026-01-30 20:02:03 +00:00
|
|
|
allChecks = append(allChecks, checks...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if len(allChecks) == 0 {
|
|
|
|
|
return &QARunResult{Passed: true}, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Build specs
|
|
|
|
|
specs := r.BuildSpecs(allChecks)
|
|
|
|
|
if len(specs) == 0 {
|
|
|
|
|
return &QARunResult{Passed: true}, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Register output handler
|
|
|
|
|
r.core.RegisterAction(func(c *framework.Core, msg framework.Message) error {
|
|
|
|
|
switch m := msg.(type) {
|
|
|
|
|
case process.ActionProcessOutput:
|
|
|
|
|
r.outputMu.Lock()
|
|
|
|
|
// Extract check name from process ID mapping
|
|
|
|
|
for _, spec := range specs {
|
|
|
|
|
if strings.Contains(m.ID, spec.Name) || m.ID != "" {
|
|
|
|
|
// Store output for later display if needed
|
|
|
|
|
r.checkOutputs[spec.Name] = append(r.checkOutputs[spec.Name], m.Line)
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
r.outputMu.Unlock()
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// Create runner and execute
|
|
|
|
|
runner := process.NewRunner(r.service)
|
|
|
|
|
result, err := runner.RunAll(ctx, specs)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Convert to QA result
|
|
|
|
|
qaResult := &QARunResult{
|
|
|
|
|
Passed: result.Success(),
|
|
|
|
|
Duration: result.Duration.String(),
|
|
|
|
|
Results: make([]QACheckRunResult, 0, len(result.Results)),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for _, res := range result.Results {
|
|
|
|
|
qaResult.Results = append(qaResult.Results, QACheckRunResult{
|
|
|
|
|
Name: res.Name,
|
|
|
|
|
Passed: res.Passed(),
|
|
|
|
|
Skipped: res.Skipped,
|
|
|
|
|
ExitCode: res.ExitCode,
|
|
|
|
|
Duration: res.Duration.String(),
|
|
|
|
|
Output: res.Output,
|
|
|
|
|
})
|
|
|
|
|
if res.Passed() {
|
|
|
|
|
qaResult.PassedCount++
|
|
|
|
|
} else if res.Skipped {
|
|
|
|
|
qaResult.SkippedCount++
|
|
|
|
|
} else {
|
|
|
|
|
qaResult.FailedCount++
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return qaResult, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// GetCheckOutput returns captured output for a check.
|
|
|
|
|
func (r *QARunner) GetCheckOutput(check string) []string {
|
|
|
|
|
r.outputMu.Lock()
|
|
|
|
|
defer r.outputMu.Unlock()
|
|
|
|
|
return r.checkOutputs[check]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// QARunResult holds the results of running QA checks.
|
|
|
|
|
type QARunResult struct {
|
2026-02-01 06:32:35 +00:00
|
|
|
Passed bool `json:"passed"`
|
|
|
|
|
Duration string `json:"duration"`
|
|
|
|
|
Results []QACheckRunResult `json:"results"`
|
|
|
|
|
PassedCount int `json:"passed_count"`
|
|
|
|
|
FailedCount int `json:"failed_count"`
|
|
|
|
|
SkippedCount int `json:"skipped_count"`
|
2026-01-30 20:02:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// QACheckRunResult holds the result of a single QA check.
|
|
|
|
|
type QACheckRunResult struct {
|
2026-02-01 06:32:35 +00:00
|
|
|
Name string `json:"name"`
|
|
|
|
|
Passed bool `json:"passed"`
|
|
|
|
|
Skipped bool `json:"skipped"`
|
|
|
|
|
ExitCode int `json:"exit_code"`
|
|
|
|
|
Duration string `json:"duration"`
|
|
|
|
|
Output string `json:"output,omitempty"`
|
2026-01-30 20:02:03 +00:00
|
|
|
}
|
|
|
|
|
|
2026-01-30 20:23:28 +00:00
|
|
|
// GetIssueMessage returns an issue message for a check.
|
2026-01-30 20:02:03 +00:00
|
|
|
func (r QACheckRunResult) GetIssueMessage() string {
|
|
|
|
|
if r.Passed || r.Skipped {
|
|
|
|
|
return ""
|
|
|
|
|
}
|
|
|
|
|
switch r.Name {
|
|
|
|
|
case "audit":
|
2026-01-30 20:23:28 +00:00
|
|
|
return i18n.T("i18n.done.find", "vulnerabilities")
|
2026-01-30 20:02:03 +00:00
|
|
|
case "fmt":
|
2026-01-30 20:23:28 +00:00
|
|
|
return i18n.T("i18n.done.find", "style issues")
|
2026-01-30 20:06:51 +00:00
|
|
|
case "stan":
|
2026-01-30 20:23:28 +00:00
|
|
|
return i18n.T("i18n.done.find", "analysis errors")
|
2026-01-30 20:02:03 +00:00
|
|
|
case "psalm":
|
2026-01-30 20:23:28 +00:00
|
|
|
return i18n.T("i18n.done.find", "type errors")
|
2026-01-30 20:02:03 +00:00
|
|
|
case "test":
|
2026-01-30 20:23:28 +00:00
|
|
|
return i18n.T("i18n.done.fail", "tests")
|
2026-01-30 20:02:03 +00:00
|
|
|
case "rector":
|
2026-01-30 20:23:28 +00:00
|
|
|
return i18n.T("i18n.done.find", "refactoring suggestions")
|
2026-01-30 20:02:03 +00:00
|
|
|
case "infection":
|
2026-01-30 20:23:28 +00:00
|
|
|
return i18n.T("i18n.fail.pass", "mutation testing")
|
2026-01-30 20:02:03 +00:00
|
|
|
default:
|
2026-01-30 20:23:28 +00:00
|
|
|
return i18n.T("i18n.done.find", "issues")
|
2026-01-30 20:02:03 +00:00
|
|
|
}
|
|
|
|
|
}
|