Skip to content

Conversation

@saber04414
Copy link

Auto lint fix in CI

Description

This PR adds an automated CI workflow that automatically fixes linting issues and commits them back to pull request branches. This saves developers time by eliminating the need to manually fix formatting issues.

Changes

  • Added format target to Makefile: New target that runs black and nbqa black to auto-fix Python code and Jupyter notebook formatting
  • Created GitHub Actions workflow (.github/workflows/lint_fix.yml):
    • Triggers on pull requests to main branch
    • Checks out the PR branch
    • Installs dependencies via make dev
    • Runs make format to auto-fix linting issues
    • Automatically commits and pushes fixes back to the PR branch

How it works

  1. When a PR is opened or updated, the workflow runs
  2. It formats code using Black (Python) and nbqa (notebooks)
  3. If any changes are detected, they are automatically committed with message "🤖 Auto-fix linting issues"
  4. Changes are pushed back to the PR branch

Testing

  • ✅ Verified Makefile format target syntax
  • ✅ Tested Black formatter functionality
  • ✅ Validated workflow YAML structure
  • ✅ Confirmed workflow file follows existing patterns

Related Issue

Closes #2060

Notes

  • The workflow uses GITHUB_TOKEN for authentication (automatically provided by GitHub Actions)
  • Only runs on pull requests to main branch
  • Uses concurrency control to prevent multiple runs
  • Follows the same pattern as existing workflows in the repository

Contribution by Gittensor, see my contribution statistics at https://gittensor.io/miners/details?githubId=157775043

- Add 'format' target to Makefile for auto-fixing linting issues
- Create GitHub Actions workflow to automatically fix and commit linting issues on PRs
- Workflow runs black formatter and nbqa for notebooks
- Auto-commits fixes back to PR branch

Closes microsoft#2060
@saber04414
Copy link
Author

@saber04414 please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.

@microsoft-github-policy-service agree [company="{your company}"]

Options:

  • (default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@microsoft-github-policy-service agree
  • (when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
@microsoft-github-policy-service agree company="Microsoft"

Contributor License Agreement

@microsoft-github-policy-service agree

@saber04414
Copy link
Author

@SunsetWolf Could you please review my pr?

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.

auto lint fix in CI

1 participant