Skip to content

Commit 90a7fa2

Browse files
authored
Update workflow (#2)
Adding clean commit message from automerger, includes link to PR and PR name. Cleaning up workflow tests, now utilizing automerger-test to run against a repository testing valid PR states.
1 parent 7f8b273 commit 90a7fa2

File tree

6 files changed

+32
-42
lines changed

6 files changed

+32
-42
lines changed

.github/workflows/basic-validation.yaml

Lines changed: 0 additions & 36 deletions
This file was deleted.

.github/workflows/test.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
name: Test Workflow
22

3-
on: [workflow_dispatch]
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
branches:
7+
- master
48

59
jobs:
610
list:
@@ -33,3 +37,4 @@ jobs:
3337
org: 'runtimeverification'
3438
repo: ${{ matrix.value }}
3539
token: ${{ secrets.JENKINS_GITHUB_PAT }}
40+
debug: --dry-run

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Any PR with the following criteria will be updated and test will be run before m
2323
- [Example workflow using Automerge across a Github Organization](#example-workflow-using-automerge-across-a-github-organization)
2424
- [The Workflow](#the-workflow)
2525
- [Reduce CI Pressure](#reduce-ci-pressure)
26+
- [Run Locally](#run-locally)
2627

2728
# Example workflow using Automerge across a Github Organization
2829
This example workflow will run every 20 minutes and will automerge PRs for tracked repositories in the organization.
@@ -104,3 +105,19 @@ on:
104105
...
105106
...
106107
```
108+
109+
# Run Locally
110+
Checkout the repository you wish to run automerge on to a local directory.
111+
```bash
112+
git clone [email protected]:org/automerge.git
113+
cd automerge
114+
```
115+
116+
Now you need to run the command from this new directory
117+
```bash
118+
$(pwd)/../src/automerge.py --org runtimeverification --repo automerger-test --dry-run
119+
```
120+
121+
Recommended to first review the actions before running without. Then remove the `--dry-run` flag to run the action.
122+
123+

action.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ inputs:
1414
token:
1515
description: 'Access token to be able to write to the repository'
1616
required: true
17+
debug:
18+
description: 'Debug mode'
19+
required: false
20+
default: ''
1721
outputs:
1822
merged:
1923
value: ${{ steps.automerge.outputs.merged }}
@@ -49,5 +53,5 @@ runs:
4953
env:
5054
GITHUB_TOKEN: ${{ inputs.token }}
5155
working-directory: tmp-${{ inputs.repo }}
52-
run: python3 ${{ github.action_path }}/src/automerge.py --org ${{ inputs.org }} --repo ${{ inputs.repo }}
56+
run: python3 ${{ github.action_path }}/src/automerge.py --org ${{ inputs.org }} --repo ${{ inputs.repo }} ${{ inputs.debug }}
5357

src/automerge.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
parser = argparse.ArgumentParser(description='Automerge approved PRs.')
1414
parser.add_argument('--repo', type=str, help='The repository to check.')
1515
parser.add_argument('--org', type=str, help='The GitHub organization to check.')
16-
parser.add_argument('--dry-run', action='store_true', help='Enable DR run mode.')
16+
parser.add_argument('--dry-run', action='store_true', default=False, help='Enable Debug/Dry-Run mode.')
1717
args = parser.parse_args()
1818

1919
_LOGGER: Final = logging.getLogger(__name__)
@@ -98,13 +98,13 @@ def run_git_command(command_args: str) -> subprocess.CompletedProcess:
9898
# - Approved, and
9999
# - Up-to-date.
100100
# If so, merge
101-
if automerge_up_to_date_prs:
101+
while automerge_up_to_date_prs:
102102
pr = automerge_up_to_date_prs[0]
103103
_LOGGER.info(f' Merging PR:\n{pr_to_display_string(pr)}\n')
104104
if args.dry_run:
105105
_LOGGER.info(f'Would have merged PR:\n{pr_to_display_string(pr)}\n')
106106
else:
107-
pr.merge(merge_method='squash')
107+
pr.merge(merge_method='squash', commit_message=f'Automerge {pr.html_url}: {pr.title}')
108108
automerge_up_to_date_prs.pop(0)
109109

110110
# 5. Get PRs that are:

test/automerge.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[
2-
"devops-actions"
2+
"automerger-test"
33
]

0 commit comments

Comments
 (0)