Skip to content

Analyzing GitHub Actions logs and implementing fix - #20

Merged
parvezmosharafvu merged 1 commit into
mainfrom
copilot/fix-failing-github-actions-job
Oct 3, 2026
Merged

parvezmosharafvu merged 1 commit into
mainfrom
copilot/fix-failing-github-actions-job

Conversation

Copilot AI commented Oct 3, 2026 •

Copy link
Copy Markdown

Pull request created by AI Agent

Summary by Sourcery

Skip license-check processing for closed pull requests while preserving failure handling for active pull requests.

Bug Fixes:

  • Prevent the license-check workflow from failing when its pull request has already been closed.

Enhancements:

  • Condition license generation, validation, remediation, and reporting steps on the pull request remaining open.

CI:

  • Improve pull request branch checkout handling by detecting closed pull requests and cleanly skipping license updates.

Co-authored-by: parvezmosharafvu <308653838+parvezmosharafvu@users.noreply.github.com>
@sourcery-ai

sourcery-ai Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

The license-check workflow now distinguishes closed pull requests from other checkout failures: it exits cleanly with a notice for closed PRs and skips all license validation/remediation steps, while preserving existing behavior for active PRs and unexpected errors.

Flow diagram for closed pull request license-check handling

flowchart TD
    A[Check out PR branch] --> B{gh pr checkout succeeds?}
    B -->|Yes| C[Run license validation and remediation]
    B -->|No| D[gh pr view PR state]
    D --> E{PR state is CLOSED?}
    E -->|Yes| F[Set skip output and emit notice]
    F --> G[Skip license validation and remediation]
    E -->|No| H[Fail workflow]
    C --> I{License changes needed?}
    I -->|No| J[Complete successfully]
    I -->|Yes| K[Commit and push fixes]
    K --> L{Push succeeds?}
    L -->|Yes| J
    L -->|No| M[Check existing comment and notify if needed]
    M --> N[Fail check]
Loading

File-Level Changes

Change Details Files
Add explicit handling for failed checkout of closed pull requests.
  • Capture the checkout step outcome with an ID and PR number environment variable.
  • Retry state inspection after checkout failure and mark closed PRs for skipping.
  • Preserve failure behavior for checkout errors unrelated to closed PRs.
.github/workflows/license-check.yml
Skip license validation and remediation when a pull request is closed.
  • Condition build, Go setup, license regeneration, and change detection on the skip output.
  • Guard commit, comment, and final failure steps against the skip state.
  • Continue reporting required license changes and remediation failures for active pull requests.
.github/workflows/license-check.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

@parvezmosharafvu
parvezmosharafvu self-requested a review October 3, 2026 06:07
@parvezmosharafvu
parvezmosharafvu marked this pull request as ready for review October 3, 2026 06:08

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've found 3 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path=".github/workflows/license-check.yml" line_range="36-44" />
<code_context>
-        run: gh pr checkout ${{ github.event.pull_request.number }}
+          PR_NUMBER: ${{ github.event.pull_request.number }}
+        run: |
+          if gh pr checkout "$PR_NUMBER"; then
+            exit 0
+          fi
+
</code_context>
<issue_to_address>
**issue (bug_risk):** A closed pull request whose branch is still checkoutable proceeds through license validation and remediation because the workflow checks the pull request state only after `gh pr checkout` fails. The workflow can therefore regenerate and push license updates to a closed pull request.

**Triggers:** When a pull request is closed but its source branch remains available, including a workflow run that continues after the PR is closed.

**Suggested fix:** Check the pull request state before attempting checkout, or query the state after a successful checkout as well and set `skip=true` for closed pull requests.
</issue_to_address>

### Comment 2
<location path=".github/workflows/license-check.yml" line_range="40-44" />
<code_context>
+            exit 0
+          fi
+
+          state=$(gh pr view "$PR_NUMBER" --json state --jq '.state')
+          if [[ "$state" == "CLOSED" ]]; then
+            echo "skip=true" >> "$GITHUB_OUTPUT"
+            echo "::notice::Pull request is closed; skipping license update."
+            exit 0
+          fi
+
</code_context>
<issue_to_address>
**issue (bug_risk):** A checkout failure for a merged pull request is treated as an unexpected checkout error because the reported state is `MERGED`, not `CLOSED`; the workflow therefore fails instead of skipping the already-closed pull request.

**Triggers:** When the pull request is merged and its branch or pull-request ref can no longer be checked out.

**Suggested fix:** Treat both `CLOSED` and `MERGED` states as skippable, or use the pull request's closed/merged status explicitly.
</issue_to_address>

### Comment 3
<location path=".github/workflows/license-check.yml" line_range="36-47" />
<code_context>
-        run: gh pr checkout ${{ github.event.pull_request.number }}
+          PR_NUMBER: ${{ github.event.pull_request.number }}
+        run: |
+          if gh pr checkout "$PR_NUMBER"; then
+            exit 0
+          fi
+
</code_context>
<issue_to_address>
**issue (bug_risk):** Any checkout failure on a pull request whose API state is `CLOSED` is converted into a successful skipped step, including failures caused by authentication, network, Git, or another checkout problem unrelated to closure. The workflow then passes without reporting the real checkout failure.

**Triggers:** When a closed pull request encounters a non-closure-related checkout error.

**Suggested fix:** Preserve the checkout failure unless the failure is known to result from a closed or merged pull request, or validate the relevant PR state before checkout and distinguish other errors.

```suggestion
          state=$(gh pr view "$PR_NUMBER" --json state --jq '.state')
          if [[ "$state" == "CLOSED" || "$state" == "MERGED" ]]; then
            echo "skip=true" >> "$GITHUB_OUTPUT"
            echo "::notice::Pull request is closed or merged; skipping license update."
            exit 0
          fi

          gh pr checkout "$PR_NUMBER"
```
</issue_to_address>

Sourcery assessment

Approval pending. 3 findings to address first.

Blocking findings: .github/workflows/license-check.yml:44, .github/workflows/license-check.yml:44, .github/workflows/license-check.yml:47


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment on lines +36 to +44
if gh pr checkout "$PR_NUMBER"; then
exit 0
fi

state=$(gh pr view "$PR_NUMBER" --json state --jq '.state')
if [[ "$state" == "CLOSED" ]]; then
echo "skip=true" >> "$GITHUB_OUTPUT"
echo "::notice::Pull request is closed; skipping license update."
exit 0

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue (bug_risk): A closed pull request whose branch is still checkoutable proceeds through license validation and remediation because the workflow checks the pull request state only after gh pr checkout fails. The workflow can therefore regenerate and push license updates to a closed pull request.

Triggers: When a pull request is closed but its source branch remains available, including a workflow run that continues after the PR is closed.

Suggested fix: Check the pull request state before attempting checkout, or query the state after a successful checkout as well and set skip=true for closed pull requests.

Comment on lines +40 to +44
state=$(gh pr view "$PR_NUMBER" --json state --jq '.state')
if [[ "$state" == "CLOSED" ]]; then
echo "skip=true" >> "$GITHUB_OUTPUT"
echo "::notice::Pull request is closed; skipping license update."
exit 0

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue (bug_risk): A checkout failure for a merged pull request is treated as an unexpected checkout error because the reported state is MERGED, not CLOSED; the workflow therefore fails instead of skipping the already-closed pull request.

Triggers: When the pull request is merged and its branch or pull-request ref can no longer be checked out.

Suggested fix: Treat both CLOSED and MERGED states as skippable, or use the pull request's closed/merged status explicitly.

Comment on lines +36 to +47
if gh pr checkout "$PR_NUMBER"; then
exit 0
fi

state=$(gh pr view "$PR_NUMBER" --json state --jq '.state')
if [[ "$state" == "CLOSED" ]]; then
echo "skip=true" >> "$GITHUB_OUTPUT"
echo "::notice::Pull request is closed; skipping license update."
exit 0
fi

exit 1

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue (bug_risk): Any checkout failure on a pull request whose API state is CLOSED is converted into a successful skipped step, including failures caused by authentication, network, Git, or another checkout problem unrelated to closure. The workflow then passes without reporting the real checkout failure.

Triggers: When a closed pull request encounters a non-closure-related checkout error.

Suggested fix: Preserve the checkout failure unless the failure is known to result from a closed or merged pull request, or validate the relevant PR state before checkout and distinguish other errors.

Suggested change
if gh pr checkout "$PR_NUMBER"; then
exit 0
fi
state=$(gh pr view "$PR_NUMBER" --json state --jq '.state')
if [[ "$state" == "CLOSED" ]]; then
echo "skip=true" >> "$GITHUB_OUTPUT"
echo "::notice::Pull request is closed; skipping license update."
exit 0
fi
exit 1
state=$(gh pr view "$PR_NUMBER" --json state --jq '.state')
if [[ "$state" == "CLOSED" || "$state" == "MERGED" ]]; then
echo "skip=true" >> "$GITHUB_OUTPUT"
echo "::notice::Pull request is closed or merged; skipping license update."
exit 0
fi
gh pr checkout "$PR_NUMBER"

@parvezmosharafvu
parvezmosharafvu merged commit 71de548 into main Oct 3, 2026
18 of 19 checks passed
@parvezmosharafvu
parvezmosharafvu deleted the copilot/fix-failing-github-actions-job branch October 3, 2026 06:10
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.

2 participants