Skip to content

Idea: A bot to run pre-commit and commit formatted code #211

Closed

Description

@sloria

It would be great to have a GitHub bot that could execute pre-commit run ... on a PR then add a commit to the PR with the formatting changes, if there are any.

This would act as a last resort, ensuring that both maintainers and contributors don't need to care about formatting code.

Does this exist? If not, is there any interest in collaborating on something like this?

Prior discussions

Activity

  1. asottile commented on Feb 4, 2019

    @asottile
    Member

    Seems like a fine idea -- though I don't have the slightest idea on where to host such a thing however

    I'm going to move this to the docs repo since it's less about the framework and more about ancillary tools.

    I'd be happy to help set something like this up if there's interest and direction 👍

    I believe @nicoddemus @RonnyPfannschmidt @obestwalter have expressed interest in a similar thing in the past as well, CCing them in case they have input

  2. sloria commented on Feb 4, 2019

    @sloria
    Author

    Seems like a fine idea -- though I don't have the slightest idea on where to host such a thing however

    The Probot docs have deployment instructions for Glitch, Heroku, Now, GH Actions, AWS Lambda, and Google Cloud Functions: https://probot.github.io/docs/deployment .

  3. sloria commented on May 3, 2019

    @sloria
    Author

    I wonder if this makes more sense as a GitHub Action. There's already actions implemented for a number of linters and formatters: https://github.com/bltavares/actions

  4. asottile commented on May 3, 2019

    @asottile
    Member

    I really really really want to set up a github action but I haven't been allowlisted into the beta yet :'(

  5. sloria commented on Jul 2, 2019

    @sloria
    Author

    The Restyled project (https://restyled.io/) uses GitHub actions to run formatters against PRs. I've suggested adding pre-commit support: restyled-io/restylers#29

  6. Pierre-Sassoulas commented on Apr 29, 2021

    @Pierre-Sassoulas

    This Github action would would save so much time. I found this existing action that look like a very close match. Maybe just adding pre-commit run --all-files would work:

    jobs:
      build:
        runs-on: ubuntu-latest
        steps:
        - uses: actions/checkout@v2
          with:
            persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token
            fetch-depth: 0 # otherwise, you will failed to push refs to dest repo
        - name: Create local changes
          run: |
            pre-commit run --all-files
        - name: Commit files
          run: |
            git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
            git config --local user.name "github-actions[bot]"
            git commit -m "Add changes" -a
        - name: Push changes
          uses: ad-m/github-push-action@master
          with:
            github_token: ${{ secrets.GITHUB_TOKEN }}
            branch: ${{ github.ref }}
  7. chriskuehl commented on Apr 29, 2021

    @chriskuehl
    Member

    @Pierre-Sassoulas have you seen https://pre-commit.ci/? It is developed by the primary pre-commit maintainer and sounds like exactly what you want.

  8. asottile commented on Apr 29, 2021

    @asottile
    Member

    yeah this isn't possible to do safely with github actions -- so I made pre-commit.ci which is now the official way to run pre-commit in CI for github

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions