Skip to content

chore: fix PR ABI validation logic (v2)#109

Merged
Aliorpse merged 2 commits intomainfrom
chore/fix-workflow-v2
Jan 31, 2026
Merged

chore: fix PR ABI validation logic (v2)#109
Aliorpse merged 2 commits intomainfrom
chore/fix-workflow-v2

Conversation

@Aliorpse
Copy link
Owner

This PR addresses logic issues and incorporates AI review feedback for the ABI validation workflow.

Changes:

  1. Replaced process.exit(0): Used structured outputs to control subsequent steps, as process.exit(0) doesn't stop following steps in a job.
  2. Default Output Value: Added core.setOutput('should_run', 'false') at the beginning of the script to ensure the variable has a predictable default state, as suggested by AI review.
  3. Step Conditions: Added if conditions to all dependent steps.

Note:

The previous PR (#108) was deleted/closed due to branch sync issues. This is the updated version on a clean branch.

Submitted by AI (Aliorpse's Token)

@sourcery-ai
Copy link

sourcery-ai bot commented Jan 31, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Updates the PR ABI validation workflow to use an explicit should_run output flag and conditional step execution instead of relying on process termination semantics, ensuring predictable and controllable behavior of the job steps based on review approval status.

Sequence diagram for ABI validation workflow control using should_run output

sequenceDiagram
    actor Developer
    participant GitHub
    participant pr_validation_job
    participant check_reviews_step
    participant setup_jdk_step
    participant abi_validation_step

    Developer->>GitHub: Open or update pull_request
    GitHub->>pr_validation_job: Trigger pr_validation workflow

    pr_validation_job->>check_reviews_step: Run github-script
    check_reviews_step->>check_reviews_step: core.setOutput(should_run, false)
    check_reviews_step->>GitHub: github.rest.pulls.listReviews
    GitHub-->>check_reviews_step: Review list

    check_reviews_step->>check_reviews_step: Determine latest review per user
    check_reviews_step->>check_reviews_step: Compute allApproved

    alt allApproved is true
        check_reviews_step->>check_reviews_step: core.setOutput(should_run, true)
    else allApproved is false
        check_reviews_step->>check_reviews_step: Log skipping message
    end

    pr_validation_job->>setup_jdk_step: Run Set up JDK (always runs)

    alt should_run == true
        pr_validation_job->>abi_validation_step: Run ABI Validation
        abi_validation_step->>abi_validation_step: ./gradlew checkLegacyAbi
    else should_run == false
        pr_validation_job-->>abi_validation_step: Skip due to if condition
    end
Loading

Flow diagram for updated should_run decision logic in check_reviews step

flowchart TD
    A[Start check_reviews script] --> B[Set output should_run = false]
    B --> C[Fetch PR reviews via github.rest.pulls.listReviews]
    C --> D[Build latestReviews map per user]
    D --> E[Extract states and compute allApproved]
    E -->|allApproved == true| F[Log: All reviewers approved]
    F --> G[Set output should_run = true]
    E -->|allApproved == false| H[Log: Skipping ABI validation]
    G --> I[End script]
    H --> I[End script]
Loading

File-Level Changes

Change Details Files
Make should_run output deterministic and driven solely by review approval state.
  • Initialize the should_run output to 'false' at the start of the GitHub Script step to guarantee a default value.
  • Adjust the review approval logic so that should_run is set to 'true' only when all reviewers have approved, otherwise it remains or falls back to 'false'.
  • Improve logging messages to clearly distinguish when validation will proceed versus be skipped based on approvals.
.github/workflows/pr_validation.yml
Gate downstream ABI validation on the should_run output instead of relying on process exit behavior.
  • Replace the previous early-exit behavior with explicit use of the should_run output to control subsequent workflow steps.
  • Add an if condition on the ABI Validation step that checks the check_reviews.should_run output before running the Gradle command.
  • Ensure the JDK setup and ABI validation steps are only executed when should_run is 'true', aligning runtime behavior with review status.
.github/workflows/pr_validation.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!

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

@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 - I've left some high level feedback:

  • In the review-check script, relying on the initial default core.setOutput('should_run', 'false') makes the else branch implicit; consider explicitly setting it back to 'false' in the else block for clearer, more robust logic if the script is modified later.
  • The workflow comment // Initialize with a default value as suggested by AI review is meta-process detail; consider simplifying or removing it so the file focuses on behavior rather than how the change was decided.
  • The PR description mentions adding if conditions to all dependent steps, but only the ABI Validation step is gated; double-check whether Set up JDK (and any other steps that should be skipped) also need the should_run condition for consistency with the intended behavior.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In the review-check script, relying on the initial default `core.setOutput('should_run', 'false')` makes the `else` branch implicit; consider explicitly setting it back to `'false'` in the `else` block for clearer, more robust logic if the script is modified later.
- The workflow comment `// Initialize with a default value as suggested by AI review` is meta-process detail; consider simplifying or removing it so the file focuses on behavior rather than how the change was decided.
- The PR description mentions adding `if` conditions to all dependent steps, but only the `ABI Validation` step is gated; double-check whether `Set up JDK` (and any other steps that should be skipped) also need the `should_run` condition for consistency with the intended behavior.

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.

@Aliorpse Aliorpse merged commit a125893 into main Jan 31, 2026
2 checks passed
@Aliorpse Aliorpse deleted the chore/fix-workflow-v2 branch January 31, 2026 16:01
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.

1 participant