Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix : added merge group support + action.yml for github action #129

Merged
merged 12 commits into from
Sep 20, 2024
Merged
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: EthanPERRUZZA/dco-check@master
christophebedard marked this conversation as resolved.
Show resolved Hide resolved
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]
EthanPERRUZZA marked this conversation as resolved.
Show resolved Hide resolved
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 @@
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(

Check warning on line 940 in dco_check/dco_check.py

View check run for this annotation

Codecov / codecov/patch

dco_check/dco_check.py#L936-L940

Added lines #L936 - L940 were not covered by tests
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
Loading