Skip to content

test: synchronize temporary Git maintenance#1946

Merged
luozhixiong01 merged 1 commit into
mainfrom
fix/publiccontent-tempdir-race
Jul 20, 2026
Merged

test: synchronize temporary Git maintenance#1946
luozhixiong01 merged 1 commit into
mainfrom
fix/publiccontent-tempdir-race

Conversation

@luozhixiong01

@luozhixiong01 luozhixiong01 commented Jul 18, 2026

Copy link
Copy Markdown
Collaborator

Summary

Temporary Git repositories in tests could be cleaned up while Git 2.54 automatic maintenance was still writing .git/objects/maintenance.lock. This change keeps automatic maintenance inside the invoking Git command lifecycle at every confirmed temporary-repository write site, without retries, sleeps, or production behavior changes.

Changes

  • Add internal/testutil/gitcmd with fixed command- and environment-scoped maintenance synchronization for root-module tests
  • Route temporary Git writes in publiccontent, diff, rules, and apps tests through the shared helper while preserving existing hook isolation
  • Apply the same fixed synchronization contract locally in the independent lint module and cover both Git version paths with contract tests

Test Plan

  • Harness validate passed: build, vet, unit, integration, convention, and security checks
  • Related root and lint packages passed go test -race -count=5
  • Real Git apps tests passed 10 consecutive runs
  • TRACE2 observed git maintenance run --auto --no-quiet --no-detach finishing before the parent Git process exited
  • Acceptance review passed 2/2 bounded scenarios
  • Local E2E skipped: test-only lifecycle change with no matching existing apps-init E2E case

Related Issues

N/A

Summary by CodeRabbit

  • Bug Fixes
    • Improved Git-based test execution to keep Git maintenance from running in detached background mode, reducing flakiness during temporary resource cleanup.
    • Preserved existing behavior that prevents external verification/hook execution during commit-related test operations.
  • Tests
    • Added/expanded coverage to confirm Git is run with the detached maintenance auto settings disabled.
    • Updated Git-related tests to use a shared test helper that enforces synchronous Git maintenance behavior.

@luozhixiong01 luozhixiong01 added the bugfix Bug fixes label Jul 18, 2026
@github-actions github-actions Bot added the size/S Low-risk docs, CI, test, or chore only changes label Jul 18, 2026
@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Git test helpers now disable detached automatic maintenance for Git commands, migrate test Git invocations to the shared helper, and add regression coverage for command and environment configuration.

Changes

Synchronous Git maintenance

Layer / File(s) Summary
Implement synchronous Git helpers
internal/testutil/gitcmd/*
Adds shared Git command and environment helpers that disable detached maintenance and validate the resulting configuration.
Migrate Git test commands
internal/qualitygate/*, shortcuts/apps/apps_init_test.go
Updates test Git subprocess helpers to use the shared command constructor while preserving repository context, arguments, commit handling, and output behavior.
Apply maintenance settings to real-Git tests
lint/errscontract/scan_test.go, shortcuts/apps/apps_init_test.go
Configures synchronous maintenance in real-Git tests and verifies both maintenance settings through Git configuration queries.

Estimated code review effort: 2 (Simple) | ~15 minutes

Suggested labels: feature

Suggested reviewers: liangshuo-1

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title is concise and accurately summarizes the main change: synchronizing temporary Git maintenance in tests.
Description check ✅ Passed The description matches the template with Summary, Changes, Test Plan, and Related Issues filled in clearly.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/publiccontent-tempdir-race

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Jul 18, 2026

Copy link
Copy Markdown

🚀 PR Preview Install Guide

🧰 CLI update

npm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@c76904c3560a6c1f5a261e0f43f4986d5893e24a

🧩 Skill update

npx skills add larksuite/cli#fix/publiccontent-tempdir-race -y -g

@codecov

codecov Bot commented Jul 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.66667% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.03%. Comparing base (44514ad) to head (c76904c).

Files with missing lines Patch % Lines
internal/testutil/gitcmd/gitcmd.go 91.66% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1946   +/-   ##
=======================================
  Coverage   75.02%   75.03%           
=======================================
  Files         894      895    +1     
  Lines       94294    94318   +24     
=======================================
+ Hits        70746    70768   +22     
- Misses      18137    18138    +1     
- Partials     5411     5412    +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@luozhixiong01
luozhixiong01 force-pushed the fix/publiccontent-tempdir-race branch from a68c431 to 299718f Compare July 18, 2026 09:47
@luozhixiong01 luozhixiong01 changed the title test: isolate publiccontent git hooks test: synchronize publiccontent Git maintenance Jul 18, 2026
@luozhixiong01
luozhixiong01 force-pushed the fix/publiccontent-tempdir-race branch from 299718f to c76904c Compare July 20, 2026 03:42
@luozhixiong01 luozhixiong01 changed the title test: synchronize publiccontent Git maintenance test: synchronize temporary Git maintenance Jul 20, 2026
@github-actions github-actions Bot added size/M Single-domain feat or fix with limited business impact and removed size/S Low-risk docs, CI, test, or chore only changes labels Jul 20, 2026
@luozhixiong01
luozhixiong01 merged commit 9dd355a into main Jul 20, 2026
27 of 55 checks passed
@luozhixiong01
luozhixiong01 deleted the fix/publiccontent-tempdir-race branch July 20, 2026 08:30
@liangshuo-1 liangshuo-1 mentioned this pull request Jul 20, 2026
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Bug fixes size/M Single-domain feat or fix with limited business impact

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants