Skip to content

test: unsigned commit to verify CI check#304

Closed
SpaceFace02 wants to merge 0 commit into
trusted-execution-clusters:mainfrom
SpaceFace02:add-commit-verification
Closed

test: unsigned commit to verify CI check#304
SpaceFace02 wants to merge 0 commit into
trusted-execution-clusters:mainfrom
SpaceFace02:add-commit-verification

Conversation

@SpaceFace02

@SpaceFace02 SpaceFace02 commented Jul 2, 2026

Copy link
Copy Markdown
Member

Commit verification.

Branch Protection rules must be configured for stricter gating.

Summary by Sourcery

CI:

  • Introduce a GitHub Actions workflow that verifies all PR commits are GPG-signed and authored by the pull request owner, failing the check otherwise.

@sourcery-ai

sourcery-ai Bot commented Jul 2, 2026

Copy link
Copy Markdown

Reviewer's Guide

Adds a GitHub Actions workflow that enforces all PR commits to be GPG/SSH verified and authored by the PR owner, failing the job with clear error messages when checks fail.

Sequence diagram for the new commit verification GitHub Action

sequenceDiagram
    actor Developer
    participant GitHub
    participant Workflow_commit_verification as Commit_Verification_Workflow
    participant GitHub_API

    Developer->>GitHub: open pull_request to main
    GitHub-->>Workflow_commit_verification: trigger verify-commits job

    Workflow_commit_verification->>GitHub_API: gh api /repos/{repo}/pulls/{number}/commits
    GitHub_API-->>Workflow_commit_verification: list of commits with verification and author

    alt [any commit not verified]
        Workflow_commit_verification-->>GitHub: ::error::Commit {sha} is not signed
    else [commit author mismatch]
        Workflow_commit_verification-->>GitHub: ::error::Commit {sha} author does not match PR owner
    else [all commits verified and authored by PR owner]
        Workflow_commit_verification-->>GitHub: All commits are signed and authored by PR owner
    end
Loading

File-Level Changes

Change Details Files
Introduce a commit verification GitHub Actions workflow for pull requests targeting main.
  • Define a pull_request-triggered workflow with minimal read-only permissions and concurrency control to avoid overlapping runs.
  • Add a single job that uses the GitHub CLI to list PR commits and inspect their verification and author metadata.
  • Implement a shell script that emits GitHub Actions ::error annotations when a commit is unsigned or its author does not match the PR owner, causing the workflow to fail.
  • Print a success message when all commits are properly signed and authored by the PR owner.
.github/workflows/commit-verification.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

@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 1 issue, and left some high level feedback:

  • Requiring every commit in the PR to be authored by the PR owner will block common workflows like maintainers pushing to a contributor’s branch or multiple authors collaborating; consider relaxing this to only enforce signatures or to allow a configurable set of allowed authors.
  • The authorship check may fail for merge commits, GitHub UI edits (e.g., web-flow), or bot commits where .author.login differs from the PR owner; you might want to explicitly skip those cases or filter only non-merge, human-authored commits.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Requiring every commit in the PR to be authored by the PR owner will block common workflows like maintainers pushing to a contributor’s branch or multiple authors collaborating; consider relaxing this to only enforce signatures or to allow a configurable set of allowed authors.
- The authorship check may fail for merge commits, GitHub UI edits (e.g., `web-flow`), or bot commits where `.author.login` differs from the PR owner; you might want to explicitly skip those cases or filter only non-merge, human-authored commits.

## Individual Comments

### Comment 1
<location path=".github/workflows/commit-verification.yml" line_range="28-37" />
<code_context>
+        env:
+          GH_TOKEN: ${{ github.token }}
+          PR_AUTHOR: ${{ github.event.pull_request.user.login }}
+        run: |
+          errors=$(gh api "repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/commits" \
+             -q '
+              .[] | .sha[:12] as $s |
+              (if .commit.verification.verified != true
+               then "::error::Commit \($s) is not signed (\(.commit.verification.reason))"
+               else empty end),
+              (if (.author.login // "") != env.PR_AUTHOR
+               then "::error::Commit \($s) author (\(.author.login // "unknown")) does not match PR owner (\(env.PR_AUTHOR))"
+               else empty end)
+            ')
+          if [ -n "${errors}" ]; then
+            echo "${errors}"
+            exit 1
+          fi
+          echo "All commits are signed and authored by ${PR_AUTHOR}."
</code_context>
<issue_to_address>
**suggestion (bug_risk):** Consider adding shell strict mode to make the verification script more robust.

Without strict mode, failures from `gh api` or `jq` (e.g., missing `gh`, rate limits, malformed JSON) won’t cause the step to fail, and `errors` may end up empty or partial, letting the job appear to succeed. Adding `set -euo pipefail` near the top of the script ensures any unexpected command failure stops the step immediately.
</issue_to_address>

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.

Comment on lines +28 to +37
run: |
errors=$(gh api "repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/commits" \
-q '
.[] | .sha[:12] as $s |
(if .commit.verification.verified != true
then "::error::Commit \($s) is not signed (\(.commit.verification.reason))"
else empty end),
(if (.author.login // "") != env.PR_AUTHOR
then "::error::Commit \($s) author (\(.author.login // "unknown")) does not match PR owner (\(env.PR_AUTHOR))"
else empty end)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion (bug_risk): Consider adding shell strict mode to make the verification script more robust.

Without strict mode, failures from gh api or jq (e.g., missing gh, rate limits, malformed JSON) won’t cause the step to fail, and errors may end up empty or partial, letting the job appear to succeed. Adding set -euo pipefail near the top of the script ensures any unexpected command failure stops the step immediately.

@SpaceFace02 SpaceFace02 force-pushed the add-commit-verification branch 3 times, most recently from 17dcc53 to 709895c Compare July 2, 2026 09:44
@SpaceFace02 SpaceFace02 closed this Jul 2, 2026
@SpaceFace02 SpaceFace02 force-pushed the add-commit-verification branch from 709895c to bbd1046 Compare July 2, 2026 09:47
@openshift-ci

openshift-ci Bot commented Jul 2, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: SpaceFace02

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

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