Skip to content

GitHub workflow scripts#8

Open
jPorterDosch wants to merge 8 commits into
mainfrom
feat/gh-workflow-scripts
Open

GitHub workflow scripts#8
jPorterDosch wants to merge 8 commits into
mainfrom
feat/gh-workflow-scripts

Conversation

@jPorterDosch

@jPorterDosch jPorterDosch commented Jun 5, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Adds automated GitHub Actions workflows for linting, formatting checks, and type checking.
  • Adds Ruff-based and mypy PR checks that run automatically on pull requests targeting main.
  • Reports results as a delta against main, so PRs are flagged for newly introduced issues rather than inherited existing issues.

Details

  • Ruff handles linting, import ordering, and formatting checks.
  • Ruff comments on PRs with a summary of new, fixed, and inherited issues.
  • mypy runs in CI to catch type errors during review.
  • Workflows are configured for PR-based feedback before merging into main.

Notes

  • Delta in this PR shows all ruff issues across the entire codebase, since it checks against main, which does not have ruff configured.
  • This replaces Black-based formatting checks with Ruff formatting checks.
  • Updates the README to replace black usage with ruff.
  • Existing issues on main should not block PRs unless the branch introduces new Ruff regressions.

@github-actions

github-actions Bot commented Jun 5, 2026

Copy link
Copy Markdown

🧹 Ruff — ❌ 67 new issues

Check Result
Lint ❌ 67 new, 1 inherited
Top new UP006 +36 🔴
Format ✅ Passing (0 files)

Important

  1. Manually fix 67 new issue(s) that can't be auto-fixed (see Files changed)
  2. Push

Tip

VSCode: Set up auto-format and code actions on save

Settings 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"
}

Full setup guide →

🔴 New Issues (67)

⚡ UP — pyupgrade

Rule Description Main PR Δ Auto-fixable
UP006 Use instead of for type annotation 0 36 +36 🔴 0 ❌
UP035 Import from instead: 0 9 +9 🔴 0 ❌
UP015 Unnecessary mode argument 0 1 +1 🔴 0 ❌
Subtotal 0 46 +46 🔴 0 ❌

📦 I — isort

Rule Description Main PR Δ Auto-fixable
I001 Import block is un-sorted or un-formatted 0 9 +9 🔴 0 ❌
Subtotal 0 9 +9 🔴 0 ❌

📝 ANN — flake8-annotations

Rule Description Main PR Δ Auto-fixable
ANN001 Missing type annotation for function argument 0 7 +7 🔴 0 ❌
ANN204 Missing return type annotation for special method 0 2 +2 🔴 0 ❌
Subtotal 0 9 +9 🔴 0 ❌

🎨 W — pycodestyle

Rule Description Main PR Δ Auto-fixable
W293 Blank line contains whitespace 0 1 +1 🔴 0 ❌
Subtotal 0 1 +1 🔴 0 ❌

⚡ SIM — flake8-simplify

Rule Description Main PR Δ Auto-fixable
SIM105 Use instead of -- 0 1 +1 🔴 0 ❌
Subtotal 0 1 +1 🔴 0 ❌

📦 RUF — Ruff

Rule Description Main PR Δ Auto-fixable
RUF022 is not sorted 0 1 +1 🔴 0 ❌
Subtotal 0 1 +1 🔴 0 ❌

Summary

Category Tool Main PR Δ Auto-fixable
⚡ UP pyupgrade 0 46 +46 🔴 0 ❌
📦 I isort 0 9 +9 🔴 0 ❌
📝 ANN flake8-annotations 0 9 +9 🔴 0 ❌
🎨 W pycodestyle 0 1 +1 🔴 0 ❌
⚡ SIM flake8-simplify 0 1 +1 🔴 0 ❌
📦 RUF Ruff 0 1 +1 🔴 0 ❌
Total 1 68 +67 🔴 0 ❌

Bot commands for this PR

Type /ruff or @ruff followed by a command in a PR comment:

Command Description
check Run lint check only (no changes)
check --fix Auto-fix lint issues, commit to PR
format Auto-format code, commit to PR
format --check Check formatting only (no changes)
fix Recommended: check --fix + format

Reactions: 👀 = processing, 🚀 = all passing, 😕 = issues remain (details in reply)

View full logs →

@jPorterDosch jPorterDosch requested a review from fmz June 5, 2026 14:51

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.toml configuration 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.

Comment thread .github/scripts/ruff/lib.sh
Comment thread .github/scripts/ruff/collect-stats.sh Outdated
Comment thread .github/workflows/ruff.yml
Comment on lines +62 to +63
OVERALL_STATUS="pass"
[ "$REGRESSION_STATUS" = "fail" ] || [ "$FORMAT_STATUS" = "fail" ] && OVERALL_STATUS="fail"

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread .github/scripts/ruff/build-tables.sh Outdated
Comment thread .github/scripts/ruff/annotate-new-issues.sh
Comment thread .github/workflows/ruff.yml Outdated
Comment thread .github/workflows/mypy.yml
Comment thread PySpotObserver/requirements.txt
Comment thread .github/workflows/ruff-commands.yml Outdated
Comment on lines +29 to +33
if: >
github.event.issue.pull_request && (
startsWith(github.event.comment.body, '/ruff') ||
startsWith(github.event.comment.body, '@ruff')
)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jPorterDosch does this seem reasonable to you?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes; this functionality was previously designed for a private repo, very important that triggering this workflow is restricted for public repos such as this.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 5 comments.

Comment thread .github/scripts/ruff/collect-stats.sh
Comment thread .github/scripts/ruff/build-comment.sh
Comment thread .github/scripts/ruff/build-tables.sh Outdated
Comment on lines +202 to +212
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"

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to sum rule regressions in current PR as well

Comment thread .github/workflows/ruff-commands.yml Outdated
Comment thread .github/workflows/ruff.yml Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 8 comments.

Comment thread .github/workflows/ruff.yml Outdated
Comment thread .github/scripts/ruff/build-tables.sh Outdated
Comment thread .github/scripts/ruff/build-tables.sh Outdated
Comment thread .github/workflows/mypy.yml
Comment thread .github/workflows/ruff-commands.yml Outdated
Comment thread .github/workflows/ruff-commands.yml Outdated
Comment thread .github/workflows/ruff-commands.yml Outdated
Comment thread .github/workflows/ruff-commands.yml Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants