Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace pre-commit with Ultralytics Actions #12579

Closed
wants to merge 4 commits into from

Conversation

glenn-jocher
Copy link
Member

@glenn-jocher glenn-jocher commented Jan 3, 2024

This pull request adds an improved Ultralytics Actions workflow to automatically format code and documentation to the new Ultralytics official standards maintained at https://github.com/ultralytics/actions.

Four individual actions are run by default. To disable actions, set them to false, i.e. 'python: false'.

To customize an action use a pyproject.toml file in this repo, and see the individual action repo for details.

name: Ultralytics Actions

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

jobs:
  format:
    runs-on: ubuntu-latest
    steps:
      - name: Run Ultralytics Formatting
        uses: ultralytics/actions@main
        with:
          python: true
          docstrings: true
          markdown: true
          spelling: true

🛠️ PR Summary

Made with ❤️ by Ultralytics Actions

WARNING ⚠️ this PR is very large, summary may not cover all changes.

🌟 Summary

This PR introduces an automated code formatting workflow for the ultralytics/yolov5 repository.

📊 Key Changes

  • Adds a new GitHub Actions workflow file format.yml.
  • Modifies CONTRIBUTING.md, README.md, benchmarks.py, train.py, and other files to comply with the formatting standards.

🎯 Purpose & Impact

  • The main goal is to enforce coding standards and maintain consistency in code style throughout the project.
  • This automated workflow will format code in pull requests according to predefined rules, ensuring that all contributions adhere to the project's coding conventions.
  • The inclusion of this workflow can significantly reduce the manual effort required for code reviews regarding style issues and improve overall code quality.
  • Contributors will have clearer guidance and immediate feedback on formatting, leading to smoother collaboration and contribution processes.

This pull request adds an improved Ultralytics Actions workflow to automatically format code and documentation to the new Ultralytics official standards maintained at https://github.com/ultralytics/actions.

Four individual actions are run by default. To disable actions, set them to false, i.e. 'python: false'.

To customize an action use a `pyproject.toml` file in this repo, and see the individual action repo for details. 

```yaml
name: Ultralytics Actions

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

jobs:
  format:
    runs-on: ubuntu-latest
    steps:
      - name: Run Ultralytics Formatting
        uses: ultralytics/actions@main
        with:
          python: true
          docstrings: true
          markdown: true
          spelling: true
```

Signed-off-by: Glenn Jocher <[email protected]>
@glenn-jocher
Copy link
Member Author

@akx ok I think I fixed all the previous problems in this new attempt. What do you think?

@akx
Copy link
Contributor

akx commented Jan 3, 2024

@glenn-jocher Please see ultralytics/actions#23 first. 😄

As for the rest, it would really be much better if the mechanical fixes (Ruff, docstrings, markdown formatting), which we may assume to always be correct would be in their separate PR or PRs, and the only lint that will actually need hand-holding (as noticed before), spelling, would be done separately.

@glenn-jocher
Copy link
Member Author

@akx I've run into a bit of a blocker. I realized this action is currently only capable of updating branches created in the base repository (i.e. like this PR branch). If you submit a PR from a fork it's not capable of updating it the way pre-commit does.

I've tried some fixes but can't seem to make it work, I'm stuck.

@glenn-jocher glenn-jocher deleted the glenn-jocher-patch-1 branch January 8, 2024 00:03
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.

2 participants