Skip to content

[Merged by Bors] - feat: run style linters in fix mode and push a commit when "bot fix style" is posted in a PR comment - #15781

Closed
bryangingechen wants to merge 17 commits into
masterfrom
bgc-lint-fix
Closed

bryangingechen wants to merge 17 commits into
masterfrom
bgc-lint-fix

Conversation

@bryangingechen

@bryangingechen bryangingechen commented Aug 13, 2024 •

Copy link
Copy Markdown
Contributor

The bot is triggered when writes "bot fix style" on a PR, either in an ordinary comment, a review comment, or a review. It then checks if the author has "write" privileges (or above) and if so, will react with a 🚀 emoji on the triggering comment and then lint and push a commit to the PR branch.

Note that this uses the NIGHTLY_TESTING secret.

See Zulip.


Open in Gitpod

This can be tested in my fork of mathlib4. The main things left to test are permissions and other edge cases. So feel free to open weird issues / PRs to my fork and comment on them to try and break things. I think only people with write access should be able to trigger the bot now, so if you want write access to my fork let me know here or on Zulip!

For starters, if someone would like to try commenting bot fix style on bryangingechen#2 (also in a PR review / PR review comment) I can check if the permissions check is working properly. (Since no one other than me has write access at this time, hopefully the bot will ignore your comment.)

@github-actions github-actions Bot added the new-contributor This PR was made by a contributor with at most 5 merged PRs. Welcome to the community! label Aug 13, 2024
@github-actions

github-actions Bot commented Aug 13, 2024 •

Copy link
Copy Markdown

PR summary 76accb4619

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference

Declarations diff

No declarations were harmed in the making of this PR! 🐙

You can run this locally as follows
## summary with just the declaration names:
./scripts/declarations_diff.sh <optional_commit>

## more verbose report:
./scripts/declarations_diff.sh long <optional_commit>

The doc-module for script/declarations_diff.sh contains some details about this script.

@bryangingechen bryangingechen added the WIP Work in progress label Aug 13, 2024
@bryangingechen

Copy link
Copy Markdown
Contributor Author

Let's make sure nothing explodes if I do this:

bot fix style

@bryangingechen

Copy link
Copy Markdown
Contributor Author

Ah, it makes sense that the workflow that triggers on comments won't run from a PR.

@adomani

adomani commented Aug 15, 2024

Copy link
Copy Markdown
Contributor

Ah, it makes sense that the workflow that triggers on comments won't run from a PR.

You may still be able to test this by modifying a workflow that reacts to comments that already is in master.

As far as I can tell, if the workflow file is in master, then PRs modifying it work with the modified script. So you could override the maintainter merge script to perform what you want in a branch and CI should act on it.

@grunweg grunweg added the CI Modifies the continuous integration setup or other automation label Aug 15, 2024
@bryangingechen

Copy link
Copy Markdown
Contributor Author

This will conflict with #15051, so I'll work on this more after that one is merged.

@ghost ghost added blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) and removed blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) labels Aug 15, 2024
@ghost

ghost commented Aug 16, 2024

Copy link
Copy Markdown

This PR/issue depends on:

Comment thread Mathlib/Algebra/Quandle.lean Resolved
@bryangingechen

Copy link
Copy Markdown
Contributor Author

bot fix style

@bryangingechen

Copy link
Copy Markdown
Contributor Author

Hmm, unfortunately the trick of overwriting the maintainer merge workflow didn't work. The run for the "bot fix style" comment above shows that the workflow on master was used: https://github.com/leanprover-community/mathlib4/actions/runs/10460233262/workflow

@bryangingechen

bryangingechen commented Aug 22, 2024 •

Copy link
Copy Markdown
Contributor Author

This can be tested in my fork of mathlib4. The main things left to test are permissions and other edge cases. So feel free to open weird issues / PRs to my fork and comment on them to try and break things. I think only people with write access should be able to trigger the bot now, so if you want write access to my fork let me know here or on Zulip!

For starters, if someone would like to try commenting bot fix style on bryangingechen#2 I can check if the permissions check is working properly. (Since no one other than me has write access at this time, hopefully the bot will ignore your comment.)

edit (2024/08/23): found some bugs, working on fixing them now.

fix_style:
name: Fix style issues from lint
if: github.repository == 'leanprover-community/mathlib4' && (github.event.issue.pull_request != 'null') && github.event.pull_request.draft == false && (startsWith(github.event.comment.body, 'bot fix style') || contains(toJSON(github.event.comment.body), '\nbot fix style'))
if: github.repository == 'leanprover-community/mathlib4' && github.event.issue.pull_request && github.event.pull_request.draft == false && (startsWith(github.event.comment.body, 'bot fix style') || contains(toJSON(github.event.comment.body), '\nbot fix style'))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

reminder to self: this needs to be fixed (in another PR) in the maintainer merge workflows as well

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in #16241

@bryangingechen bryangingechen removed the WIP Work in progress label Aug 23, 2024
@bryangingechen bryangingechen changed the title feat: run lint-style.sh --fix and push a commit when "bot fix style" is posted in a PR comment feat: run style linters in fix mode and push a commit when "bot fix style" is posted in a PR comment Aug 23, 2024
@bryangingechen bryangingechen added the WIP Work in progress label Aug 23, 2024
@bryangingechen bryangingechen removed the WIP Work in progress label Aug 24, 2024

- run: echo ${{ steps.user_permission.outputs.require-result }}

# Maybe no API exists for this yet?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Is there a way to add a reaction to a PR review via the API? I tried the following and it gave me a 404 (I'm pretty sure the token I used has the permissions necessary): https://github.com/bryangingechen/mathlib4/actions/runs/10534530644/job/29192315609#step:4:14

@jcommelin jcommelin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks 🎉

bors merge

mathlib-bors Bot pushed a commit that referenced this pull request Aug 27, 2024
…tyle" is posted in a PR comment (#15781)

The bot is triggered when writes "bot fix style" on a PR, either in an ordinary comment, a review comment, or a review. It then checks if the author has "write" privileges (or above) and if so, will react with a 🚀 emoji on the triggering comment and then lint and push a commit to the PR branch.

Note that this uses the NIGHTLY_TESTING secret.

See [Zulip](https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/reviewdog/near/460017984).
@mathlib-bors

mathlib-bors Bot commented Aug 27, 2024

Copy link
Copy Markdown
Contributor

Pull request successfully merged into master.

Build succeeded:

@mathlib-bors mathlib-bors Bot changed the title feat: run style linters in fix mode and push a commit when "bot fix style" is posted in a PR comment [Merged by Bors] - feat: run style linters in fix mode and push a commit when "bot fix style" is posted in a PR comment Aug 27, 2024
@mathlib-bors mathlib-bors Bot closed this Aug 27, 2024
@mathlib-bors
mathlib-bors Bot deleted the bgc-lint-fix branch August 27, 2024 19:18
bjoernkjoshanssen pushed a commit that referenced this pull request Sep 9, 2024
…tyle" is posted in a PR comment (#15781)

The bot is triggered when writes "bot fix style" on a PR, either in an ordinary comment, a review comment, or a review. It then checks if the author has "write" privileges (or above) and if so, will react with a 🚀 emoji on the triggering comment and then lint and push a commit to the PR branch.

Note that this uses the NIGHTLY_TESTING secret.

See [Zulip](https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/reviewdog/near/460017984).
bjoernkjoshanssen pushed a commit that referenced this pull request Sep 9, 2024
…tyle" is posted in a PR comment (#15781)

The bot is triggered when writes "bot fix style" on a PR, either in an ordinary comment, a review comment, or a review. It then checks if the author has "write" privileges (or above) and if so, will react with a 🚀 emoji on the triggering comment and then lint and push a commit to the PR branch.

Note that this uses the NIGHTLY_TESTING secret.

See [Zulip](https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/reviewdog/near/460017984).
bjoernkjoshanssen pushed a commit that referenced this pull request Sep 12, 2024
…tyle" is posted in a PR comment (#15781)

The bot is triggered when writes "bot fix style" on a PR, either in an ordinary comment, a review comment, or a review. It then checks if the author has "write" privileges (or above) and if so, will react with a 🚀 emoji on the triggering comment and then lint and push a commit to the PR branch.

Note that this uses the NIGHTLY_TESTING secret.

See [Zulip](https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/reviewdog/near/460017984).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI Modifies the continuous integration setup or other automation new-contributor This PR was made by a contributor with at most 5 merged PRs. Welcome to the community!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants