diff --git a/.github/workflows/jsweep.md b/.github/workflows/jsweep.md index 96f71d1e830..414fef04479 100644 --- a/.github/workflows/jsweep.md +++ b/.github/workflows/jsweep.md @@ -90,7 +90,7 @@ fi - Exclude test files (`*.test.cjs`) - Exclude files already listed in `cleaned_files` in the loaded state - **Priority 1**: Pick files with `@ts-nocheck` or `// @ts-nocheck` comments (these need type checking enabled) -- **Priority 2**: If no uncleaned files with `@ts-nocheck` remain, pick the **one file** with the earliest modification timestamp that hasn't been cleaned +- **Priority 2**: If no uncleaned files with `@ts-nocheck` remain, determine the last-committed timestamp for each uncleaned file by running `git log --format="%at" --follow -- | head -1` (empty output means the file has never been committed; treat it as timestamp `0`). Sort ascending by that timestamp and pick the **one file** with the earliest git commit timestamp. This ordering is deterministic across CI machines and fresh checkouts, and files never touched by git automatically bubble to the top. If no uncleaned files remain, start over with the oldest cleaned file (reset `cleaned_files` to only the one just chosen). diff --git a/pkg/workflow/jsweep_workflow_test.go b/pkg/workflow/jsweep_workflow_test.go index 0a8e669c63f..62cb48566a0 100644 --- a/pkg/workflow/jsweep_workflow_test.go +++ b/pkg/workflow/jsweep_workflow_test.go @@ -190,6 +190,19 @@ func TestJSweepWorkflowConfiguration(t *testing.T) { t.Error("jsweep workflow should batch validation commands into a single chained command") } }) + + // Test 16: Verify Priority 2 uses git-based deterministic ordering + t.Run("GitBasedDeterministicOrdering", func(t *testing.T) { + if !strings.Contains(mdContent, "git log --format") { + t.Error("jsweep workflow Priority 2 should use git log for deterministic file ordering") + } + if strings.Contains(mdContent, "earliest modification timestamp") { + t.Error("jsweep workflow should not use filesystem modification timestamps for file ordering") + } + if !strings.Contains(mdContent, "deterministic") { + t.Error("jsweep workflow should describe the ordering as deterministic") + } + }) } // TestJSweepWorkflowLockFile validates that the compiled jsweep.lock.yml file