diff --git a/.github/labeler.yml b/.github/labeler.yml new file mode 100644 index 0000000000..e703eeb11c --- /dev/null +++ b/.github/labeler.yml @@ -0,0 +1,14 @@ +version: 1 +labels: + - label: "automerge" + authors: ["softwaremill-ci"] + files: + - "build.sbt" + - "project/Versions.scala" + - "project/plugins.sbt" + - label: "dependency" + authors: ["softwaremill-ci"] + files: + - "build.sbt" + - "project/Versions.scala" + - "project/plugins.sbt" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0b11769bfd..b3f4d51cd5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,7 +1,6 @@ name: CI on: pull_request: - branches: ['**'] push: branches: ['**'] tags: [v*] @@ -10,8 +9,12 @@ env: SBT_JAVA_OPTS: -J-Xms4g -J-Xmx4g jobs: ci: - # run on external PRs, but not on internal PRs since those will be run by push to branch - if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository + # run on 1) push, 2) external PRs, 3) softwaremill-ci PRs + # do not run on internal, non-steward PRs since those will be run by push to branch + if: | + github.event_name == 'push' || + github.event.pull_request.head.repo.full_name != github.repository || + github.event.pull_request.user.login == 'softwaremill-ci' runs-on: ubuntu-22.04 strategy: fail-fast: false @@ -109,9 +112,14 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # identify binary incompatibilities (check build.sbt for details) mima: - # run on external PRs, but not on internal PRs since those will be run by push to branch - if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository + # run on 1) push, 2) external PRs, 3) softwaremill-ci PRs + # do not run on internal, non-steward PRs since those will be run by push to branch + if: | + github.event_name == 'push' || + github.event.pull_request.head.repo.full_name != github.repository || + github.event.pull_request.user.login == 'softwaremill-ci' runs-on: ubuntu-22.04 steps: - name: Checkout @@ -182,3 +190,41 @@ jobs: version: "v${{ env.VERSION }}" env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + + # `automerge` label is attached iff there is exactly one file changed by steward and this file belongs to a + # whitelist specified by `labeler.yml` + label: + name: Attach automerge label + # only for PRs by softwaremill-ci + if: github.event.pull_request.user.login == 'softwaremill-ci' + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 2 + # count number of files changed + - name: Count number of files changed + id: count-changed-files + run: | + N=$(git diff --name-only -r HEAD^1 HEAD | wc -w) + echo "changed_files_num=$N" >> $GITHUB_OUTPUT + - name: Launch labeler + # skip if more than one file changed + if: steps.count-changed-files.outputs.changed_files_num == 1 + uses: srvaroa/labeler@master + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + + auto-merge: + name: Auto merge + # only for PRs by softwaremill-ci + if: github.event.pull_request.user.login == 'softwaremill-ci' + needs: [ ci, mima, label ] + runs-on: ubuntu-22.04 + steps: + - id: automerge + name: automerge + uses: "pascalgn/automerge-action@v0.15.6" + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" diff --git a/.github/workflows/rebase-cmd-dispatch.yml b/.github/workflows/rebase-cmd-dispatch.yml new file mode 100644 index 0000000000..55ddb6eee0 --- /dev/null +++ b/.github/workflows/rebase-cmd-dispatch.yml @@ -0,0 +1,19 @@ +# On any comment, it will look for '/rebase' in the comment body and in case of hit, it dispatches rebase cmd +# with event type 'rebase-command' which triggers 'rebase-command` WF that performs the rebase operation. +name: Slash Command Dispatch +on: + issue_comment: + types: [created] +jobs: + slashCommandDispatch: + # to fast-skip for typical, non-rebase comments + if: contains(github.event.comment.body, '/rebase') + runs-on: ubuntu-latest + steps: + - name: Slash Command Dispatch + uses: peter-evans/slash-command-dispatch@v3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + commands: rebase + permission: write + issue-type: pull-request diff --git a/.github/workflows/rebase-cmd.yml b/.github/workflows/rebase-cmd.yml new file mode 100644 index 0000000000..0503b52b7b --- /dev/null +++ b/.github/workflows/rebase-cmd.yml @@ -0,0 +1,20 @@ +name: rebase-command +on: + repository_dispatch: + types: [rebase-command] +jobs: + rebase: + runs-on: ubuntu-latest + steps: + - uses: peter-evans/rebase@v2 + id: rebase + with: + head: ${{ github.event.client_payload.pull_request.head.label }} + - name: Add reaction + if: steps.rebase.outputs.rebased-count == 1 + uses: peter-evans/create-or-update-comment@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + repository: ${{ github.event.client_payload.github.payload.repository.full_name }} + comment-id: ${{ github.event.client_payload.github.payload.comment.id }} + reaction-type: hooray diff --git a/.mergify.yml b/.mergify.yml deleted file mode 100644 index ed957d40f1..0000000000 --- a/.mergify.yml +++ /dev/null @@ -1,107 +0,0 @@ -pull_request_rules: - - name: delete head branch after merge - conditions: [] - actions: - delete_head_branch: {} - - name: automatic merge for softwaremill-ci pull requests affecting build.sbt - conditions: - - author=softwaremill-ci - - check-success=ci (2.12, JVM) - - check-success=ci (2.13, JVM) - - check-success=ci (3, JVM) - - check-success=ci (2.12, JS) - - check-success=ci (2.13, JS) - - check-success=ci (3, JS) - - check-success=ci (3, Native) - - check-success=mima - - "#files=1" - - files=build.sbt - actions: - merge: - method: merge - - name: automatic merge for softwaremill-ci pull requests affecting project plugins.sbt - conditions: - - author=softwaremill-ci - - check-success=ci (2.12, JVM) - - check-success=ci (2.13, JVM) - - check-success=ci (3, JVM) - - check-success=ci (2.12, JS) - - check-success=ci (2.13, JS) - - check-success=ci (3, JS) - - check-success=ci (3, Native) - - check-success=mima - - "#files=1" - - files=project/plugins.sbt - actions: - merge: - method: merge - - name: semi-automatic merge for softwaremill-ci pull requests - conditions: - - author=softwaremill-ci - - check-success=ci (2.12, JVM) - - check-success=ci (2.13, JVM) - - check-success=ci (3, JVM) - - check-success=ci (2.12, JS) - - check-success=ci (2.13, JS) - - check-success=ci (3, JS) - - check-success=ci (3, Native) - - check-success=mima - - "#approved-reviews-by>=1" - actions: - merge: - method: merge - - name: automatic merge for softwaremill-ci pull requests affecting project build.properties - conditions: - - author=softwaremill-ci - - check-success=ci (2.12, JVM) - - check-success=ci (2.13, JVM) - - check-success=ci (3, JVM) - - check-success=ci (2.12, JS) - - check-success=ci (2.13, JS) - - check-success=ci (3, JS) - - check-success=ci (3, Native) - - check-success=mima - - "#files=1" - - files=project/build.properties - actions: - merge: - method: merge - - name: automatic merge for softwaremill-ci pull requests affecting .scalafmt.conf - conditions: - - author=softwaremill-ci - - check-success=ci (2.12, JVM) - - check-success=ci (2.13, JVM) - - check-success=ci (3, JVM) - - check-success=ci (2.12, JS) - - check-success=ci (2.13, JS) - - check-success=ci (3, JS) - - check-success=ci (3, Native) - - check-success=mima - - "#files=1" - - files=.scalafmt.conf - actions: - merge: - method: merge - - name: automatic merge for softwaremill-ci pull requests affecting project Versions.scala - conditions: - - author=softwaremill-ci - - check-success=ci (2.12, JVM) - - check-success=ci (2.13, JVM) - - check-success=ci (3, JVM) - - check-success=ci (2.12, JS) - - check-success=ci (2.13, JS) - - check-success=ci (3, JS) - - check-success=ci (3, Native) - - check-success=mima - - "#files=1" - - files=project/Versions.scala - actions: - merge: - method: merge - - name: add label to softwaremill-ci PRs - conditions: - - author=softwaremill-ci - actions: - label: - add: - - dependency