Skip to content

Gitdiff v2#5752

Closed
Gongxl972 wants to merge 9 commits into
deepmodeling:masterfrom
Gongxl972:gitdiff-v2
Closed

Gitdiff v2#5752
Gongxl972 wants to merge 9 commits into
deepmodeling:masterfrom
Gongxl972:gitdiff-v2

Conversation

@Gongxl972

@Gongxl972 Gongxl972 commented Jul 8, 2026

Copy link
Copy Markdown

Modify the test_python.ymlworkflow and add several Python helper scripts under .github/scripts/.
The new scripts discover all test files, analyze test-to-source dependencies, and generate a .global_test_mapping.jsoncache file.
Subsequent test runs will only execute tests mapped to changed source files, reducing CI runtime.

Summary by CodeRabbit

  • New Features

    • CI now uses change-aware test selection, so only impacted tests run when possible.
    • Test results and durations are tracked more consistently across runs.
  • Bug Fixes

    • Improved handling for unclear or incomplete change detection by safely falling back to broader test runs.
    • Added better support for identifying affected tests from source changes.

Gongxl972 and others added 8 commits June 23, 2026 15:10
Signed-off-by: Gongxl972 <141223555+Gongxl972@users.noreply.github.com>
Signed-off-by: Gongxl972 <141223555+Gongxl972@users.noreply.github.com>
Signed-off-by: Gongxl972 <141223555+Gongxl972@users.noreply.github.com>
Signed-off-by: Gongxl972 <141223555+Gongxl972@users.noreply.github.com>
Signed-off-by: Gongxl972 <141223555+Gongxl972@users.noreply.github.com>
Signed-off-by: Gongxl972 <141223555+Gongxl972@users.noreply.github.com>
Signed-off-by: Gongxl972 <141223555+Gongxl972@users.noreply.github.com>
@dosubot dosubot Bot added the build label Jul 8, 2026
@github-actions github-actions Bot added the Python label Jul 8, 2026
Signed-off-by: Gongxl972 <141223555+Gongxl972@users.noreply.github.com>
@Gongxl972 Gongxl972 closed this Jul 8, 2026
@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 381f7923-dd01-4eb8-9fbb-01782d85b8d1

📥 Commits

Reviewing files that changed from the base of the PR and between d8892c7 and 70c8936.

📒 Files selected for processing (4)
  • .github/scripts/build-global-mapping.py
  • .github/scripts/detect_affected_tests.py
  • .github/workflows/test_python.yml
  • deepmd/dpmodel/atomic_model/gitdiff_test_file.py

📝 Walkthrough

Walkthrough

Adds two CI scripts (build-global-mapping.py, detect_affected_tests.py) that build a source-to-test dependency mapping and detect affected tests from changed files, reworks test_python.yml to gate full vs. incremental pytest runs using them, and includes an unrelated stray module with a commented-out class.

Changes

Incremental Python test selection

Layer / File(s) Summary
Global test mapping builder
.github/scripts/build-global-mapping.py
Parses test file ASTs to detect deepmd dependencies and test_ functions, then writes a sorted .global_test_mapping.json.
Affected-tests detection script
.github/scripts/detect_affected_tests.py
Determines changed files (via env vars or git diff), loads the global mapping, classifies changed files, and outputs selected_paths/need_full_test/skip_all.
Workflow early-detection and mapping build jobs
.github/workflows/test_python.yml
Adds early-detection job to compute changed files and force_full_test, and build-global-mapping job to rebuild/reuse and upload the mapping artifact.
Testpython job rework
.github/workflows/test_python.yml
Reworks the testpython matrix/dependencies, adds syntax checks, downloads the mapping, determines test scope, and runs full or incremental pytest with a conditional TF2 eager run.
Durations caching and pass job updates
.github/workflows/test_python.yml
Updates per-shard duration artifact handling, merges durations in update_durations, and updates the final pass job dependencies with alls-green.

Unrelated stray file

Layer / File(s) Summary
Stray module addition
deepmd/dpmodel/atomic_model/gitdiff_test_file.py
Adds a new file with a commented-out DPEnergyAtomicModel class declaration and an __init__ method validating fitting type and delegating to DPAtomicModel.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Workflow as test_python.yml
  participant Detect as detect_affected_tests.py
  participant Mapping as .global_test_mapping.json
  participant Pytest

  Workflow->>Detect: run with changed files env vars
  Detect->>Detect: get_changed_files_from_git() fallback
  Detect->>Mapping: load .global_test_mapping.json
  Mapping-->>Detect: dependency map
  Detect->>Detect: match changed files to affected_tests
  Detect-->>Workflow: selected_paths / need_full_test / skip_all
  Workflow->>Pytest: run full suite or selected_paths
Loading

Possibly related PRs

  • deepmodeling/deepmd-kit#5131: Both PRs modify .github/workflows/test_python.yml’s Python CI job matrix and how pytest is split across matrix groups.
  • deepmodeling/deepmd-kit#5611: Both PRs modify .github/workflows/test_python.yml’s test matrix selection logic and downstream duration aggregation.

Suggested reviewers: wanghan-iapcm, njzjz

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant