Skip to content

Require merged pull request before finishing Step 3 - #70

Merged
arilivigni merged 1 commit into
mainfrom
arilivigni-automatic-barnacle
Aug 7, 2026
Merged

Require merged pull request before finishing Step 3#70
arilivigni merged 1 commit into
mainfrom
arilivigni-automatic-barnacle

Conversation

@arilivigni

Copy link
Copy Markdown
Collaborator

Why

In Step 3, the exercise issue was closing before any pull request was reviewed or merged. The Step 3 grading workflow triggers on any push to main touching docs/**. When the personas/roles change reached main via a direct commit (for example, when the Copilot Cloud Agent commits straight to main instead of opening a pull request), the "personas doc changed" check passed and the exercise finished immediately, closing the exercise issue prematurely.

This was reproduced in a learner copy of the repo: the exercise issue closed seconds after the personas issue was created, triggered by a single-parent commit pushed directly to main with no associated PR.

Approach

Add a guard step to .github/workflows/3-last-step.yml that confirms the pushed change is associated with a merged pull request before the exercise can complete:

  • New step "Verify the update arrived via a merged pull request" queries the commits/{sha}/pulls API for the pushed head commit and requires at least one associated PR with merged_at set.
  • Direct commits to main return no associated PR, so the step fails with actionable feedback and the grading job fails, which prevents finish_exercise from running. The exercise issue stays open until the PR is actually merged.
  • A genuine merge (merge commit or squash) returns the PR, so the guard passes.
  • Added the new check to the step results table and granted pull-requests: read permission.

Notes

  • This intentionally keeps the existing push-to-main trigger (previously chosen to avoid Actions approval prompts) and only gates completion on a real merge.
  • Verified against the affected repo that the API cleanly distinguishes a merged PR push (returns the PR) from a direct commit (returns an empty list). YAML validated.

The Step 3 grading job triggers on any push to main under docs/**. When the
personas/roles change reaches main via a direct commit (for example, when the
Copilot Cloud Agent commits straight to main instead of opening a pull request),
the file check passed and the exercise finished before any pull request was
reviewed or merged, closing the exercise issue prematurely.

Add a guard that confirms the pushed change is associated with a merged pull
request via the commits/{sha}/pulls API. Direct commits now fail with actionable
feedback and the exercise no longer completes until the personas/roles pull
request is actually merged.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings August 7, 2026 01:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the Step 3 grading workflow to ensure the exercise only completes when the personas/roles documentation update reaches main via a merged pull request, preventing premature completion from direct commits that touch docs/**.

Changes:

  • Adds a guard step that queries the commits/{sha}/pulls API and requires at least one associated PR with merged_at set.
  • Adds pull-requests: read permission to support the new API call.
  • Surfaces the new guard’s result in the step results table and ensures the job fails if the guard fails.
Show a summary per file
File Description
.github/workflows/3-last-step.yml Adds a merged-PR verification gate (via gh api) before allowing Step 3 grading to succeed, preventing finish logic from running on direct commits.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Lite

@arilivigni
arilivigni merged commit 88f48a6 into main Aug 7, 2026
1 check passed
@arilivigni
arilivigni deleted the arilivigni-automatic-barnacle branch August 7, 2026 01:13
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