Skip to content

feat: auto-fix formatting for web UI commits in CI#5308

Merged
fpigeonjr merged 6 commits intomainfrom
copilot/auto-fix-formatting-web-ui-commits
Apr 7, 2026
Merged

feat: auto-fix formatting for web UI commits in CI#5308
fpigeonjr merged 6 commits intomainfrom
copilot/auto-fix-formatting-web-ui-commits

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 18, 2026

Web UI contributors (docs fixes, small edits via GitHub's editor) were blocked by formatting CI failures with no easy path to fix them locally.

What changed

CI (ci.ymllint job)

  • Detects web UI commits by checking git log committer identity: GitHub <*@noreply.github.com>
  • Web UI path: runs Black, isort, and Prettier in write/fix mode → commits fixes back to the branch as github-actions[bot] with message style: auto-format code (web UI commit) → posts a PR comment explaining what happened
  • Local path: existing fail-on-format-error behavior unchanged
  • Push failures (fork PRs, branch protection) fall back gracefully: posts a PR comment with the exact manual commands to run
  • Added permissions: contents: write, pull-requests: write scoped to the lint job only; uses gh CLI and native git — no new external actions

Detection logic:

if [[ "$COMMITTER_NAME" == "GitHub" && "$COMMITTER_EMAIL" == *"noreply@github.com"* ]]; then
  echo "source=web-ui" >> $GITHUB_OUTPUT
fi

CONTRIBUTING.md (new)

  • Quick-start section for web UI contributors explaining the auto-format behavior
  • Local dev setup: RSA keys, pre-commit hooks, Docker stack
  • Per-tool formatting commands (Prettier, Black, isort) for check and fix modes
  • Conventional commit reference table

.github/pull_request_template.md

  • Added a callout at the top for web UI contributors pointing to CONTRIBUTING.md

Issue

https://github.com/HHS/OPRE-OPS/issues/

How to test

  1. Open a PR branch and edit any .py or .js/.ts file via GitHub's web UI, intentionally introducing a formatting issue (e.g., extra blank lines, wrong import order)
  2. Observe the CI Linting job: it should detect source=web-ui, run the auto-fix steps, and commit a style: auto-format code (web UI commit) commit to the branch
  3. Confirm a bot comment appears on the PR explaining the fix
  4. Make a local commit with a formatting issue → confirm CI still fails the Check backend/frontend formatting steps as before

A11y impact

  • No accessibility-impacting changes in this PR

Screenshots

N/A — CI/workflow-only changes

Definition of Done Checklist

  • OESA: Code refactored for clarity
  • OESA: Dependency rules followed
  • Automated unit tests updated and passed
  • Automated integration tests updated and passed
  • Automated quality tests updated and passed
  • Automated load tests updated and passed
  • Automated a11y tests updated and passed
  • Automated security tests updated and passed
  • 90%+ Code coverage achieved
  • Form validations updated

Links

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/repos/actions/github-script/git/refs/tags/v7.0.1
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Auto-fix formatting for web UI commits</issue_title>
<issue_description>## Problem

Infrequent contributors using GitHub's web UI to make edits (docs fixes, small changes) often get blocked by formatting failures in CI. They don't have local dev environments set up with pre-commit hooks and formatters.

Current behavior:

  • CI fails the build on formatting issues
  • Contributor must set up local environment or abandon contribution
  • Creates friction for small, valuable contributions

Proposed Solution: Hybrid Approach

Implement conditional auto-formatting based on commit source:

For Web UI Commits (Auto-Fix)

  • Detect commits made via GitHub web interface
  • Automatically run formatters (Prettier, Black, isort)
  • Auto-commit fixes with clear message: style: auto-format code (web UI commit)
  • Add PR comment explaining the auto-fix
  • Link to contributor setup guide for regular contributors

For Local Commits (Fail Build - Current Behavior)

  • Keep existing behavior: fail CI if formatting issues detected
  • Encourages proper local tooling setup
  • Maintains developer ownership and learning

Detection Strategy

Web UI commits can be identified by:

  • Commit author: web-flow (GitHub's web UI bot)
  • Commit signature metadata
  • PR labels (could add web-ui-edit label manually/automatically)

Implementation Steps

  1. Add web UI detection logic to CI workflow

    - name: Detect commit source
      id: detect
      run: |
        if git log -1 --pretty=format:'%an' | grep -q 'web-flow'; then
          echo "source=web-ui" >> $GITHUB_OUTPUT
        else
          echo "source=local" >> $GITHUB_OUTPUT
        fi
  2. Conditional formatting job

    - name: Check or fix formatting
      if: steps.detect.outputs.source == 'local'
      run: bun run prettier --check  # Fail build
      
    - name: Auto-fix formatting
      if: steps.detect.outputs.source == 'web-ui'
      run: |
        bun run format
        # Similar for backend: nox -s black
  3. Auto-commit changes

    • Use stefanzweifel/git-auto-commit-action
    • Configure commit message and author
    • Add PR comment explaining the fix
  4. Documentation

    • Update CONTRIBUTING.md with web contributor guidance
    • Add PR template checkbox for web UI edits
    • Link to full dev setup for regular contributors

Acceptance Criteria

  • CI detects web UI commits vs local commits
  • Web UI commits: formatting auto-fixed and committed
  • Local commits: CI fails on formatting issues (current behavior)
  • PR comment added when auto-fix runs explaining what happened
  • Backend (Black, isort) and frontend (Prettier) both handled
  • Documentation updated in CONTRIBUTING.md
  • Tested with actual web UI edit

Bonus Feature: Smart Auto-Fix Bot

Interactive bot for flexibility:

Behavior

  • Run formatting check on all PRs
  • If fails: Post comment with options
  • Contributor can reply /format to trigger auto-fix
  • Or auto-fix after 1 hour if no response (for web UI only)
  • Track contributor history (GitHub API) to customize messaging

Example Comment

👋 Hi! I noticed some formatting issues in this PR.

**Options:**
- 🤖 Reply `/format` and I'll fix them automatically
- 💻 Run `bun run format` locally (recommended for regular contributors)
- ⏱️ I'll auto-fix in 1 hour if you don't respond

[Setup guide for local development](link)

Implementation

  • GitHub Actions workflow triggered by PR comments
  • Watch for /format command via issue_comment event
  • Permission checks (only PR author or maintainers can trigger)
  • Rate limiting to prevent abuse

Benefits

  • More flexible than automatic fixes
  • Educational for new contributors
  • Maintains control and transparency
  • Graceful degradation (auto-fix after timeout)

Related

  • Current formatting setup: CLAUDE.md Editor Setup section
  • Pre-commit hooks: .pre-commit-config.yaml
  • CI formatting checks: .github/workflows/ci.yml

Labels

enhancement, ci-cd, developer-experience, good-first-issue (for basic implementation)</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Implement auto-fix formatting for web UI commits feat: auto-fix formatting for web UI commits in CI Mar 18, 2026
Copilot AI requested a review from fpigeonjr March 18, 2026 21:50
@fpigeonjr fpigeonjr requested a review from Copilot March 19, 2026 13:21
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 updates CI to automatically fix and commit formatting changes (Black/isort/Prettier) when a PR’s latest commit appears to come from GitHub’s web UI, reducing friction for occasional contributors who can’t easily run formatters locally.

Changes:

  • Adds “web UI commit” detection to the lint job and conditionally runs formatters in fix mode, committing/pushing results back to the PR branch.
  • Posts PR comments describing what happened (auto-fixed vs. unable to auto-fix).
  • Adds contributor documentation (new CONTRIBUTING.md) and a PR template note for web UI contributors.

Reviewed changes

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

File Description
CONTRIBUTING.md New contributor guide describing the auto-format behavior and local setup/format/test commands.
.github/workflows/ci.yml Adds web UI detection, auto-format + auto-commit flow, and PR commenting for formatting results.
.github/pull_request_template.md Adds a callout directing web UI contributors to the contributing guide.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/workflows/ci.yml Outdated
Comment thread .github/workflows/ci.yml Outdated
Comment thread .github/workflows/ci.yml Outdated
Comment thread .github/workflows/ci.yml Outdated
Comment thread CONTRIBUTING.md Outdated
Comment thread .github/workflows/ci.yml Outdated
Comment thread .github/workflows/ci.yml Outdated
Comment thread .github/pull_request_template.md Outdated
@fpigeonjr
Copy link
Copy Markdown
Contributor

@copilot apply changes based on the comments in this thread

@HHS HHS deleted a comment from Copilot AI Mar 19, 2026
@HHS HHS deleted a comment from Copilot AI Mar 19, 2026
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 19, 2026

@fpigeonjr The model claude-sonnet-4.6 is not available for your account. This can happen if the model was disabled by your organization's policy or if your Copilot plan doesn't include access to it.

You can try again without specifying a model (just @copilot) to use the default, or choose a different model from the model picker.

If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: 5812724f-db08-4e59-9a6e-b2e096aee56f

@HHS HHS deleted a comment from Copilot AI Mar 19, 2026
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 19, 2026

@fpigeonjr The model claude-sonnet-4.6 is not available for your account. This can happen if the model was disabled by your organization's policy or if your Copilot plan doesn't include access to it.

You can try again without specifying a model (just @copilot) to use the default, or choose a different model from the model picker.

If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: 5812724f-db08-4e59-9a6e-b2e096aee56f

1 similar comment
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 19, 2026

@fpigeonjr The model claude-sonnet-4.6 is not available for your account. This can happen if the model was disabled by your organization's policy or if your Copilot plan doesn't include access to it.

You can try again without specifying a model (just @copilot) to use the default, or choose a different model from the model picker.

If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: 5812724f-db08-4e59-9a6e-b2e096aee56f

@fpigeonjr fpigeonjr force-pushed the copilot/auto-fix-formatting-web-ui-commits branch from 0169b50 to 2d7c299 Compare March 23, 2026 15:31
@fpigeonjr fpigeonjr marked this pull request as ready for review March 23, 2026 23:39
@github-actions
Copy link
Copy Markdown
Contributor

🤖 Auto-formatting applied!

I detected that this PR was edited via the GitHub web UI and had some formatting issues. I automatically applied fixes using:

  • Prettier (frontend)
  • Black + isort (backend)

The fixes have been committed to this branch. For future contributions, consider setting up the local development environment to run formatters before pushing - it avoids this extra round-trip.

@fpigeonjr fpigeonjr merged commit 8a39071 into main Apr 7, 2026
58 checks passed
@fpigeonjr fpigeonjr deleted the copilot/auto-fix-formatting-web-ui-commits branch April 7, 2026 16:37
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 7, 2026

🎉 This PR is included in version 1.355.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Auto-fix formatting for web UI commits

5 participants