Skip to content
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

patch: fix octokit api #940

Merged
merged 5 commits into from
May 25, 2023
Merged

patch: fix octokit api #940

merged 5 commits into from
May 25, 2023

Conversation

gitofdeepanshu
Copy link
Contributor

@gitofdeepanshu gitofdeepanshu commented May 19, 2023

Pull Request Summary

fix generate-release-body.ts file to allow printing of pr information according to label.
Broke due to Octokit API update.

@gitofdeepanshu gitofdeepanshu added the ci This PR/Issue is related to the topic "CI" label May 19, 2023
Copy link
Member

@Dinonard Dinonard May 19, 2023

Choose a reason for hiding this comment

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

Why did the error happen?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was failing because of new api design of octokit.

Copy link
Member

Choose a reason for hiding this comment

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

It's good to include such information in the PR summary, imo.

@@ -213,10 +212,17 @@ async function main() {
const emptyLabelPRs = prByLabels[''] || [];
Copy link
Member

Choose a reason for hiding this comment

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

What about this part?

I mentioned it in the Slack - won't this be always empty if we have a CI check for labels?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we added the labels check recently, surely there will be some pr which doesn't have any labels yet. we can remove this after this release imo.

return pr.title + " (#" + pr.number + ")";
}
else {
return pr.data.title + " (#" + pr.data.number + ")";
Copy link
Member

Choose a reason for hiding this comment

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

Does this work? (Just confirmation)
I can see .data field was removed at other plances in this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It does work, the new api is very confusing.
.data field is only present in pr objects that doesn't have any labels.

refactor: add .includes()

Co-authored-by: Shunsuke Watanabe <shunsukesan.tech@gmail.com>
@shunsukew
Copy link
Member

@gitofdeepanshu You need to change two lines not only 1 line.

for (const label in pr.lables) {
        if (label == BREAKING_CHANGES_LABEL) {

Comment on lines 215 to 217
const testsPRs = prByLabels[TESTS_CHANGES_LABEL] || [];
const ciPRs = prByLabels[CI_CHANGES_LABEL] || [];
const otherPRs = prByLabels[OTHER_CHANGES_LABEL] || [];
Copy link
Member

Choose a reason for hiding this comment

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

I'd suggest to go with a simpler solution - you have runtime, client and other.

other is everything - runtime - client (set difference operation).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

other = everything - runtime - client won't work because this will cause some of the pr which have more than 1 label to be included multiple times.
(example: let's suppose a Pr (123) has 3 tags shiden, runtime and shibuya)
This pr will be included in runtime and 2 times in other.
Of course this can be managed but that would not be a simpler solution (which is our objective).
Current solution is good enough for now imo.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, it's possible for a single PR to have multiple labels and that is fine.
It was also possible before.

The example I gave will work, not sure how you see it not working?
Iterate over all PRs and make sure that it's not included in neither of the client or runtime lists.

And I'm sorry but I won't approve this - the code highlighted in this comment is a clear anti-pattern.
It has unnecessary complexity, and is not resistant to addition of new labels (which isn't important for this example but it is in general).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was also possible before.

Earlier only the PRs that had runtime, client, breaksapi or empty label were included (not all), so if I had put a test label, it wouldn't have got included.

Iterate over all PRs and make sure that it's not included in neither of the client or runtime lists.

We also have to make sure that a PR doesn't get include twice which has different labels, For example: If a PR has test and ci label, then we have to make sure it only gets included once.

Now it has all the functionality that you wanted.

Copy link
Member

@Dinonard Dinonard left a comment

Choose a reason for hiding this comment

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

Let's merge it and get the release re-released.

Comment on lines +153 to +154
// filters out the PR that has a tag `client` or `runtime` and returns all the remaining PRs
function PRfilter(prLabels: any) {
Copy link
Member

Choose a reason for hiding this comment

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

Nit-picky general comment - try to keep the style & approach consistent.
The formatting is off compared to other functions and e.g. below where consts are used, you use let.

Comment on lines +181 to +184
prLabels[""].forEach(element => {
if (included_pr_number.includes(element.data.number)) {
// do nothing
}
Copy link
Member

Choose a reason for hiding this comment

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

filter should be used in such places

Copy link
Contributor Author

Choose a reason for hiding this comment

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

makes sense, I will make a patch file.

@Dinonard Dinonard merged commit f763505 into master May 25, 2023
@Dinonard Dinonard deleted the patch/gen-release-body branch May 25, 2023 05:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci This PR/Issue is related to the topic "CI"
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants