Skip to content

[misc] feat: introduce a style bot. #10274

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

Merged
merged 15 commits into from
Feb 19, 2025
Merged

[misc] feat: introduce a style bot. #10274

merged 15 commits into from
Feb 19, 2025

Conversation

sayakpaul
Copy link
Member

What does this PR do?

This PR introduces a workflow for allowing us to use the GitHub Actions bot to do @bot /style on PRs that are close to merging but cannot be merged because of styling issues.

I have experimented with the workflow in this dummy repository: https://github.com/sayakpaul/poc-style-bot.

This is how it'd look like:
image

Workflow run: https://github.com/sayakpaul/poc-style-bot/actions/runs/12366322159

@hlky possible for you to give this a look and try it out?

Copy link
Contributor

@hlky hlky left a comment

Choose a reason for hiding this comment

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

This type of workflow event will only trigger if the workflow is on the default branch so we can't test it here, but it appears correct and is working on your test repo. My only comment is that make style && make quality can just be make style and sometimes we need to do ruff check $(check_dirs) setup.py --fix --unsafe-fixes, probably better to do --unsafe-fixes manually though.

https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#issue_comment

This event will only trigger a workflow run if the workflow file is on the default branch.

@sayakpaul
Copy link
Member Author

an just be make style and sometimes we need to do ruff check $(check_dirs) setup.py --fix --unsafe-fixes, probably better to do --unsafe-fixes manually though.

Yeah usually make style && make quality is the command we're looking into using. Anything other than that, should be applied manually, IMO.

This type of workflow event will only trigger if the workflow is on the default branch so we can't test it here

Yeah exactly. Sorry, I should have made it clear. My ask was more about checking the structure of the workflow and the dummy repo I tested it on.

@DN6 could you give this a look too?

@sayakpaul sayakpaul requested a review from DN6 December 19, 2024 03:01
git add .
git commit -m "Apply style fixes"
# Push back to the PR branch
git push origin HEAD:${{ steps.pr_info.outputs.headRef }}
Copy link
Contributor

Choose a reason for hiding this comment

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

Note that this will push to diffusers/headRef instead of the original contributor's forked repo'branch (if it is from a forked repository) - If I am not making mistake here.

Better to revise this part I think :-)

Copy link
Member Author

Choose a reason for hiding this comment

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

I PoC'd it here: https://github.com/sayakpaul/poc-style-bot in sayakpaul/poc-style-bot#1.

If you have ideas about revisions, please provide them.

Copy link

Choose a reason for hiding this comment

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

It's because your PR is opened by a branch pushed to the same repository. To actually test the situation, you have to fork the repository poc-style-bot say to (under another github account sayakapaul_2), push a branch to sayakapaul_2/poc-style-bot, and opening a PR in sayakpaul/poc-style-bot.

Copy link
Member Author

Choose a reason for hiding this comment

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

@ydshieh I pushed some updates to account for your comment here #10274 (comment). LMK.

Copy link
Contributor

@ydshieh ydshieh Jan 7, 2025

Choose a reason for hiding this comment

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

Looks my comment is addressed, although I didn't check line by line.

I always recommend to test it with a external contributor (a new github account, say sayakpaul2) opening a PR from it's forked repo. to your POC repository (under @sayakpaul).

But I will leave the final decision to you :-)

Copy link
Contributor

Choose a reason for hiding this comment

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

Tested with external contributor here sayakpaul/poc-style-bot#2

Copy link
Member Author

Choose a reason for hiding this comment

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

@yiyixuxu yiyixuxu added the roadmap Add to current release roadmap label Jan 6, 2025
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}

- name: Debug
Copy link
Contributor

Choose a reason for hiding this comment

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

can you do the same here ? create 3 env variable and use them on the run

Copy link
Member Author

Choose a reason for hiding this comment

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

Do the latest changes work?

sayakpaul and others added 3 commits January 14, 2025 10:57
Co-authored-by: Guillaume LEGENDRE <glegendre01@gmail.com>
Comment on lines +67 to +78
- name: Download Makefile from main branch
run: |
curl -o main_Makefile https://raw.githubusercontent.com/huggingface/diffusers/main/Makefile

- name: Compare Makefiles
run: |
if ! diff -q main_Makefile Makefile; then
echo "Error: The Makefile has changed. Please ensure it matches the main branch."
exit 1
fi
echo "No changes in Makefile. Proceeding..."
rm -rf main_Makefile
Copy link
Member Author

Choose a reason for hiding this comment

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

@glegendre01 added this too. LMK if it works for you.

Copy link
Contributor

Choose a reason for hiding this comment

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

LGTM

@sayakpaul sayakpaul requested a review from glegendre01 January 21, 2025 09:24
@sayakpaul
Copy link
Member Author

@glegendre01 a gentle ping.

@sayakpaul sayakpaul merged commit 680a8ed into main Feb 19, 2025
10 of 11 checks passed
@sayakpaul
Copy link
Member Author

Thanks all for helping :)

@sayakpaul sayakpaul deleted the style-bot branch February 19, 2025 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
roadmap Add to current release roadmap
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

6 participants