Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion .buildkite/pull-requests.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"trigger_comment_regex": "^(?:(?:buildkite\\W+)?(?:build|test)\\W+(?:this|it))",
"always_trigger_comment_regex": "^(?:(?:buildkite\\W+)?(?:build|test)\\W+(?:this|it))",
"skip_target_branches": [],
"skip_ci_on_only_changed": ["^docs/"],
"skip_ci_on_only_changed": ["^.github/", "^docs/", "^.mergify.yml", "^.pre-commit-config.yaml"],
"always_require_ci_on_changed": [],
"skip_ci_labels": []
}
Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/mergify-labels-copier.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: mergify backport labels copier

on:
pull_request:
types:
- opened

permissions:
contents: read

jobs:
mergify-backport-labels-copier:
runs-on: ubuntu-latest
if: startsWith(github.head_ref, 'mergify/bp/')
permissions:
# Add GH labels
pull-requests: write
# See https://github.com/cli/cli/issues/6274
repository-projects: read
steps:
- uses: elastic/oblt-actions/mergify/labels-copier@v1
with:
excluded-labels-regex: "^backport-*"
18 changes: 18 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: pre-commit

on:
pull_request:
push:
branches:
- main
- 8.*
- 9.*
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we leverage the branches defined in the repo for CI purpose?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we leverage the branches defined in the repo for CI purpose?

In GitHub actions, the branches section accept static values or wildcards , if you mean being explicit, we can, or if you mean to add 7.17, I can include it. However, I cannot think of any issues for running the pre-commit workflow with any push commit in any of those wildcard branches. Or do you have any other concerns?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, if you want to avoid maintaining branches.json, we have a public bucket to help with those details too, see https://storage.googleapis.com/artifacts-api/snapshots/branches.json

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My main concern is maintenance:

  • do we need to update pre-defined valid .mergify.yml on major & minor releases?.
  • if so how other teams are modifying to avoid manual effort?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to update pre-defined valid .mergify.yml on major & minor releases?.
if so how other teams are modifying to avoid manual effort?

I understand, and thanks for pointing those concerns! This PR is still draft and gathering those questions can help us to have something workable and fully functional.

We have automated that as part of the FF scripts teams use. For instance:

  1. APM Server uses this process
  2. Beats uses an internal process to do the same.

In those cases, there are PRs with those changes created automatically. See elastic/apm-server#11760 or elastic/beats#41706

That's something we can help with, for instance, I added the support for creating the backport labels for the logstash in elastic/logstash@f2ccbce (#16937). I'll add the support to modify the mergify file in logstash and will review how those bumps work for this project to do the same

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thank you for sharing valuable info.
For this case, we need to also include a manual (in the Logstash release) and mention both logstash and elastic_integration repos.


permissions:
contents: read

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: elastic/oblt-actions/pre-commit@v1
114 changes: 114 additions & 0 deletions .mergify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
pull_request_rules:
- name: ask to resolve conflict
conditions:
- conflict
actions:
comment:
message: |
This pull request is now in conflicts. Could you fix it @{{author}}? 🙏
To fixup this pull request, you can check out it locally. See documentation: https://help.github.com/articles/checking-out-pull-requests-locally/
```
git fetch upstream
git checkout -b {{head}} upstream/{{head}}
git merge upstream/{{base}}
git push upstream {{head}}
```

- name: notify the backport policy
conditions:
- -label~=^backport
- base=main
actions:
comment:
message: |
This pull request does not have a backport label. Could you fix it @{{author}}? 🙏
To fixup this pull request, you need to add the backport labels for the needed
branches, such as:
* `backport-8./d` is the label to automatically backport to the `8./d` branch. `/d` is the digit.
* `backport-8.x` is the label to automatically backport to the `8.x` branch.

- name: add backport-8.x for the all the PRs targeting main if no skipped or assigned already
conditions:
- -label~=^(backport-skip|backport-8.x)$
- base=main
actions:
comment:
message: |
`backport-8.x` has been added to help with the transition to the new branch `8.x`.
If you don't need it please use `backport-skip` label.
label:
add:
- backport-8.x

- name: remove backport-skip label
conditions:
- label~=^backport-\d
actions:
label:
remove:
- backport-skip

- name: remove backport-8.x label if backport-skip is present
conditions:
- label~=^backport-skip
actions:
label:
remove:
- backport-8.x

- name: notify the backport has not been merged yet
conditions:
- -merged
- -closed
- author=mergify[bot]
- "#check-success>0"
- schedule=Mon-Mon 06:00-10:00[Europe/Paris]
actions:
comment:
message: |
This pull request has not been merged yet. Could you please review and merge it @{{ assignee | join(', @') }}? 🙏

- name: backport patches to 8.x branch
conditions:
- merged
- base=main
- label=backport-8.x
actions:
backport:
assignees:
- "{{ author }}"
branches:
- "8.x"
labels:
- "backport"
title: "[{{ destination_branch }}] {{ title }} (backport #{{ number }})"

- name: backport patches to 8.16 branch
conditions:
- merged
- base=main
- label=backport-8.16
actions:
backport:
assignees:
- "{{ author }}"
branches:
- "8.16"
labels:
- "backport"
title: "[{{ destination_branch }}] {{ title }} (backport #{{ number }})"

- name: backport patches to 8.17 branch
conditions:
- merged
- base=main
- label=backport-8.17
actions:
backport:
assignees:
- "{{ author }}"
branches:
- "8.17"
labels:
- "backport"
title: "[{{ destination_branch }}] {{ title }} (backport #{{ number }})"
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: check-merge-conflict
args: ['--assume-in-merge']
Loading