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

Fix changelog generator so that all PR commits are checked #5474

Merged
merged 1 commit into from
Apr 16, 2024

Conversation

noahtallen
Copy link
Contributor

@noahtallen noahtallen commented Apr 16, 2024

Description

When working through a recent mu-plugins release, a changelog was not generated for production. After some digging, I realized the script was only fetching 30 of the many PRs associated, and so some PRs/commits were not being checked for chaneglogs. (So if the first 30 commits had no changelog entry, no post would be generated.)

Thankfully, this endpoint can be paginated with page and per_page, so we simply request with page++ until the page is empty. At that point, we have all the commits for the request.

Steps to Test

First, create a test.php file, and copy both the curl_get_all and curl_get functions from this branch into that file. Then, add this test code:

$commit_url = 'https://api.github.com/repos/Automattic/vip-go-mu-plugins/pulls/5472/commits';

$some_data = curl_get($commit_url);
print_r($some_data[0]);
echo( "\nPartial commits count: " . count( $some_data ) );

$all_data = curl_get_all( $commit_url );
print_r($all_data[0]);
echo( "\nAll commits count: " . count( $all_data ) );

You can compare the two commits to see that they are the same, and verify that more commits are requested using the new approach.

…logs.

The GH request to fetch all commits for a PR only returns 30 results, and no
pagination information. This change manually paginates the URL until no results
are returned, and uses the new paginator function when we get PRs associated
with the primary release PR.
@noahtallen noahtallen self-assigned this Apr 16, 2024
@noahtallen noahtallen requested a review from a team as a code owner April 16, 2024 20:42
Copy link

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

Copy link

codecov bot commented Apr 16, 2024

Codecov Report

Attention: Patch coverage is 0% with 7 lines in your changes are missing coverage. Please review.

Project coverage is 28.96%. Comparing base (effba8a) to head (48e5043).
Report is 1 commits behind head on develop.

Files Patch % Lines
ci/changelog-summary.php 0.00% 7 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             develop    #5474      +/-   ##
=============================================
+ Coverage      28.85%   28.96%   +0.10%     
  Complexity      4855     4855              
=============================================
  Files            284      284              
  Lines          21019    21012       -7     
=============================================
+ Hits            6065     6086      +21     
+ Misses         14954    14926      -28     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@rinatkhaziev rinatkhaziev left a comment

Choose a reason for hiding this comment

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

thank you for the fix!

@noahtallen noahtallen merged commit ebcc0b3 into develop Apr 16, 2024
40 of 41 checks passed
@noahtallen noahtallen deleted the fix/changelog-parsing-all-commits branch April 16, 2024 22:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants