Skip to content

Commit

Permalink
fix : added merge group support + action.yml for github action (#129)
Browse files Browse the repository at this point in the history
Signed-off-by: Ethan Perruzza <[email protected]>
  • Loading branch information
EthanPERRUZZA authored Sep 20, 2024
1 parent 30353d8 commit c9ae1d5
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 27 deletions.
22 changes: 10 additions & 12 deletions .github/workflows/dco.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,17 @@ on:
- master

jobs:
check:
check_dco:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
name: Check DCO
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Check DCO
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
python3 dco_check/dco_check.py --verbose
- name: Run dco-check
uses: christophebedard/dco-check@master
with:
python-version: ${{ matrix.python-version }}
args: '--verbose'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
Expand Down
23 changes: 11 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,22 +112,21 @@ on:
branches:
- master
jobs:
check:
check_dco:
runs-on: ubuntu-latest
name: Check DCO
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.x
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Check DCO
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
pip3 install -U dco-check
dco-check
- name: Run dco-check
uses: christophebedard/[email protected]
with:
python-version: '3.12'
args: '--verbose'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```

Please note that the `with:` property is optional, the default Python version is 3.12 and no additional arguments are passed by default.

### GitLab

```yaml
Expand Down
25 changes: 25 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# action.yml
name: 'DCO check'
description: 'A reusable action that checks that all commits for a proposed change are signed off'

inputs:
args:
description: "Arguments to be added the dco_check.py execution line."
required: false
default: ''
python-version:
description: "The version of python to be used."
required: false
default: '3.12'

runs:
using: "composite"
steps:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}

- name: Check DCO
run: python ${{ github.action_path }}/dco_check/dco_check.py ${{ inputs.args }}
shell: bash
10 changes: 10 additions & 0 deletions dco_check/dco_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -931,6 +931,16 @@ def get_commit_range(self) -> Optional[Tuple[str, str]]: # noqa: D102
f"\ton pull request branch '{commit_branch_head}': "
f"will check commits off of base branch '{commit_branch_base}'"
)
elif event_name == 'merge_group':
# See: https://docs.github.com/en/webhooks/webhook-events-and-payloads#merge_group
commit_hash_base = self.event_payload['merge_group']['base_sha']
commit_hash_head = self.event_payload['merge_group']['head_sha']
commit_branch_base = self.event_payload['merge_group']['base_ref']
commit_branch_head = self.event_payload['merge_group']['head_ref']
logger.verbose_print(
f"\ton merge group branch '{commit_branch_head}': "
f"will check commits off of base branch '{commit_branch_base}'"
)
elif event_name == 'push':
# See: https://developer.github.com/v3/activity/events/types/#pushevent
created = self.event_payload['created']
Expand Down
3 changes: 1 addition & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@ classifiers =
License :: OSI Approved :: Apache Software License
Operating System :: POSIX
Programming Language :: Python
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Programming Language :: Python :: 3.12
Topic :: Software Development :: Libraries :: Python Modules
Topic :: Software Development :: Testing
license = Apache License, Version 2.0
Expand Down

0 comments on commit c9ae1d5

Please sign in to comment.