ci(signed-commits): check that GitHub verifies every pull request commit - #56
Merged
Merged
Conversation
Adds a Signed commits check that lists the pull request's commits through the API and fails unless each one has a verified signature, naming every offender with GitHub's reason. It fails closed when the list cannot be read in full: an API error, an empty or truncated list, a head that moved, or more than the 250 commits the endpoint returns.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Adds a
Signed commitscheck on pull requests.scripts/check_signed_commits.pylists the pull request's commits through the API and fails unless GitHub reportsverification.verified == truefor every one, printing each offending sha with GitHub's reason and a link to the signing docs. It fails closed on an API error, an empty or truncated list, a head that moved since the event, and more than the 250 commits the endpoint can list. The workflow runs the script's own tests (a fakeghonPATHdriving the command line) before the real check.GitHub's docs say branch protection already evaluates the head branch's commits at merge time; this makes the result a named status on every push that can be required. Dependabot and web-UI commits pass: GitHub signs web-UI commits ("Commits signed by GitHub will have a verified status"), and Dependabot commits across the org list as
verified: true, reason: valid.What's left: add
Signed commitsas a required status check after merge; this PR changes no protection. As with anypull_requestcheck, a pull request can edit this workflow or script and neuter its own run; review of.github/andscripts/is the backstop.Type of change
CI only; no listed type applies.
Required checklist
bash scripts/check_workflows.shandbash scripts/check_hygiene.shpass.pyfiles carry the Apache-2.0 license headerRelated issue
None.
Testing notes
The check failed on an unsigned commit pushed to ori-platform/ori-canonicaljson#3 and passed once it was removed.