Skip to content

Commit 1ab494e

Browse files
committed
move git commit checker to separate repository
The YAML and Python script originated from the OMPI repository (diverged here: open-mpi/ompi@ef866a4) An OMPI maintainer wanted this and the label bot in two of their other repos. Instead of copying the code to their repo(s), it is far simpler to move the actions to separate repos and publish them on the GitHub marketplace. The functionality remains the same, but the YAML had to be tweaked to work as a reusable (marketplace) action. These changes are: * add / change the action name, description, branding, and inputs * remove the trigger * remove permissions * specify composite action (runs:) * remove os specification * specify shell for each command run * use github.action_path instead of the env variable GITHUB_WORKSPACE Instead of using JSON for config, we instead take the values as inputs, and give them the same defaults in the JSON/code. This resulted in a minor change to the Python script: removing the loading of the JSON file and instead get values from the environment. Signed-off-by: Joe Downs <[email protected]>
1 parent 45d7c03 commit 1ab494e

File tree

3 files changed

+467
-0
lines changed

3 files changed

+467
-0
lines changed

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Pull Request Git Commit Checker
2+
A minor action which checks commits on a pull request for certain conformity
3+
policies. If all commits pass, the action succeeds and no comment emitted. If a
4+
check fails for one or many commits, the action fails and a comment is placed on
5+
the PR explaining which commits caused the failure and why. For instance, if
6+
contributed commits need to be signed off, a comment with this message will
7+
appear:
8+
9+
`e3042c1`**: foobar**
10+
* *check_signed_off: does not contain a valid Signed-off-by line*
11+
12+
13+
*Uses [SemVer 2.0.0](https://semver.org/spec/v2.0.0.html)*

action.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Pull Request Git Commit Checker
2+
description: Checks pull request commits for policy conformity
3+
branding:
4+
icon: check-square
5+
color: green
6+
inputs:
7+
token:
8+
description: "The GITHUB_TOKEN secret"
9+
required: true
10+
cherry-pick-required:
11+
description: "Whether the cherry-pick message is required"
12+
required: false
13+
default: false
14+
permit-empty:
15+
description: "Allow empty commit messages"
16+
required: false
17+
default: false
18+
19+
runs:
20+
using: "composite"
21+
steps:
22+
- name: Check out the code
23+
uses: actions/checkout@v2
24+
with:
25+
# Get all branches and history
26+
fetch-depth: 0
27+
28+
- name: Setup Python
29+
uses: actions/setup-python@v2
30+
with:
31+
python-version: '3.x'
32+
33+
- name: Get the GitPython and PyGithub modules
34+
run: pip install gitpython PyGithub
35+
shell: bash
36+
37+
- name: Check all git commits
38+
run: ${{ github.action_path }}/git-commit-checks.py
39+
shell: bash
40+
env:
41+
GITHUB_TOKEN: ${{ inputs.token }}
42+
CHERRY_PICK_REQUIRED: ${{ inputs.cherry-pick-required }}
43+
PERMIT_EMPTY: ${{ inputs.permit-empty }}
44+
PR_NUM: ${{ github.event.number }}

0 commit comments

Comments
 (0)