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

chore: screenshots to be dynamically added in prs #1233

Open
wants to merge 1 commit into
base: flutter_app
Choose a base branch
from

Conversation

adityastic
Copy link
Collaborator

@adityastic adityastic commented Mar 8, 2025

Summary by Sourcery

Dynamically generate screenshot tables in pull request comments based on files found in the 'screenshots' directory. Also, update the screenshot file naming convention to use hyphens instead of underscores.

CI:

  • Dynamically generate screenshot tables in pull request comments based on files found in the 'screenshots' directory.
  • Update the screenshot file naming convention to use hyphens instead of underscores.

Copy link
Contributor

sourcery-ai bot commented Mar 8, 2025

Reviewer's Guide by Sourcery

This pull request dynamically generates screenshot tables in the pull request comment workflow based on the files present in the pr-screenshots directory. It also updates the screenshot filename pattern to use hyphens instead of underscores for consistency.

Sequence diagram for generating screenshot HTML

sequenceDiagram
    participant GitHub Actions Workflow
    participant File System

    GitHub Actions Workflow->>File System: Check if 'pr-screenshots' directory exists
    alt Directory exists
        File System-->>GitHub Actions Workflow: Returns true
        GitHub Actions Workflow->>File System: Read files in 'pr-screenshots' directory
        File System-->>GitHub Actions Workflow: Returns list of files
        loop For each file
            GitHub Actions Workflow->>GitHub Actions Workflow: Match filename against regex
            alt Filename matches
                GitHub Actions Workflow->>GitHub Actions Workflow: Extract device name
                GitHub Actions Workflow->>GitHub Actions Workflow: Add file to deviceScreenshots object
            end
        end
        GitHub Actions Workflow->>GitHub Actions Workflow: Generate HTML table from deviceScreenshots
    else Directory does not exist
        File System-->>GitHub Actions Workflow: Returns false
    end
    GitHub Actions Workflow->>GitHub Actions Workflow: Update PR comment with generated HTML
Loading

File-Level Changes

Change Details Files
Dynamically generate screenshot tables in the pull request comment workflow.
  • Replaced hardcoded screenshot tables for Android, iPhone, and iPad with a dynamic table generation based on files in the pr-screenshots directory.
  • Introduced Node.js fs and path modules to read and process files in the pr-screenshots directory.
  • Implemented logic to extract device names from screenshot filenames using a regular expression.
  • Created a deviceScreenshots object to group screenshots by device name.
  • Generated HTML tables for each device with corresponding screenshots.
  • Added a heading for each device screenshot table, replacing underscores with spaces in the device name for better readability.
.github/workflows/pull_request_comment.yml
Modified screenshot filename pattern to use hyphens instead of underscores.
  • Updated the screenshot filename pattern in the pull request comment workflow to use hyphens instead of underscores.
  • Updated the screenshot filename pattern in the pull request closed workflow to use hyphens instead of underscores.
.github/workflows/pull_request_comment.yml
.github/workflows/pull_request_closed.yml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @adityastic - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider adding error handling for file system operations in the GitHub script.
  • The screenshot table generation could be simplified by using a single loop and calculating the number of columns dynamically.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@adityastic adityastic requested a review from AsCress March 8, 2025 11:07
Copy link
Contributor

github-actions bot commented Mar 8, 2025

Build Status

Build successful. APKs to test: https://github.com/fossasia/badgemagic-app/actions/runs/13736940703/artifacts/2715616643.

Screenshots (Android)

Screenshots (iPhone)

Screenshots (iPad)

Copy link
Contributor

@AsCress AsCress left a comment

Choose a reason for hiding this comment

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

@adityastic Looks good to me ! I am not able to imagine as to how the screenshots would look though. Let's maybe merge and try ?

@adityastic adityastic changed the title chore: screenshots to by dynamically added chore: screenshots to be dynamically added in prs Mar 14, 2025
@adityastic adityastic force-pushed the flutter_app branch 2 times, most recently from d14b7e1 to 381b8c8 Compare March 14, 2025 13:48
@Jhalakupadhyay Jhalakupadhyay self-requested a review March 19, 2025 10:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants