fix: write skills-state.json updated_at in local timezone#1777
fix: write skills-state.json updated_at in local timezone#1777zhangheng023 wants to merge 2 commits into
Conversation
Local git tooling that hooks trace2 (e.g. a global trace2.eventtarget socket listener) can asynchronously write into a repo's .git/ shortly after a git command runs. This races with t.TempDir's automatic RemoveAll cleanup and intermittently fails tests with "directory not empty", unrelated to the code under test.
📝 WalkthroughWalkthroughTest files in qualitygate (diff, publiccontent, rules) add a ChangesGit test repo cleanup helper
Estimated code review effort: 2 (Simple) | ~10 minutes SkillsState UpdatedAt Timezone Fix
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1777 +/- ##
==========================================
+ Coverage 74.43% 74.46% +0.03%
==========================================
Files 854 855 +1
Lines 88490 88568 +78
==========================================
+ Hits 65867 65954 +87
+ Misses 17554 17543 -11
- Partials 5069 5071 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
🚀 PR Preview Install Guide🧰 CLI updatenpm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@e01132227dfcbb6216cdeeb40212daba7d35499e🧩 Skill updatenpx skills add larksuite/cli#fix/skill-state-local-time -y -g |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
internal/qualitygate/diff/diff_test.go (1)
143-161: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winConsider extracting
newGitTestRepointo a shared test helper.This exact helper (comment, retry loop, and cleanup logic) is duplicated verbatim in
internal/qualitygate/publiccontent/collect_test.goandinternal/qualitygate/rules/run_test.go. Consolidating into a shared internal test-support package underinternal/qualitygatewould avoid triple maintenance if the retry strategy ever needs tuning.The retry/cleanup logic itself is correct:
t.Cleanupregistered aftert.TempDir()'s own cleanup runs first (LIFO), so the retry loop removes the tree beforet.TempDir's cleanup runs, making it a no-op.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/qualitygate/diff/diff_test.go` around lines 143 - 161, The `newGitTestRepo` helper is duplicated verbatim across multiple test files, so extract it into a shared internal test-support helper under `internal/qualitygate` and update the callers to use that shared function. Keep the existing `t.TempDir`, `t.Cleanup`, retry loop, and `os.RemoveAll`/`time.Sleep` behavior intact in the shared helper so `diff_test.go`, `collect_test.go`, and `run_test.go` all rely on one implementation.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@internal/qualitygate/diff/diff_test.go`:
- Around line 143-161: The `newGitTestRepo` helper is duplicated verbatim across
multiple test files, so extract it into a shared internal test-support helper
under `internal/qualitygate` and update the callers to use that shared function.
Keep the existing `t.TempDir`, `t.Cleanup`, retry loop, and
`os.RemoveAll`/`time.Sleep` behavior intact in the shared helper so
`diff_test.go`, `collect_test.go`, and `run_test.go` all rely on one
implementation.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 595f1c26-2443-462e-b9c2-050a6309adff
📒 Files selected for processing (5)
internal/qualitygate/diff/diff_test.gointernal/qualitygate/publiccontent/collect_test.gointernal/qualitygate/rules/run_test.gointernal/skillscheck/sync.gointernal/skillscheck/sync_test.go
Summary
lark-cli updatewritesupdated_atinto the local skill-sync state file (skills-state.json) using a fixed UTC timestamp regardless of the host's timezone. This PR switches it to the local timezone so the timestamp is meaningful to a human reading the file.Changes
internal/skillscheck/sync.go: drop.UTC()on bothUpdatedAtassignments (incremental-sync path and fallback-install path) soopts.Now().Format(time.RFC3339)reflects the local timezoneinternal/skillscheck/sync_test.go: add two tests asserting a non-UTC injected clock is written verbatim (e.g.+08:00, notZ)internal/qualitygate/{diff,publiccontent,rules}: retryTempDircleanup for test-created git repos, fixing an unrelated pre-existing flaky "directory not empty" failure caused by a local git hook racing with test cleanupTest Plan
go test ./internal/skillscheck/... -vpassedgo build ./...passedRelated Issues
N/A
Summary by CodeRabbit
Bug Fixes
Tests