Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

Github Pr.Run Related Tests

БесплатноБез исполняемых скриптовНе проверен

Find and run the tests related to the code changed by a PR

gpsaggeseот gpsaggese★ 158 звёзд на GitHub

Об этом скилле

Goal

  • Given a PR, find the set of test files to run, run them on all the builds, and report the failures

Workflow

Resolve the Input

  • Resolve the argument following .claude/skills/github_pr.rules.md ## Resolve the PR Argument
  • Get the code following .claude/skills/github_pr.rules.md ## Get the Local Code of the PR

Find the Tests

  • Get the first selection of test files
    > pytest_pr_related_tests.py --pr <PR_NUM> --dry_run
    
  • The script saves the selection in tmp.pytest_pr_related_tests.tests.txt

Complete the Selection

  • The test files to run are:
    • All the test files modified by the PR
    • All the test files corresponding to the code modified by the PR
  • When undecided about a test file, run it: running more tests is better than missing a failure
  • Do not remove any test file selected by the script
  • The script uses text matching, so read the diff and look for the tests it misses
    > gh pr diff <PR_NUM>
    
    • Tests of the callers of a modified function, i.e., indirect dependencies
    • Tests of code that reads a modified config, template, rules, or data file
    • Tests of a module with a name built at run time (e.g., importlib)
  • Check each file listed under PR files without related tests
    • If it can change the behavior of every test (e.g., requirements.txt, a Dockerfile, a submodule pointer), pass --extra_targets .

Run the Tests

  • Run the selection, passing the test files that you added
    > pytest_pr_related_tests.py --pr <PR_NUM> \
        --extra_targets <TEST_FILE_1> <TEST_FILE_2> 2>&1 \
        | tee tmp.github_pr.run_related_tests.log
    
    • Omit --extra_targets if there is nothing to add
    • Run in the background and wait for the script to terminate, since it runs the tests once per build
  • The script calls pytest_multi_build.py, which calls pytest_failed_multi_build.py at the end

Check the Results

  • The exit code does not report test failures: read the tables at the end of the log
  • To print the summary again
    > pytest_failed_multi_build.py
    
  • Use tmp.pytest_failed_multi_build.repro.sh to reproduce the failures

Report

  • Save the report to github_pr.run_related_tests.<INPUT_REF>.md in the current dir
    • <INPUT_REF> is PR<PR_NUM>, or <BRANCH_NAME> if there is no PR, as in .claude/skills/skill.rules.md ### Name the Output File
  • Say in the file how it was generated, with this line right after the title:
    - Generated by `.claude/skills/github_pr.run_related_tests/SKILL.md`
    
  • Print the report and the path of the file. The report has:
    • Number of test files run, and the ones added to the script selection
    • Status of each build
    • Failed tests with the builds where they fail
  • Do not fix the failures: suggest /pytest.fix_local_tests
  • Do not comment on the PR unless the user asks for it

Conventions

  • .claude/skills/github.rules.md
  • .claude/skills/github_pr.rules.md
  • .claude/skills/pytest.rules.md

Verification

  • The output file is github_pr.run_related_tests.<INPUT_REF>.md in the current dir and has the Generated by line
  • Every test file modified by the PR is in the selection
  • Every build in the Build Statistics table is DONE
  • The report lists every failed test of tmp.pytest_failed_multi_build.failed_tests.txt
Полный SKILL.md на GitHub

Установить Github Pr.Run Related Tests в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

FAQ

Что делает скилл Github Pr.Run Related Tests?

Find and run the tests related to the code changed by a PR

Как установить скилл Github Pr.Run Related Tests?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл Github Pr.Run Related Tests запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить Github Pr.Run Related Tests с