Pull Request Analytics Action: A Comprehensive Guide

Apr 25, 2021 | Data Science

In the rapidly evolving world of software development, understanding team dynamics and improving workflow efficiency is paramount. The pull-request-analytics-action on GitHub provides essential metrics that allow developers and teams to optimize their performance. This article serves as a detailed guide on how to implement this action, covering its motivations, setup, configuration, and troubleshooting tips.

Table of Contents

Motivation

The pull-request-analytics-action addresses several key challenges faced in software development:

  • Identifying Bottlenecks in Code Review Processes: Generate summaries that reveal delays occurring during review stages.
  • Tracking Trends in Code Review Processes: Analyze changes in review dynamics over time to highlight positive or negative trends.
  • Detecting Significant Deviations: Spot metric discrepancies among teams and developers to identify potential concerns.
  • Simplifying Analysis of Notable PRs: Identify standout pull requests for focused attention.

Metrics

All metrics are presented in tables, charts, and lists, showcasing essential data for analysis. For example, consider two software developers who are building a cutting-edge application. One is meticulous and spends a lot of time refining code, causing some delays in overall delivery. The other is proficient but might rush through reviews. The metrics would reveal these differences, helping the team understand individual contributions and spot potential areas for improvement.

Metrics Overview

  • Lead Time: Measures the time from PR creation to various statuses, aiding in spotting bottlenecks.
  • Contribution: Tracks opened, merged, and reverted PRs along with additions and deletions.
  • Discussion Intensity (Author’s Perspective): Measures how discussion-heavy PRs are based on comments and reviews.
  • Reviewer Response Time: Tracks how quickly reviewers respond to requests, essential for understanding reviewer engagement.

Getting Started

To integrate pull-request-analytics-action into your GitHub repository, follow these steps:

  1. Navigate to the .github/workflows directory in your repository.
  2. Create a new YAML file, for example, pull-request-analytics.yml.
  3. Open your newly created file and paste the following example workflow:
  4. name: PR Analytics
    on:
      workflow_dispatch:
        inputs:
          report_date_start:
            description: Report date start(dMMyyyy)
          report_date_end:
            description: Report date end(dMMyyyy)
    jobs:
      create-report:
        name: Create report
        runs-on: ubuntu-latest
        steps:
          - name: Run script for analytics
            uses: AlexSim93/pull-request-analytics-action@v3
            with:
              GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
              GITHUB_REPO_FOR_ISSUE: repo
              GITHUB_OWNER_FOR_ISSUE: owner
              GITHUB_OWNERS_REPOS: ownerrepo
              CORE_HOURS_START: 9:00
              CORE_HOURS_END: 19:00
              TIMEZONE: Europe/Berlin
              REPORT_DATE_START: ${{ inputs.report_date_start }}
              REPORT_DATE_END: ${{ inputs.report_date_end }}
  5. Adjust the parameters as needed for your specific requirements.
  6. Click on the Actions tab and run the workflow.

Using GitHub Enterprise Server

To use this action with GitHub Enterprise Server, set the GITHUB_API_URL environment variable in your workflow file.

env:
  GITHUB_API_URL: http(s)://HOSTNAME/api/v3

Configuration Parameters Overview

Customize the action using various parameters including:

  • GITHUB_TOKEN: Required to authenticate access.
  • SHOW_STATS_TYPES: Specify which stats you want displayed in the report.
  • CORE_HOURS_START: Define working hours for more accurate metrics.

Outputs

The action can generate outputs such as:

  • JSON_COLLECTION: A JSON object containing collected data.
  • MARKDOWN: The report as a markdown string.

Recommendations and Tips

  • Use a Personal Access Token (classic) for multi-repository reports.
  • Leverage the schedule event for optimal report updates without exceeding rate limits.
  • Utilize filtering through the EXCLUDE_LABELS and INCLUDE_LABELS parameters to refine data.

Privacy and Data Handling

This action is stateless, meaning it does not store collected data but sends anonymous inputs to Mixpanel to improve user experience. Set ALLOW_ANALYTICS to false to disable data transmission.

Usage Limitations

The action adheres to GitHub’s API rate limits. If working with very large datasets, consider possible adjustments. The output report length is limited to 65,536 characters due to GitHub’s Issue size constraints.

Troubleshooting

If you encounter any issues while setting up or using the action, here are some troubleshooting ideas:

  • Ensure all required parameters are correctly set in your YAML file.
  • Check the GitHub token and ensure it has the necessary permissions.
  • If metrics appear incorrect, verify the core hours and time zone settings.

For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.

At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.

Stay Informed with the Newest F(x) Insights and Blogs

Tech News and Blog Highlights, Straight to Your Inbox