Repository navigation
feat(test): forge test flakes --issues --stale-after closes stale flake issues from CI - #2795
Open
reliant-01 wants to merge 2 commits into
Open
reliant-01 wants to merge 2 commits into
reliant-01 wants to merge 2 commits into
Conversation
…ke issues from CI
Contributor
There was a problem hiding this comment.
review:changes
Lane: MEDIUM (one pass on gpt-6-luna@codex).
MEDIUM: agent-instructions (internal/templates/project/skills/forge/ci/gate/SKILL.md); code (internal/cli/test_flakes.go, internal/testflakes/issues.go)
The stale sweep can close valid flake issues when it cannot inspect the test package; this is a data-loss defect.
- blocker [B1]
internal/testflakes/issues.go:237— The gone-test path converts a failed os.Stat of a package path containing a dotted first segment into “not evidence” (correctly), but for ordinary package paths it reaches TestBody, which returns an empty string both when no test exists and when the package directory is missing or files cannot be read. Thus a typo, removed/missing checkout subtree, or transient filesystem read error closes every matching open issue as if its test were deleted. A sweep run from a partial checkout can therefore close valid issues. The sweep must distinguish a successful scan proving absence from inability to inspect. Fix: Treat stat/read/parse failures as indeterminate and leave the issue open; only close when the package is verifiably present and a successful source scan proves the test absent. Add regression cases for missing package directories and unreadable test files.
Fix the blockers and push: the push is reviewed again. (pr-fix takes over if nobody does.)
Reviewed be1a1c5ef675d65384a658ab4bc6533cf8e9c04f.
Posted by Reliant for PR pipeline · pr-review · opened, an automation of @reliant-01.
…scan of its package
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
forge test flakes --issuescloses an openflake:suspectedissue only when the local test record (.forge/tests/runs/) shows its test leaving the suspected/flaky states. A CI runner is a fresh machine with an empty record, so on CI nothing is ever closed. reliant keeps a hand-writtenscripts/flake-report.sh --sweepfor this (run daily by itsflake-report.yml), and forge's own copy of that script does the same. Any forge project that files flake issues from CI needs it.Behaviour
New, additive flag:
forge test flakes --issues --stale-after <age>(7d,168h; a whole number of days or a Go duration). Without the flag nothing changes. With it, after the existing record-driven filing/commenting/closing, a sweep reads the evidence from the open issues themselves and closes each openflake:suspectedissue forge filed (titleflake:suspected: <Test> (<pkg>)) when:func <Test>(is in no*_test.goof the package directory in this checkout (needs ago.modat the root; a package path from another module is never taken as gone), or<age>. Evidence is the issue'screatedAt, or the newest comment starting "Failed then passed on retry again" (the comment forge, and flake-report.sh before it, writes on a repeat flake). Other comments don't keep an issue open.An issue whose test the local record still calls suspected/flaky is left to the record rule, so a local run never closes an issue and then reopens it. Each close comments
Closed by \forge test flakes --issues`: . A new flake of this test reopens it., and that is accurate: the filing path searches issues with--state alland reopens and comments on the closed issue instead of filing a new one.--dry-runprintswould close #N:. The flag works with an empty local record. The clock is injectable (IssueOptions.Now), so the tests never sleep.--stale-afterwithout--issues, or an age it can't parse, exits 2. ThecreatedAt,commentsfields are requested fromgh issue list` only when sweeping.Docs: the command's
--help, and theci/gateskill (a new paragraph on flake issues from CI).Tests
internal/testflakes:TestSyncIssuesStaleAfter, a table over the empty record: a stale issue is closed with a comment; a fresh one is kept; a forge evidence comment resets the age, an old one doesn't; a non-forge comment doesn't; a gone test is closed even when fresh; an hours duration works; dry-run writes nothing; no flag means no sweep; a hand-filed title is left alone; a test the record still calls a flake is left alone. AlsoTestSyncIssuesAsksForDatesOnlyToSweepandTestParseStaleAfter.internal/cli:TestRunTestFlakesStaleAfter(usage errors; a sweep from an empty record closes a gone test's issue).task test:short -- ./internal/testflakes/...,task test -- ./internal/testflakes/...(-race),go test -short -run Flake ./internal/cli/, the new tests with-count=3,go build ./...,go vet,scripts/ci-golangci-changed.sh(0 issues), andgo test -short -run Skill ./internal/templates/....Post-merge check
After this ships in a forge release reliant pins: in reliant, run
forge test flakes --issues --stale-after 7d --dry-runfrom main. Itswould closelines should matchscripts/flake-report.sh --sweep --dry-run(except for any hand-filed issues, which forge leaves alone). Then reliant'sflake-report.ymlsweep step can call forge, and--sweepcan be deleted from the script.Rollback
Revert this commit. The flag is new and opt-in, so no existing invocation depends on it. Issues it closed stay closed, and a later flake reopens them as before.