Repository navigation
Use less time on the GPU runner in the CI #465
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
908c310
Use less time on the GPU runner in the CI
kozlov721 bfe076a
Let the RVC2 HubAI conversion test fail for now
kozlov721 8ab034c
Fix the tests that fail on main
kozlov721 46d61dc
Start the GPU suites after the CPU suite passes
kozlov721 52e8004
Show a clean name for a skipped GPU test job
kozlov721 c3c19b0
Clean up the comments and docstrings of the CI test split
kozlov721 c354332
ci: run checks for documentation-only changes
kozlov721 8ca2426
tests: run archive-only combinations test on CPU
kozlov721 82f350d
tests: restore HubAI conversion checks
kozlov721 6c96acb
xfail
kozlov721 2fe38e6
fixed tests
klemen1999 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| """Tell whether a branch changes only its documentation. | ||
|
|
||
| Exit with 0 when each changed file is a Markdown file, ``.gitignore``, | ||
| ``.pre-commit-config.yaml``, ``pyproject.toml`` with changes in | ||
| ``DOC_TABLES`` only, or a Python file whose syntax tree without | ||
| docstrings stays the same. Otherwise exit with 1 and name the file. | ||
|
|
||
| Usage: ``python scripts/only_docstrings_changed.py <base-commit>`` | ||
|
|
||
| """ | ||
|
|
||
| import ast | ||
| import subprocess | ||
| import sys | ||
|
|
||
| DOC_TABLES = ( | ||
| "tool.docformatter", | ||
| "tool.pydoctor", | ||
| "tool.pyright", | ||
| "tool.ruff", | ||
| ) | ||
| IGNORED = {".gitignore", ".pre-commit-config.yaml"} | ||
|
|
||
|
|
||
| def git(*args: str) -> str: | ||
| """Run git and return its output.""" | ||
| return subprocess.run( | ||
| ["git", *args], # noqa: S607 | ||
| check=True, | ||
| capture_output=True, | ||
| text=True, | ||
| ).stdout | ||
|
|
||
|
|
||
| def is_bare_string(statement: ast.stmt) -> bool: | ||
| """Tell whether a statement is a string literal and nothing else.""" | ||
| return ( | ||
| isinstance(statement, ast.Expr) | ||
| and isinstance(statement.value, ast.Constant) | ||
| and isinstance(statement.value.value, str) | ||
| ) | ||
|
|
||
|
|
||
| def code_of(source: str) -> str: | ||
| """Dump the syntax tree of ``source`` without its docstrings. | ||
|
|
||
| A string literal that stands as a statement has no effect, so the | ||
| docstrings of attributes go too. | ||
|
|
||
| """ | ||
| tree = ast.parse(source) | ||
| for node in ast.walk(tree): | ||
| for field in ("body", "orelse", "finalbody"): | ||
| statements = getattr(node, field, None) | ||
| if isinstance(statements, list): | ||
| setattr( | ||
| node, | ||
| field, | ||
| [s for s in statements if not is_bare_string(s)], | ||
| ) | ||
| return ast.dump(tree) | ||
|
|
||
|
|
||
| def without_doc_tables(pyproject: str) -> list[str]: | ||
| """Drop the tables of ``DOC_TABLES`` from ``pyproject.toml``.""" | ||
| kept = [] | ||
| keep = True | ||
| for line in pyproject.splitlines(): | ||
| if line.startswith("["): | ||
| keep = not line.strip("[] ").startswith(DOC_TABLES) | ||
| if keep: | ||
| kept.append(line) | ||
| return kept | ||
|
|
||
|
|
||
| def main(base: str) -> int: | ||
| merge_base = git("merge-base", base, "HEAD").strip() | ||
| changes = git("diff", "--name-status", "--no-renames", merge_base, "HEAD") | ||
| for line in changes.splitlines(): | ||
| status, path = line.split("\t") | ||
| if path.endswith(".md") or path in IGNORED: | ||
| continue | ||
| if path == "pyproject.toml": | ||
| compare = without_doc_tables | ||
| elif path.endswith(".py"): | ||
| compare = code_of | ||
| else: | ||
| print(f"{path}: not a documentation file") | ||
| return 1 | ||
| if status != "M": | ||
| print(f"{path}: added or removed") | ||
| return 1 | ||
| before = git("show", f"{merge_base}:{path}") | ||
| after = git("show", f"HEAD:{path}") | ||
| if compare(before) != compare(after): | ||
| print(f"{path}: the code changed") | ||
| return 1 | ||
| print("Only the documentation changed.") | ||
| return 0 | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| sys.exit(main(sys.argv[1])) |
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.