GitHub workflow scripts#8
Conversation
🧹 Ruff — ❌ 67 new issues
Important
Tip VSCode: Set up auto-format and code actions on saveSettings UI: Search "format on save" and "code actions on save" settings.json: "editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.ruff": "explicit",
"source.organizeImports.ruff": "explicit"
}🔴 New Issues (67)⚡ UP — pyupgrade
📦 I — isort
📝 ANN — flake8-annotations
🎨 W — pycodestyle
⚡ SIM — flake8-simplify
📦 RUF — Ruff
Summary
Bot commands for this PRType
Reactions: 👀 = processing, 🚀 = all passing, 😕 = issues remain (details in reply) |
There was a problem hiding this comment.
Pull request overview
This PR introduces automated CI checks for the Python portion of the repo by adding Ruff-based lint/format validation (including PR delta reporting and PR comment summaries), optional Ruff “slash command” automation, and a mypy workflow for type checking. It also updates contributor guidance and dev requirements to reflect the move from Black to Ruff.
Changes:
- Add a
ruff.tomlconfiguration and CI workflows for Ruff (delta-based reporting) and mypy. - Add custom Bash scripts to compute Ruff deltas vs
origin/main, generate tables, PR comments, and annotations. - Update Python contributor documentation and dev requirements to prefer Ruff over Black.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
ruff.toml |
Adds Ruff lint/format configuration (rules, ignores, exclusions, target version). |
PySpotObserver/requirements.txt |
Switches dev formatting tool from Black to Ruff (and keeps mypy). |
PySpotObserver/README.md |
Updates contributing instructions to use Ruff instead of Black. |
.github/workflows/ruff.yml |
Adds PR-triggered Ruff workflow with delta stats, annotations, and PR comment reporting. |
.github/workflows/ruff-commands.yml |
Adds an issue_comment-triggered workflow to run Ruff commands and optionally push fixes to the PR branch. |
.github/workflows/mypy.yml |
Adds PR-triggered mypy type-check workflow. |
.github/scripts/ruff/lib.sh |
Adds shared logging/validation/JQ helper functions for Ruff scripts. |
.github/scripts/ruff/collect-stats.sh |
Collects Ruff results for PR vs main and computes rule/category deltas and “new vs fixed” counts. |
.github/scripts/ruff/build-tables.sh |
Builds per-category Markdown tables for new/fixed deltas and auto-fixability. |
.github/scripts/ruff/build-comment.sh |
Assembles the final PR comment body (status, tables, remediation steps). |
.github/scripts/ruff/annotate-new-issues.sh |
Emits GitHub annotations for newly introduced rule regressions only. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| OVERALL_STATUS="pass" | ||
| [ "$REGRESSION_STATUS" = "fail" ] || [ "$FORMAT_STATUS" = "fail" ] && OVERALL_STATUS="fail" |
There was a problem hiding this comment.
In bash, expressions are parsed left-to-right, so even if it short-circuits, it will be treated like:
{ [ "$REGRESSION_STATUS" = "fail" ] || [ "$FORMAT_STATUS" = "fail" ]; } && OVERALL_STATUS="fail"|
And thus OVERALL_STATUS="fail" will be set.
| if: > | ||
| github.event.issue.pull_request && ( | ||
| startsWith(github.event.comment.body, '/ruff') || | ||
| startsWith(github.event.comment.body, '@ruff') | ||
| ) |
There was a problem hiding this comment.
Yes; this functionality was previously designed for a private repo, very important that triggering this workflow is restricted for public repos such as this.
| grep "^new|" "$D/all_rule_rows.txt" | cut -d'|' -f2 | sort -u | while read cat; do | ||
| cat_main=$(grep "^$cat " "$D/main_category_counts.txt" 2>/dev/null | awk '{print $2}' || echo "0") | ||
| cat_main=${cat_main:-0} | ||
| cat_pr=$(grep "^$cat " "$D/pr_category_counts.txt" 2>/dev/null | awk '{print $2}' || echo "0") | ||
| cat_pr=${cat_pr:-0} | ||
| cat_delta=$((cat_pr - cat_main)) | ||
| cat_info=$(get_category_info "$cat") | ||
| cat_display=$(echo "$cat_info" | cut -d'|' -f1) | ||
| cat_tool=$(echo "$cat_info" | cut -d'|' -f2) | ||
| cat_fix_str=$(get_fix_str "$cat" "$cat_delta" "true") | ||
| echo "$cat_delta|$cat|$cat_display|$cat_tool|$cat_main|$cat_pr|$cat_fix_str" |
There was a problem hiding this comment.
Updated to sum rule regressions in current PR as well
Summary
main.main, so PRs are flagged for newly introduced issues rather than inherited existing issues.Details
main.Notes
ruffissues across the entire codebase, since it checks against main, which does not haveruffconfigured.blackusage withruff.mainshould not block PRs unless the branch introduces new Ruff regressions.