Repository navigation
Analyzing GitHub Actions logs and implementing fix - #20
Conversation
Co-authored-by: parvezmosharafvu <308653838+parvezmosharafvu@users.noreply.github.com>
Reviewer's GuideThe 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 handlingflowchart 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]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
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
| 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 |
There was a problem hiding this comment.
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.
| 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 |
There was a problem hiding this comment.
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.
| 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 |
There was a problem hiding this comment.
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.
| 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" |
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:
Enhancements:
CI: