Repository navigation
Conversation
PR Status: Approved 🚀Please fix all CI failures and trigger merge by commenting "@pytorchbot merge". ✅ AUTOMATED REVIEW - OUTDATED (earlier commit) - Ready for human review:
Findings (11): Reviewed commit: 🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/203772
Note: Links to docs will display an error until the docs builds have been completed. ⏳ No Failures, 1 PendingAs of commit c6f9068 with merge base 5f22867 ( 🟡 GREEN LIGHT - OUTDATED (earlier commit) - PR requires human review:
reason: This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
@claude Review this change |
|
Claude finished @huydhn's task in 6m 0s —— View job The linter looks like it never fires under lintrunner: it matches the file paths lintrunner passes in against repo-relative paths, and lintrunner passes absolute ones. Details below. PR Review: #203772SummaryThis PR adds a Code Quality
RecommendationRequest Changes The path mismatch probably makes the lintrunner integration a no-op, so editing a workflow wouldn't catch a new duplicate until the |
235067d to
f56bae4
Compare
There was a problem hiding this comment.
Automated review of f56bae4: nothing blocking; ready for human review.
This PR adds a WORKFLOWDUP lintrunner linter, with tests. It fails when the same test config (build-environment, config, runner) runs from two workflows that test main. Recommendation: Approve, with no blocking issues; every point the review raises is non-blocking, and the most useful follow-up is to also report on the root (calling) workflow.
⚪ 11 non-blocking findings
Non-blocking: a change made only in a calling workflow gets no lint message. if o.path not in linted: continue reports only on the file that defines the job, and o.root (the workflow that triggers it) is never checked. On PRs lintrunner gets only the changed files (lint.yml:37, .github/scripts/lintrunner.sh:16, .spin/cmds.py:435). So a PR that only adds uses: ./.github/workflows/dynamo-unittest.yml to pull.yml gets no WORKFLOWDUP annotation, even though trunk.yml:49 already calls that workflow. The same happens when a schedule: is added to a workflow whose jobs live in a reusable workflow. CI would still fail through test_repo_has_no_duplicates in test-tools, but only as a raw dict diff with no file or line, and local lintrunner misses it entirely. The PR body's claim that the lint "would have caught" the # 198271 overlap holds only if that PR also touched the called file. Fix: also emit a message when o.root is among the linted files, anchored at the root's uses: job.
Non-blocking: one problem can produce two messages that point at the wrong places. When one reusable workflow is called from two roots (the test_called_workflow_runs_from_two_workflows case), you get two errors on the same line of the reusable file: one says "also runs from pull.yml", the other "also runs from trunk.yml". The fix belongs in one of the callers, not in the flagged file, so "Remove one" is misleading. The message also never says which file and job define the other copy.
Non-blocking: the ALLOWLIST is broader than the duplicate key. It matches only on (build_environment, config), with no runner and no workflows, so it would also hide a future third workflow running cuda13.2 default/distributed on any runner. Nothing fails when an entry goes stale, so the allowlist will not shrink on its own. Consider keying it on the full TestConfig plus the set of roots, and adding a test that each entry still matches something.
Non-blocking: real duplicates slip through. ENTRY strips only a leading ${{}}, so a literal mt- prefix stays in the runner key (inductor-periodic.yml:48, slow.yml:61). But runner_determinator.py:96/:698 resolves the label-type prefix to that same mt- by default, so mt-l-x86aavx2-11-41-a10g and ${{ label-type }}l-x86aavx2-11-41-a10g count as different machines. Separately (line 136), a test-matrix written directly on a test job is never counted, because nothing reads needs.<job>.outputs.test-matrix, e.g. trunk.yml:238-254 (cross-compile-linux-test-cuda132). Neither gap hides a duplicate today, but the docstring mentions neither.
Non-blocking: stale comment and names. The comment says this cron becomes "mem_leak_check and rerun_disabled_tests runs", but SUPPORTED_PERIODICAL_MODES (.github/scripts/filter_test_configs.py:35-39) now holds only rerun_disabled_tests. The names MEM_LEAK_CHECK_CRON and the test's ON_MEM_LEAK_CHECK are misleading for the same reason. Add a pointer to filter_test_configs.py:691 so the two copies of the cron string don't drift apart.
Non-blocking: a malformed or empty file anywhere under .github/workflows crashes the linter. Every workflow is loaded with no guard; an empty file gives None, and tests_main(None) then raises AttributeError. The crash is reported as an opaque linter failure on whichever PR touches a workflow. gha_linter.py:59-75 shows the sibling pattern of turning load errors into a LintMessage.
Non-blocking: test-matrix is parsed with a line regex, not the way CI parses it. CI reads the same string with yaml.safe_load and iterates include (filter_test_configs.py:636). The regex silently skips any entry that isn't on one line with config before runner in double quotes, and entries with no runner (e.g. trunk.yml:151). Parsing the substituted string with yaml.safe_load and walking ["include"] would match CI and remove these silent false negatives if matrices are reformatted.
Non-blocking: test_lint_takes_absolute_paths reads the real file from disk. lint() calls job_line(), which reads the real .github/workflows/pull.yml even though the test passes made-up workflow contents. The real pull.yml has no build: job, so line comes back None. The test doesn't check line, so job_line is untested, and the test breaks if pull.yml is renamed.
Non-blocking: test_repo_has_no_duplicates cannot catch a broken parser. It asserts {}, which is also what a parser that finds nothing returns, e.g. if the regex stops matching or called workflows stop resolving. Also asserting that, without the ALLOWLIST, the two cuda13.2 pairs are still found would make it a real check.
Non-blocking: the unit tests use simplified forms that don't match the real workflows. Called workflows use ./dynamo.yml instead of ./.github/workflows/. The matrix key is version, while real workflows use the hyphenated python-version (dynamo-unittest.yml:40), so a regression in MATRIX_REF's \[w-\]+ would not be caught.
Non-blocking: the linter uses pure-Python yaml.SafeLoader and parses every workflow on every run, including the ~2k-line generated binary workflows. It is registered in VERY_FAST_LINTERS (.spin/cmds.py, documented as under 3s of CPU time). The siblings workflow_consistency_linter.py:33-36 and no_workflows_on_fork.py:41-44 use CSafeLoader with a SafeLoader fallback; use the same block here. (Not timed offline.)
This review is AI-generated and advisory. Each new automated review replaces the previous one. Report a bad review
|
@pytorchbot review |
|
The automated review only re-runs on PRs labeled |
georgehong
left a comment
There was a problem hiding this comment.
Change makes sense to me! Looks great for reducing redundantly run test configs.
|
@pytorchbot rebase |
|
@pytorchbot started a rebase job onto refs/remotes/origin/viable/strict. Check the current status here |
|
Merged |
f6831f9 to
90477f5
Compare
90477f5 to
5dc4a2a
Compare
#198271 moved pull from py3.10 to py3.11 without noticing that trunk's dynamo-unittest already ran py3.11 dynamo_wrapped, so the same shards ran twice on every commit for six weeks. Nothing flagged it because no check compares test configs across workflows. WORKFLOWDUP collects (build-environment, test config, runner) from every workflow that runs on a push to main or on a schedule, including the reusable workflows they call, and fails when the same triple runs from two of them. A reusable workflow called from two such workflows counts twice. The 29 8 * * * schedule is not counted, since filter_test_configs.py turns it into mem_leak_check and rerun_disabled_tests runs. A build job's test-matrix only counts when a test job reads it. Different runners count as different configs, which keeps trunk's Graviton3 aarch64 shards (run for SVE256 coverage) apart from pull's Graviton4 ones. periodic.yml's CUDA 13.2 default and distributed configs repeat trunk's on a schedule and are allowlisted for now. Test Plan: ``` PYTHONPATH=$(pwd) python3 -m pytest -q tools/test/test_workflow_duplicate_jobs_linter.py uv run --python 3.11 --script tools/linter/adapters/workflow_duplicate_jobs_linter.py -- .github/workflows/pull.yml ``` The linter is clean on this stack. With main's pull.yml restored, `lintrunner --take WORKFLOWDUP .github/workflows/pull.yml` flags its py3.11 and py3.14 dynamo_wrapped jobs. Authored with an AI assistant (Claude Code).
5dc4a2a to
0dda8b9
Compare
cpp-faketensor-weekly.yml reruns trunk, pull and inductor-unittest configs with fake_tensor: "cpp", which sets CPP_FAKETENSOR=1 and so tests a different code path. Keying only on build-environment, config and runner flagged all six as duplicates and failed test_repo_has_no_duplicates.
#203884 moved dynamo-unittest's build and test jobs into _dynamo-unittest-python.yml, which takes the Python version and runner as inputs. The linter treated every _ workflow as a leaf and never filled in ${{ inputs.* }}, so it no longer saw those configs and a py3.11 dynamo_wrapped re-added to pull.yml went unflagged. Follow any local workflow call until a job passes a test-matrix, carrying the caller's with: values as inputs. Also handle matrix include: entries and the ${{ x || 'default' }} form, which dynamo-unittest.yml uses to put 3.14t on a bigger runner. Drop the lint message tweak from the previous commit.
|
@pytorchbot merge -f 'Linter only' |
Merge startedYour change will be merged immediately since you used the force (-f) flag, bypassing any CI checks (ETA: 1-5 minutes). Please use Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Summary (human written only)
This is to prevent similar mistake of having duplicated test configs on CI.
Agent details (if applicable)
cc @jgong5 @mingfeima @XiaobingSuper @sanchitintel @ashokei @jingxu10 @aditew01 @voznesenskym @penguinwu @EikanWang @Guobing-Chen @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @kadeng @muchulee8 @amjames @chauhang @aakhundov @coconutruben @jataylo