mirror of
https://github.com/elastic/logstash.git
synced 2025-04-17 19:35:03 -04:00
mergify: support backports automation with labels (#16937)
This commit is contained in:
parent
3115c78bf8
commit
d40386a335
7 changed files with 234 additions and 7 deletions
|
@ -14,8 +14,10 @@
|
|||
"skip_ci_labels": [ ],
|
||||
"skip_target_branches": [ ],
|
||||
"skip_ci_on_only_changed": [
|
||||
"^docs/",
|
||||
"^.github/",
|
||||
"^docs/",
|
||||
"^.mergify.yml$",
|
||||
"^.pre-commit-config.yaml",
|
||||
"\\.md$"
|
||||
],
|
||||
"always_require_ci_on_changed": [ ]
|
||||
|
|
47
.ci/Makefile
Normal file
47
.ci/Makefile
Normal file
|
@ -0,0 +1,47 @@
|
|||
.SILENT:
|
||||
MAKEFLAGS += --no-print-directory
|
||||
.SHELLFLAGS = -euc
|
||||
SHELL = /bin/bash
|
||||
|
||||
#######################
|
||||
## Templates
|
||||
#######################
|
||||
## Mergify template
|
||||
define MERGIFY_TMPL
|
||||
|
||||
- name: backport patches to $(BRANCH) branch
|
||||
conditions:
|
||||
- merged
|
||||
- base=main
|
||||
- label=$(BACKPORT_LABEL)
|
||||
actions:
|
||||
backport:
|
||||
assignees:
|
||||
- "{{ author }}"
|
||||
branches:
|
||||
- "$(BRANCH)"
|
||||
labels:
|
||||
- "backport"
|
||||
title: "[{{ destination_branch }}] {{ title }} (backport #{{ number }})"
|
||||
endef
|
||||
|
||||
# Add mergify entry for the new backport label
|
||||
.PHONY: mergify
|
||||
export MERGIFY_TMPL
|
||||
mergify: BACKPORT_LABEL=$${BACKPORT_LABEL} BRANCH=$${BRANCH} PUSH_BRANCH=$${PUSH_BRANCH}
|
||||
mergify:
|
||||
@echo ">> mergify"
|
||||
echo "$$MERGIFY_TMPL" >> ../.mergify.yml
|
||||
git add ../.mergify.yml
|
||||
git status
|
||||
if [ ! -z "$$(git status --porcelain)" ]; then \
|
||||
git commit -m "mergify: add $(BACKPORT_LABEL) rule"; \
|
||||
git push origin $(PUSH_BRANCH) ; \
|
||||
fi
|
||||
|
||||
# Create GitHub backport label
|
||||
.PHONY: backport-label
|
||||
backport-label: BACKPORT_LABEL=$${BACKPORT_LABEL}
|
||||
backport-label:
|
||||
@echo ">> backport-label"
|
||||
gh label create $(BACKPORT_LABEL) --description "Automated backport with mergify" --color 0052cc --force
|
23
.github/workflows/mergify-labels-copier.yml
vendored
Normal file
23
.github/workflows/mergify-labels-copier.yml
vendored
Normal file
|
@ -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
.github/workflows/pre-commit.yml
vendored
Normal file
18
.github/workflows/pre-commit.yml
vendored
Normal file
|
@ -0,0 +1,18 @@
|
|||
name: pre-commit
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- 8.*
|
||||
- 9.*
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
pre-commit:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: elastic/oblt-actions/pre-commit@v1
|
29
.github/workflows/version_bumps.yml
vendored
29
.github/workflows/version_bumps.yml
vendored
|
@ -25,9 +25,13 @@ jobs:
|
|||
version_bumper:
|
||||
name: Bump versions
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
INPUTS_BRANCH: "${{ inputs.branch }}"
|
||||
INPUTS_BUMP: "${{ inputs.bump }}"
|
||||
BACKPORT_LABEL: "backport-${{ inputs.branch }}"
|
||||
steps:
|
||||
- name: Fetch logstash-core team member list
|
||||
uses: tspascoal/get-user-teams-membership@v1
|
||||
uses: tspascoal/get-user-teams-membership@57e9f42acd78f4d0f496b3be4368fc5f62696662 #v3.0.0
|
||||
with:
|
||||
username: ${{ github.actor }}
|
||||
organization: elastic
|
||||
|
@ -37,14 +41,14 @@ jobs:
|
|||
if: ${{ steps.checkUserMember.outputs.isTeamMember == 'false' }}
|
||||
run: exit 1
|
||||
- name: checkout repo content
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
ref: ${{ github.event.inputs.branch }}
|
||||
ref: ${{ env.INPUTS_BRANCH }}
|
||||
- run: git config --global user.email "43502315+logstashmachine@users.noreply.github.com"
|
||||
- run: git config --global user.name "logstashmachine"
|
||||
- run: ./gradlew clean installDefaultGems
|
||||
- run: ./vendor/jruby/bin/jruby -S bundle update --all --${{ github.event.inputs.bump }} --strict
|
||||
- run: ./vendor/jruby/bin/jruby -S bundle update --all --${{ env.INPUTS_BUMP }} --strict
|
||||
- run: mv Gemfile.lock Gemfile.jruby-*.lock.release
|
||||
- run: echo "T=$(date +%s)" >> $GITHUB_ENV
|
||||
- run: echo "BRANCH=update_lock_${T}" >> $GITHUB_ENV
|
||||
|
@ -53,8 +57,21 @@ jobs:
|
|||
git add .
|
||||
git status
|
||||
if [[ -z $(git status --porcelain) ]]; then echo "No changes. We're done."; exit 0; fi
|
||||
git commit -m "Update ${{ github.event.inputs.bump }} plugin versions in gemfile lock" -a
|
||||
git commit -m "Update ${{ env.INPUTS_BUMP }} plugin versions in gemfile lock" -a
|
||||
git push origin $BRANCH
|
||||
|
||||
- name: Update mergify (minor only)
|
||||
if: ${{ inputs.bump == 'minor' }}
|
||||
continue-on-error: true
|
||||
run: make -C .ci mergify BACKPORT_LABEL=$BACKPORT_LABEL BRANCH=$INPUTS_BRANCH PUSH_BRANCH=$BRANCH
|
||||
|
||||
- name: Create Pull Request
|
||||
run: |
|
||||
curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -X POST -d "{\"title\": \"bump lock file for ${{ github.event.inputs.branch }}\",\"head\": \"${BRANCH}\",\"base\": \"${{ github.event.inputs.branch }}\"}" https://api.github.com/repos/elastic/logstash/pulls
|
||||
curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -X POST -d "{\"title\": \"bump lock file for ${{ env.INPUTS_BRANCH }}\",\"head\": \"${BRANCH}\",\"base\": \"${{ env.INPUTS_BRANCH }}\"}" https://api.github.com/repos/elastic/logstash/pulls
|
||||
|
||||
- name: Create GitHub backport label (Mergify) (minor only)
|
||||
if: ${{ inputs.bump == 'minor' }}
|
||||
continue-on-error: true
|
||||
run: make -C .ci backport-label BACKPORT_LABEL=$BACKPORT_LABEL
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
114
.mergify.yml
Normal file
114
.mergify.yml
Normal file
|
@ -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
.pre-commit-config.yaml
Normal file
6
.pre-commit-config.yaml
Normal file
|
@ -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…
Add table
Reference in a new issue