add new composite actions, add a stale stubs check to type check workflow, refactor shared logic into composite actions #162
Conversation
…flow, refactor shared composite actions
|
regen-ci-req-check detected changes to pinned CI requirements and uploaded a patch artifact named 'regen-pins-diff'. Top changes:
Please review the artifact and CI results. This workflow is report-only and will not open a PR; the scheduled regen workflow will open PRs automatically. |
… type stub generation to include formatting to ensure semantic diffs
There was a problem hiding this comment.
Pull Request Overview
This PR refactors CI workflows by extracting shared dependency installation logic into reusable composite actions and adds a stale stubs check to the type check workflow. The main goals are to improve maintainability by reducing code duplication and ensure type stubs remain synchronized with the codebase.
Key changes:
- Creates composite actions for installing CI dependencies and checking file differences
- Adds automated stale stub detection to prevent type checking against outdated stubs
- Updates the stub generation script to include automatic formatting
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
.github/actions/install-ci-dependencies/action.yml |
New composite action that centralizes CI dependency installation logic |
.github/actions/check-file-diffs/action.yml |
New composite action for comparing files and generating patches |
.github/workflows/type-check.yml |
Renamed and enhanced to check for stale stubs before type checking |
.github/workflows/ci_test-full.yml |
Refactored to use the new install-ci-dependencies composite action |
.github/workflows/copilot-setup-steps.yml |
Updated to use composite actions and added caching |
.github/actions/regen-ci-reqs/action.yml |
Refactored to use the new check-file-diffs composite action |
scripts/generate_op_stubs.py |
Enhanced to automatically format generated stubs |
src/interpretune/__init__.pyi |
Updated type stubs with new imports |
| env: | ||
| APPLY_POST_UPGRADES: ${{ inputs.apply_post_upgrades }} | ||
| run: | | ||
| if ([ "${APPLY_POST_UPGRADES}" = "1" ] || [ "${APPLY_POST_UPGRADES}" = "true" ]) && [ -s requirements/post_upgrades.txt ]; then |
There was a problem hiding this comment.
The condition logic is unnecessarily complex with nested brackets. Consider simplifying to if [[ "${APPLY_POST_UPGRADES}" =~ ^(1|true)$ ]] && [[ -s requirements/post_upgrades.txt ]]; then for better readability.
| if ([ "${APPLY_POST_UPGRADES}" = "1" ] || [ "${APPLY_POST_UPGRADES}" = "true" ]) && [ -s requirements/post_upgrades.txt ]; then | |
| if [[ "${APPLY_POST_UPGRADES}" =~ ^(1|true)$ ]] && [[ -s requirements/post_upgrades.txt ]]; then |
|
|
||
| # Ensure pre-commit hooks are installed | ||
| # We run install every time since it's idempotent and fast if already installed | ||
| install_result = subprocess.run(["pre-commit", "install"], capture_output=True, text=True, cwd=project_root) | ||
|
|
||
| if install_result.returncode != 0: | ||
| print(f"Warning: Failed to install pre-commit hooks: {install_result.stderr}") | ||
| print("Skipping formatting step") | ||
| return |
There was a problem hiding this comment.
Running pre-commit install on every stub generation is unnecessary overhead. Consider checking if hooks are already installed before running the install command, or document that this overhead is acceptable since it's idempotent.
| # Ensure pre-commit hooks are installed | |
| # We run install every time since it's idempotent and fast if already installed | |
| install_result = subprocess.run(["pre-commit", "install"], capture_output=True, text=True, cwd=project_root) | |
| if install_result.returncode != 0: | |
| print(f"Warning: Failed to install pre-commit hooks: {install_result.stderr}") | |
| print("Skipping formatting step") | |
| return | |
| import os | |
| # Ensure pre-commit hooks are installed only if not already present | |
| hook_path = project_root / ".git" / "hooks" / "pre-commit" | |
| if not hook_path.exists(): | |
| install_result = subprocess.run(["pre-commit", "install"], capture_output=True, text=True, cwd=project_root) | |
| if install_result.returncode != 0: | |
| print(f"Warning: Failed to install pre-commit hooks: {install_result.stderr}") | |
| print("Skipping formatting step") | |
| return |
| echo "No platform-dependent packages to install." | ||
| fi | ||
| # Make a backup of current stubs | ||
| cp src/interpretune/__init__.pyi src/interpretune/__init__.pyi.backup |
There was a problem hiding this comment.
The backup file creation appears unused since the workflow doesn't restore from it on failure. Either remove this line or add restoration logic to maintain the original state when the check fails.
| cp src/interpretune/__init__.pyi src/interpretune/__init__.pyi.backup |
add new composite actions, add a stale stubs check to type check workflow, refactor shared logic into composite actions