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

ci(actions): add workflow to calculate and surface PR merge rate #17684

Merged
merged 5 commits into from
Oct 10, 2024

Conversation

tay1orjones
Copy link
Member

@tay1orjones tay1orjones commented Oct 8, 2024

This workflow calculates the merge rate of PRs for the past week in this repo. The workflow outputs the data to slack as well as an actions job summary so we can view the output within the Actions tab on github.

Changelog

New

  • add metrics-merge-rate.yml

Changed

  • rename the repo stats workflow to metrics-repo-stats.yml so these two workflows sit together alphabetically in the sidebar of code editors and the actions view here on github

Testing / Reviewing

I used a modified version of this locally to gather data from the last 12 weeks

#!/bin/bash

# Repository to analyze
REPO="carbon-design-system/carbon"
WEEKS=12

echo "Calculating weekly merge rates for the last $WEEKS weeks for repository $REPO"

# Loop over the past 12 weeks
for (( i=0; i<$WEEKS; i++ ))
do
  START_DATE=$(date -v-$(($i+1))w +%Y-%m-%d)
  END_DATE=$(date -v-$i\w +%Y-%m-%d)

  # Get merged PRs within the date range
  MERGED_COUNT=$(gh pr list --repo "$REPO" --state merged --search "merged:$START_DATE..$END_DATE" --limit 1000 | wc -l)
  # Get all PRs created within the date range
  TOTAL_COUNT=$(gh pr list --repo "$REPO" --state all --search "created:$START_DATE..$END_DATE" --limit 1000 | wc -l)

  if [ "$TOTAL_COUNT" -gt 0 ]; then
    MERGE_RATE=$(echo "scale=2; ($MERGED_COUNT / $TOTAL_COUNT) * 100" | bc)
    echo "Week ending $END_DATE: Merge Rate: $MERGE_RATE% (Merged PRs: $MERGED_COUNT, Total PRs: $TOTAL_COUNT)"
  else
    echo "Week ending $END_DATE: No PRs found. Merge Rate: 0% (Merged PRs: $MERGED_COUNT, Total PRs: $TOTAL_COUNT)"
  fi
done

Weekly merge rates for the last 12 weeks

Week ending on Merge rate Merged PRs Total PRs created
2024-10-08 84% 27 32
2024-10-01 75% 24 32
2024-09-24 67% 25 37
2024-09-17 97% 36 37
2024-09-10 75% 24 32
2024-09-03 92% 25 27
2024-08-27 64% 24 37
2024-08-20 64% 25 39
2024-08-13 80% 21 26
2024-08-06 126% 19 15
2024-07-30 80% 17 21
2024-07-23 50% 13 26

@tay1orjones tay1orjones requested a review from a team as a code owner October 8, 2024 19:36
@tay1orjones tay1orjones self-assigned this Oct 8, 2024
Copy link

netlify bot commented Oct 8, 2024

Deploy Preview for carbon-elements ready!

Name Link
🔨 Latest commit f580951
🔍 Latest deploy log https://app.netlify.com/sites/carbon-elements/deploys/670589c121886b00076e552e
😎 Deploy Preview https://deploy-preview-17684--carbon-elements.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Oct 8, 2024

Deploy Preview for v11-carbon-react ready!

Name Link
🔨 Latest commit f580951
🔍 Latest deploy log https://app.netlify.com/sites/v11-carbon-react/deploys/670589c14f549a0008e92d1b
😎 Deploy Preview https://deploy-preview-17684--v11-carbon-react.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Oct 8, 2024

Deploy Preview for carbon-elements ready!

Name Link
🔨 Latest commit c0dbf3a
🔍 Latest deploy log https://app.netlify.com/sites/carbon-elements/deploys/6706c1d3fe4e0f000840a5f8
😎 Deploy Preview https://deploy-preview-17684--carbon-elements.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Oct 8, 2024

Deploy Preview for v11-carbon-react ready!

Name Link
🔨 Latest commit c0dbf3a
🔍 Latest deploy log https://app.netlify.com/sites/v11-carbon-react/deploys/6706c1d36d49930009400b78
😎 Deploy Preview https://deploy-preview-17684--v11-carbon-react.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

codecov bot commented Oct 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 77.19%. Comparing base (72617dd) to head (ab88c93).

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #17684   +/-   ##
=======================================
  Coverage   77.19%   77.19%           
=======================================
  Files         409      409           
  Lines       14025    14025           
  Branches     4355     4307   -48     
=======================================
  Hits        10827    10827           
  Misses       3029     3029           
  Partials      169      169           

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

Copy link
Member

@alisonjoseph alisonjoseph left a comment

Choose a reason for hiding this comment

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

nice!

Copy link
Member

@kennylam kennylam left a comment

Choose a reason for hiding this comment

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

This is great!

@tay1orjones tay1orjones added this pull request to the merge queue Oct 10, 2024
Merged via the queue into carbon-design-system:main with commit 8abaf92 Oct 10, 2024
23 checks passed
@tay1orjones tay1orjones deleted the merge-rate-action branch October 10, 2024 14:44
annawen1 pushed a commit to annawen1/carbon that referenced this pull request Oct 11, 2024
…bon-design-system#17684)

* ci(actions): add workflow to calculate and surface PR merge rate

* ci(actions): add workflow to calculate and surface PR merge rate

---------

Co-authored-by: Nikhil Tomar <63502271+2nikhiltom@users.noreply.github.com>
Co-authored-by: Alison Joseph <alison.joseph@us.ibm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

4 participants