diff --git a/.github/workflows/basic-validation.yaml b/.github/workflows/basic-validation.yaml deleted file mode 100644 index 32261f7..0000000 --- a/.github/workflows/basic-validation.yaml +++ /dev/null @@ -1,36 +0,0 @@ -name: Basic validation - -on: - push: - branches: - - master - paths-ignore: - - '**.md' - pull_request: - paths-ignore: - - '**.md' - -jobs: - call-basic-validation: - # Setup basic python lint check - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4.0.0 - - name: Set up Python 3.10 - uses: actions/setup-python@v5.0.0 - with: - python-version: 3.10 - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install flake8 pytest - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - - name: Lint with flake8 - run: | - # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - # - name: Test with pytest - # run: | - # pytest diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index c6e9137..663a620 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -1,6 +1,10 @@ name: Test Workflow -on: [workflow_dispatch] +on: + workflow_dispatch: + pull_request: + branches: + - master jobs: list: @@ -33,3 +37,4 @@ jobs: org: 'runtimeverification' repo: ${{ matrix.value }} token: ${{ secrets.JENKINS_GITHUB_PAT }} + debug: --dry-run diff --git a/README.md b/README.md index f529ed8..ed12999 100644 --- a/README.md +++ b/README.md @@ -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. @@ -104,3 +105,19 @@ on: ... ... ``` + +# Run Locally +Checkout the repository you wish to run automerge on to a local directory. +```bash +git clone git@github.com: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. + + diff --git a/action.yaml b/action.yaml index 40533e6..432b99e 100644 --- a/action.yaml +++ b/action.yaml @@ -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 }} @@ -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 }} diff --git a/src/automerge.py b/src/automerge.py index 0ad687e..91d2c2a 100755 --- a/src/automerge.py +++ b/src/automerge.py @@ -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__) @@ -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: diff --git a/test/automerge.json b/test/automerge.json index ad2b806..ed6b8b0 100644 --- a/test/automerge.json +++ b/test/automerge.json @@ -1,3 +1,3 @@ [ - "devops-actions" + "automerger-test" ] \ No newline at end of file