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

Update workflow #2

Merged
merged 5 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 0 additions & 36 deletions .github/workflows/basic-validation.yaml

This file was deleted.

7 changes: 6 additions & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
name: Test Workflow

on: [workflow_dispatch]
on:
workflow_dispatch:
pull_request:
branches:
- master

jobs:
list:
Expand Down Expand Up @@ -33,3 +37,4 @@ jobs:
org: 'runtimeverification'
repo: ${{ matrix.value }}
token: ${{ secrets.JENKINS_GITHUB_PAT }}
debug: --dry-run
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Any PR with the following criteria will be updated and test will be run before m
- [Example workflow using Automerge across a Github Organization](#example-workflow-using-automerge-across-a-github-organization)
- [The Workflow](#the-workflow)
- [Reduce CI Pressure](#reduce-ci-pressure)
- [Run Locally](#run-locally)

# Example workflow using Automerge across a Github Organization
This example workflow will run every 20 minutes and will automerge PRs for tracked repositories in the organization.
Expand Down Expand Up @@ -104,3 +105,19 @@ on:
...
...
```

# Run Locally
Checkout the repository you wish to run automerge on to a local directory.
```bash
git clone [email protected]:org/automerge.git
cd automerge
```

Now you need to run the command from this new directory
```bash
$(pwd)/../src/automerge.py --org runtimeverification --repo automerger-test --dry-run
```

Recommended to first review the actions before running without. Then remove the `--dry-run` flag to run the action.


6 changes: 5 additions & 1 deletion action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ inputs:
token:
description: 'Access token to be able to write to the repository'
required: true
debug:
description: 'Debug mode'
required: false
default: ''
outputs:
merged:
value: ${{ steps.automerge.outputs.merged }}
Expand Down Expand Up @@ -49,5 +53,5 @@ runs:
env:
GITHUB_TOKEN: ${{ inputs.token }}
working-directory: tmp-${{ inputs.repo }}
run: python3 ${{ github.action_path }}/src/automerge.py --org ${{ inputs.org }} --repo ${{ inputs.repo }}
run: python3 ${{ github.action_path }}/src/automerge.py --org ${{ inputs.org }} --repo ${{ inputs.repo }} ${{ inputs.debug }}

6 changes: 3 additions & 3 deletions src/automerge.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
parser = argparse.ArgumentParser(description='Automerge approved PRs.')
parser.add_argument('--repo', type=str, help='The repository to check.')
parser.add_argument('--org', type=str, help='The GitHub organization to check.')
parser.add_argument('--dry-run', action='store_true', help='Enable DR run mode.')
parser.add_argument('--dry-run', action='store_true', default=False, help='Enable Debug/Dry-Run mode.')
args = parser.parse_args()

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

# 5. Get PRs that are:
Expand Down
2 changes: 1 addition & 1 deletion test/automerge.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[
"devops-actions"
"automerger-test"
]