-
Notifications
You must be signed in to change notification settings - Fork 2
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
Add labels in a more principled way. #90
Conversation
Before, I was just munging the label to the name, so I wouldn't have to change a lot of code. This didn't work because the name was used in places where the code needs it to actually be a name (e.g. when telling github what reviewers to add to the PR). So now I store names and labels separately, and just print the label explicitly when emitting the comment text. This also gives me more control over where the label goes; all in all a more maintainable arrangement. Issue: https://khanacademy.atlassian.net/browse/FEI-5970 Test plan: yarn jest
GeraldRequired Reviewers
Don't want to be involved in this pull request? Comment |
src/runOnPullRequest.js
Outdated
@@ -22,6 +22,8 @@ import { | |||
MATCH_COMMENT_HEADER_REGEX, | |||
} from './constants'; | |||
|
|||
type NameToLabelToFiles = {[name: string]: {[label: string]: string[], ...}, ...}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before, if there were multiple matching rules, I think it would do:
{
lilli: [fileFromR1, fileFromR2, fileFromR2]
...
}
Then in the comment it would do:
lilli because fileFromR1, fileFromR2, fileFromR2
But now if there are multiple matching rules, I think I would want:
lilli (rule1): fileFromR1
lilli (rule2): fileFromR2, fileFromR2
I'm not clear if this structure gets us to that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it does! You can see in some of the test output.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it does, but the syntax is starting to twist my head...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If js allowed non-string map keys, I could do a map from (person, label)
to [files]
, but it doesn't, so this is the best I could do...
src/runOnPush.js
Outdated
) => { | ||
const names: string[] = Object.keys(peopleToFiles); | ||
if (peopleToFiles && names.length) { | ||
type NameToLabelToFiles = {[name: string]: {[label: string]: string[], ...}, ...}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we put this somewhere shared so as to not dupe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want. I like having it in each place so it's easier to find when reading the file; flow won't let them get out of sync. But I know some people feel very militant about DRY!
let body = `<details>\n<summary><b>${header}</b></summary>\n\n`; | ||
names.forEach((person: string) => { | ||
const files = peopleToFiles[person]; | ||
const names: string[] = Object.keys(peopleToLabelToFiles); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I bet this impacts the #remove-me functionality. Have you checked that? This is big enough that it's fine to do that part in another PR if it's easier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did check that, at least by reading the code. My changes do not affect #remove-me
as far as I can tell. The remove-me logic goes through getFilteredLists(), and that works on the key to peopleToLabelToFiles, which is still the person's name. (My previous way of doing this did break remove-me, but this way should not.)
Why did you think this would impact remove-me?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you think this would impact remove-me?
I guess I thought it might impact the remove-me function because I didn't really know how to remove me function works… I just had a hunch that it might, and I wanted to make sure that it was considered and tested.
Sounds like the way that the functionality works is that it just re-creates the comment minus the removed person? So if the removed person was originally in there twice, and they wanted to be removed, it just leave them out for both rules? Instead of, say, matching the name in the body of the previous comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's right.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#removeme
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tentatively approving but we will want to check the #remove-me functionality.
You can also just test things in the Gerald repo, I think, if you want to avoid the long chain of gerald → actions → webapp.
There's also some local tester utility, but I have no idea what it does or how it works. I just saw it when picking though the code.
Here's Gerald's comment: #90 (comment) for more context on self-testing and #remove-me |
84fecd9
to
24a71c0
Compare
Sadly, I can't, because the gerald repo's github action is |
@csilvers I believe you can temporarily point Gerald to the sha that is one behind of the tip of your PR? Because the sha of the commit that points to one behind the tip is the tip... |
Oh, I can change the git tag. But that will change things for everyone, not just me, so it's a little scary. I'll try it later in the day. |
@csilvers I think on this branch, point this repo's workflow file to a sha on this branch. I think that should work in a way that doesn't affect other people? |
I don't know how to do that. Right now the repo's gerald-pr.yml file looks like this:
what are you proposing I change it to? |
@MiguelCastillo you're just being added because I needed a name for testing this new functionality. There's one more test you could help with -- could you add a comment to this PR that just says |
The way I implemented it before didn't work well with REVIEWERS. Now it's a bit more complicated but also more principled. Issue: https://khanacademy.atlassian.net/browse/FEI-5970 Test plan: The comments and such on Khan/gerald#90
🖍 _This is an audit!_ 🖍 ## Summary: The way I implemented it before didn't work well with REVIEWERS. Now it's a bit more complicated but also more principled. Issue: https://khanacademy.atlassian.net/browse/FEI-5970 ## Test plan: The comments and such on Khan/gerald#90 Author: csilvers Auditors: #github-actions, jeresig, lillialexis Required Reviewers: Approved By: Checks: ⌛ Lints, ⌛ gerald Pull Request URL: #96
Sure thang! #removeme |
@MiguelCastillo : I think you may need to say |
I did above. I also did it as an inline comment in case that made a difference. Will do a standalone one too. |
#removeme |
Oh, it's still processing the PR, maybe it will be a while before it's ready to run the github actions to do the update. |
|
It's still processing the PR. Something is very wrong. Probably the huge index.js file. |
OK, I'm landing this. I'm not convinced |
Summary:
Before, I was just munging the label to the name, so I wouldn't have
to change a lot of code. This didn't work because the name was used
in places where the code needs it to actually be a name (e.g. when
telling github what reviewers to add to the PR).
So now I store names and labels separately, and just print the label
explicitly when emitting the comment text. This also gives me more
control over where the label goes; all in all a more maintainable
arrangement.
Issue: https://khanacademy.atlassian.net/browse/FEI-5970
Test plan:
yarn jest