diff --git a/backend/cmd/localpatchreport/main.go b/backend/cmd/localpatchreport/main.go index 4849ba40..74d8ec0e 100644 --- a/backend/cmd/localpatchreport/main.go +++ b/backend/cmd/localpatchreport/main.go @@ -46,7 +46,7 @@ type reportJSON struct { func main() { repoRootFlag := flag.String("repo-root", ".", "Repository root path") - baselineFlag := flag.String("baseline", "origin/main...HEAD", "Git diff baseline") + baselineFlag := flag.String("baseline", "origin/development...HEAD", "Git diff baseline") backendCoverageFlag := flag.String("backend-coverage", "backend/coverage.txt", "Backend Go coverage profile") frontendCoverageFlag := flag.String("frontend-coverage", "frontend/coverage/lcov.info", "Frontend LCOV coverage report") jsonOutFlag := flag.String("json-out", "test-results/local-patch-report.json", "Path to JSON output report") diff --git a/backend/cmd/localpatchreport/main_test.go b/backend/cmd/localpatchreport/main_test.go index efe4cebf..df04b8f8 100644 --- a/backend/cmd/localpatchreport/main_test.go +++ b/backend/cmd/localpatchreport/main_test.go @@ -240,7 +240,7 @@ func TestGitDiffAndWriters(t *testing.T) { } report := reportJSON{ - Baseline: "origin/main...HEAD", + Baseline: "origin/development...HEAD", GeneratedAt: "2026-02-17T00:00:00Z", Mode: "warn", Thresholds: thresholdJSON{Overall: 90, Backend: 85, Frontend: 85}, @@ -271,7 +271,7 @@ func TestGitDiffAndWriters(t *testing.T) { if err != nil { t.Fatalf("read json file: %v", err) } - if !strings.Contains(string(jsonBytes), "\"baseline\": \"origin/main...HEAD\"") { + if !strings.Contains(string(jsonBytes), "\"baseline\": \"origin/development...HEAD\"") { t.Fatalf("unexpected json content: %s", string(jsonBytes)) } @@ -392,7 +392,7 @@ func TestWriteJSONReturnsErrorWhenPathIsDirectory(t *testing.T) { func TestWriteMarkdownReturnsErrorWhenPathIsDirectory(t *testing.T) { dir := t.TempDir() report := reportJSON{ - Baseline: "origin/main...HEAD", + Baseline: "origin/development...HEAD", GeneratedAt: "2026-02-17T00:00:00Z", Mode: "warn", Thresholds: thresholdJSON{Overall: 90, Backend: 85, Frontend: 85}, @@ -581,7 +581,7 @@ func TestMain_WarnsForInvalidThresholdEnv(t *testing.T) { func TestWriteMarkdownIncludesArtifactsSection(t *testing.T) { report := reportJSON{ - Baseline: "origin/main...HEAD", + Baseline: "origin/development...HEAD", GeneratedAt: "2026-02-17T00:00:00Z", Mode: "warn", Thresholds: thresholdJSON{Overall: 90, Backend: 85, Frontend: 85}, @@ -707,7 +707,7 @@ func TestAssertFileExistsErrorMessageIncludesLabel(t *testing.T) { func TestWriteJSONContentIncludesTrailingNewline(t *testing.T) { path := filepath.Join(t.TempDir(), "out.json") - report := reportJSON{Baseline: "origin/main...HEAD", GeneratedAt: "2026-02-17T00:00:00Z", Mode: "warn"} + report := reportJSON{Baseline: "origin/development...HEAD", GeneratedAt: "2026-02-17T00:00:00Z", Mode: "warn"} if err := writeJSON(path, report); err != nil { t.Fatalf("writeJSON: %v", err) } @@ -841,7 +841,7 @@ func TestMainStderrForMissingFrontendCoverage(t *testing.T) { func TestWriteMarkdownWithoutWarningsOrFiles(t *testing.T) { report := reportJSON{ - Baseline: "origin/main...HEAD", + Baseline: "origin/development...HEAD", GeneratedAt: "2026-02-17T00:00:00Z", Mode: "warn", Thresholds: thresholdJSON{Overall: 90, Backend: 85, Frontend: 85}, @@ -1026,7 +1026,7 @@ func TestMainProcessHelperWithMalformedArgsExitsNonZero(t *testing.T) { func TestWriteMarkdownContainsSummaryTable(t *testing.T) { report := reportJSON{ - Baseline: "origin/main...HEAD", + Baseline: "origin/development...HEAD", GeneratedAt: "2026-02-17T00:00:00Z", Mode: "warn", Thresholds: thresholdJSON{Overall: 90, Backend: 85, Frontend: 85}, diff --git a/docs/issues/local_patch_report_dod_manual_checklist.md b/docs/issues/local_patch_report_dod_manual_checklist.md index 6668efe3..9fae1e8c 100644 --- a/docs/issues/local_patch_report_dod_manual_checklist.md +++ b/docs/issues/local_patch_report_dod_manual_checklist.md @@ -27,7 +27,7 @@ Validate that local patch-report workflow is executed in Definition of Done (DoD - [ ] `test-results/local-patch-report.md` - [ ] `test-results/local-patch-report.json` - [ ] Confirm JSON includes: - - [ ] `baseline = origin/main...HEAD` + - [ ] `baseline = origin/development...HEAD` (or `development...HEAD` when remote ref is unavailable) - [ ] `mode = warn` - [ ] `overall`, `backend`, `frontend` coverage blocks - [ ] `files_needing_coverage` list diff --git a/scripts/local-patch-report.sh b/scripts/local-patch-report.sh index 7d2aa5ee..aa814c7c 100755 --- a/scripts/local-patch-report.sh +++ b/scripts/local-patch-report.sh @@ -2,7 +2,7 @@ set -euo pipefail ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" -BASELINE="${CHARON_PATCH_BASELINE:-origin/main...HEAD}" +BASELINE="${CHARON_PATCH_BASELINE:-}" BACKEND_COVERAGE_FILE="$ROOT_DIR/backend/coverage.txt" FRONTEND_COVERAGE_FILE="$ROOT_DIR/frontend/coverage/lcov.info" JSON_OUT="$ROOT_DIR/test-results/local-patch-report.json" @@ -62,6 +62,16 @@ if ! command -v go >/dev/null 2>&1; then exit 1 fi +if [[ -z "$BASELINE" ]]; then + if git -C "$ROOT_DIR" rev-parse --verify --quiet "origin/development^{commit}" >/dev/null; then + BASELINE="origin/development...HEAD" + elif git -C "$ROOT_DIR" rev-parse --verify --quiet "development^{commit}" >/dev/null; then + BASELINE="development...HEAD" + else + BASELINE="origin/development...HEAD" + fi +fi + if [[ ! -f "$BACKEND_COVERAGE_FILE" ]]; then write_preflight_artifacts "backend coverage input missing at $BACKEND_COVERAGE_FILE" echo "Error: backend coverage input missing at $BACKEND_COVERAGE_FILE" >&2 @@ -80,7 +90,7 @@ if [[ "$BASELINE" == *"..."* ]]; then fi if [[ -n "$BASE_REF" ]] && ! git -C "$ROOT_DIR" rev-parse --verify --quiet "${BASE_REF}^{commit}" >/dev/null; then - echo "Error: baseline base ref '$BASE_REF' is not available locally. Set CHARON_PATCH_BASELINE to a valid range and retry." >&2 + echo "Error: baseline base ref '$BASE_REF' is not available locally. Set CHARON_PATCH_BASELINE to a valid range and retry (default attempts origin/development, then development)." >&2 exit 1 fi