Comments (15)
Could it also delete previous xl
comments if it's adding another one?
from pr-size-labeler.
This sticky comment action has a few variations of behavior for replacing or hiding PR comments, so it might be a good reference for an implementation to fix this issue (I haven't had a chance to poke around to see how it works, yet).
from pr-size-labeler.
Here's the trick - the sticky comment action inserts a comment to use as a means to find the PR comment and replace it.
The h
here is the comment text inserted when the comment is made, which is also how the action can post multiple comments for different steps in one job. It has an option to set a string that differentiates the comments.
const target = repository.pullRequest?.comments?.nodes?.find(
(node: IssueComment | null | undefined) =>
node?.author?.login === viewer.login.replace("[bot]", "") &&
!node?.isMinimized &&
node?.body?.includes(h)
)
from pr-size-labeler.
Hi!
As you can see in this example, it publishes the mentioned comment one time for each Workflow execution. That is, it depends on your on
clause configuration (example).
Could you please link or attach your yaml configuration and a screenshot of the duplicated message in a PR? (Wipe out sensible information if that's the case)
This could help debugging or reproducing the issue 🙂
Thanks!
from pr-size-labeler.
name: labeler
on: [pull_request]
jobs:
labeler:
runs-on: ubuntu-latest
name: Label the PR size
steps:
- uses: codelytv/pr-size-labeler@v1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
xs_max_size: '10'
s_max_size: '100'
m_max_size: '500'
l_max_size: '1000'
fail_if_xl: 'false'
message_if_xl: 'This PR is extremely big! Please, split it 😊'
from pr-size-labeler.
Thanks for the information! 🙌
As we can see in the screenshot, it publishes a comment regarding the PR size being too big for every new commit, that is, on every chance the PR has had to modify its size.
We could have some kind of logic taking into account the previous labels. I mean:
- Check if the PR already have the
size/xl
label and if that's the case:
1.a. If it's still too big, publish a comment like "This PR is still too big 😬"
1.b. If it has been reduced fromsize/xl
to any other size, publish a comment like "Congrats! 🎉 You have reduced the PR size successfully!"
What do you think? Would it be better?
from pr-size-labeler.
What do you think? Would it be better?
Yeah! It would also be nice to be able to set e.g. it will check the size every commit, but for commits on the same day it will not say this, i.e. the first commit on august 21 will have the message, but subsequent commits on that day will not show the message, andthe first commit on august 22 will have the message etc to reduce clutter.
from pr-size-labeler.
Oh yeah, that would be great to reduce clutter.
from pr-size-labeler.
Was this fixed?? I cant find a commit that proves this, but....
Over 21 hours, only 1 message from the bot. 🤔
from pr-size-labeler.
nvm, i think it was a bug with github actions
from pr-size-labeler.
How's this for a potential solution for deleting? Non-battle tested code (the query seems to work, I didn't run the DELETE) that will remove all previous comments. It should be called before you add a new comment.
# Delete existing messages from the GitHub Actions Bot user that match the $comment
local -r comment_id_list=$(curl -sSL \
-H "Authorization: token $GITHUB_TOKEN" \
-H "$GITHUB_API_HEADER" \
-X GET \
"$GITHUB_API_URI/repos/$GITHUB_REPOSITORY/issues/$pr_number/comments" \
| jq -r --arg comment "$comment" '.[] | select(.user.type == "Bot")| select(.user.login == "github-actions[bot]")| select(.body == $comment ) | .id' )
for id in $comment_id_list; do
curl -sSL \
-H "Authorization: token $GITHUB_TOKEN" \
-H "$GITHUB_API_HEADER" \
-X DELETE \
"$GITHUB_API_URI/repos/$GITHUB_REPOSITORY/issues/comments/$id"
done
I think this will just have a string of 'comment deleted by' in place of the comments themselves, so I think the 'comment every commit' is still too much.
from pr-size-labeler.
We could in theory impl this with something like this:
https://github.com/aaimio/set-persistent-value
(and its sister repo, https://github.com/aaimio/get-persistent-value)
Basically the persistent value would be a JSON array of PRs that it's already said "This PR is too big!" on, and the script could check the PR against that array
from pr-size-labeler.
I just thought of something: Maybe you could provide a label name that, if the PR has that label, will prevent the bot from commenting.
That way if there's a known big PR, you can work around this issue by adding that label.
from pr-size-labeler.
@JavierCane maybe the fastest way to deal with this issue (not the most cost optimal one) is to use GITHUB_OUTPUT, output the message_if_xl and then suggest users to pass that message to something like sticky as @EngJay suggested
from pr-size-labeler.
@luong-komorebi It's been a couple of years, so I don't remember much but I believe what I ended up doing in the fork I made is decoupling the message posting from this action by adding an option to return a bool if the PR is xl, so it can be used to trigger something else, like another action to post a comment. Fork is here.
Net effect was being able to "turn off" the comment posting in this action and depend on an external action (sticky) that replaced the comments already. Workaround but it worked at the time.
from pr-size-labeler.
Related Issues (20)
- Ignore files and folders by pattern? HOT 7
- Not working anymore HOT 11
- PR size labeler is not working HOT 2
- Is it possible to make github bot as labeler? HOT 2
- Label is not added pull requests HOT 1
- Feature Request: Regular expression support for files_to_ignore parameter HOT 5
- Document required permissions HOT 5
- XL warning message is posted repeatedly HOT 2
- Allow messages per size definition
- A new release with regex support HOT 3
- Possible to not pass message_if_xl? HOT 2
- Add support to ignore whitespace-only changes? HOT 1
- can ignore deletions? HOT 2
- Action fails: parse error: Invalid numeric literal at line 1, column 6 HOT 8
- Labeling nonexist size level `size/xs`
- Is it possible to ignore line count from deleted files? HOT 2
- files_to_ignore HOT 3
- Proposal to Revive and Maintain Pr-Size-Labeler: Seeking Community Input HOT 5
- Also include amount of changed files to the calculation to show complexity of pr instead of size only HOT 2
- Unexpected input(s) 'ignore_file_deletions' HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pr-size-labeler.