Commit 68465a00 authored by intrigeri's avatar intrigeri

Port detection of stalled issues/MRs to GitLab

refs: #17851
parent 52f37619
#!/bin/sh
set -e
set -u
set -x
rm -f config/gitlab-triage/policies/stalled.yml
./config/gitlab-triage/bin/generate-stalled-policy \
> config/gitlab-triage/policies/stalled.yml
sudo "$(dirname "$0")"/../config/gitlab-triage/bin/gitlab-triage \
--source-id tails --source groups \
--policies-file /etc/gitlab-triage-policies/stalled.yml \
"${@}"
#! /usr/bin/python3
import gitlab
import os
from jinja2 import Environment, FileSystemLoader
from pathlib import Path
PYTHON_GITLAB_CONFIG_FILE = os.getenv('PYTHON_GITLAB_CONFIG_FILE',
default=Path.home() /
'.python-gitlab.cfg')
PYTHON_GITLAB_NAME = os.getenv('GITLAB_NAME', default='TailsGardener')
gl = gitlab.Gitlab.from_config(PYTHON_GITLAB_NAME,
config_files=[PYTHON_GITLAB_CONFIG_FILE])
gl.auth()
usernames = [user.username for user in gl.users.list(
all=True
)]
# usernames = ["anonym", "intrigeri", "CyrilBrulebois", "sajolida", "segfault"]
env = Environment(loader=FileSystemLoader('config/gitlab-triage/templates'),
block_start_string='[[%',
block_end_string='%]]',
variable_start_string='[[',
variable_end_string=']]')
print(env.get_template('stalled.yml').render(usernames=usernames))
The files in this directory are Jinja2 templates, that use non-default start/end
block/variable strings, in order not to conflict with gitlab-triage's own
templating syntax.
They are processed and rendered by
`config/gitlab-triage/bin/generate-stalled-policy`.
resource_rules:
issues:
summaries:
- name: Stalled WIP
actions:
summarize:
destination: tails/tails
title: "Triage stalled work-in-progress: #{Time.now.strftime('%Y-%m-%d')}"
summary: |
Some issues on Tails' GitLab, currently assigned to you, seem to
require updating in order to:
- better reflect your plans
- bring down your amount of work-in-progress to a sustainable level
- encourage team work and increase the chances that someone
finishes the work
Below, there's a section titled with your GitLab username, that
lists the issues assigned to you, in 'Doing' state, that were not
updated since more than 3 months.
For each such issue, you have a few options, such as:
- Unassign yourself. That's fine. If it really matters, someone
else, possibly you, may pick it up later.
Then, if the issue is relevant for a Tails team, bring it to
their attention; else, forget it and take care of yourself :)
- If you think you can realistically come back to it and finish
the work in the next months, say so on the issue, for example
by replacing the "Doing" label with "To Do" and setting
a suitable milestone.
This will communicate your plans to the rest of the project and
ensure the task pops up on your radar at a suitable time.
Of course, you can still realize later that it is not going to
work as planned, and revisit today's choice.
Cheers,
the robot that avoids a human doing ticket triaging
and asking you the above questions on each such issue
{{items}}
/assign @intrigeri
rules:
[[% for username in usernames %]]
- name: "Stalled WIP: [[username]]"
conditions:
state: opened
labels:
- Doing
date:
attribute: updated_at
condition: older_than
interval_type: months
interval: 3
ruby: |
!resource[:assignee].nil? && resource[:assignee][:username] == "[[username]]"
actions:
summarize:
item: "- [ ] [{{title}}]({{web_url}})"
summary: |
@[[username]]
=========
{{items}}
[[% endfor %]]
- name: Stalled validation
actions:
summarize:
destination: tails/tails
title: "Triage stalled validation: #{Time.now.strftime('%Y-%m-%d')}"
summary: |
Some issues on Tails' GitLab, currently assigned to you, seem to
require updating in order to:
- better reflect your plans
- bring down your amount of work-in-progress to a sustainable level
- encourage team work and increase the chances that someone
finishes the work
Below, there's a section titled with your GitLab username, that
lists the issues assigned to you, in "Needs Validation" state,
that were not updated since more than 45 days.
For each such issue, you have a few options, such as:
- If you are the author of the work that needs validation: try to
find someone who can complete the review in a timely manner.
- Else, if you are the reviewer:
- Unassign yourself to make it clear that someone else can
handle it.
- Set up whatever self-organizational tool works for you to ensure
you complete the review in a timely manner.
Cheers,
the robot that avoids a human doing ticket triaging
and asking you the above questions on each such issue
{{items}}
/assign @intrigeri
rules:
[[% for username in usernames %]]
- name: "Stalled validation: [[username]]"
conditions:
state: opened
labels:
- Needs Validation
date:
attribute: updated_at
condition: older_than
interval_type: days
interval: 45
ruby: |
!resource[:assignee].nil? && resource[:assignee][:username] == "[[username]]"
actions:
summarize:
item: "- [ ] [{{title}}]({{web_url}})"
summary: |
@[[username]]
=========
{{items}}
[[% endfor %]]
merge_requests:
summaries:
- name: Stalled MRs
actions:
summarize:
destination: tails/tails
title: "Triage stalled merge requests: #{Time.now.strftime('%Y-%m-%d')}"
summary: |
Some merge requests on Tails' GitLab, currently assigned to you,
seem to require updating in order to:
- better reflect your plans
- bring down your amount of work-in-progress to a sustainable level
- encourage team work and increase the chances that someone
finishes the work
Below, there's a section titled with your GitLab username, that
lists the MRs assigned to you, that were not updated since more
than 45 days.
For each such MR, you have a few options, such as:
- If you are the author of the work:
- Unassign yourself. That's fine. If it really matters, someone
else, possibly you, may pick it up later.
Then, if the issue is relevant for a Tails team, bring it to
their attention; else, forget it and take care of yourself :)
- Else, if you are the reviewer:
- Unassign yourself to make it clear that someone else can
handle it.
- Set up whatever self-organizational tool works for you to ensure
you complete the review in a timely manner.
Cheers,
the robot that avoids a human doing ticket triaging
and asking you the above questions on each such MR
{{items}}
/assign @intrigeri
rules:
[[% for username in usernames %]]
- name: "Stalled MRs: [[username]]"
conditions:
state: opened
date:
attribute: updated_at
condition: older_than
interval_type: days
interval: 45
ruby: |
!resource[:assignee].nil? && resource[:assignee][:username] == "[[username]]"
actions:
summarize:
item: "- [ ] [{{title}}]({{web_url}})"
summary: |
@[[username]]
=========
{{items}}
[[% endfor %]]
......@@ -76,21 +76,47 @@ that we can use as a basis to explain why we're removing the milestone.
## Existing automation
* **WIP stalled for a while**
To run the automated triaging processes described below, execute
the following commands:
Issues assigned to somebody, labeled *Doing*, and not updated in the last
180 days.
sudo ./config/gitlab-triage/bin/ensure-up-to-date-Docker-image && \
./bin/gitlab-triage-gardener \
--host-url "$(bin/gitlab-url TailsGardener)" \
--token "$(bin/gitlab-api-token TailsGardener)"
An email reminder sends everyone the list of such issues that are assigned to
them, asking them if they think they can realistically come back to it and
finish the work in the next 6 months. If yes, they should set a suitable
milestone and when relevant, the relevant "Core work: $team" label. Else, the
contributor should clear the _Assignee_ field and bring it to the attention of
the relevant team.
This will take a long time to complete: 1 hour is common.
* **Stalled merge requests**
Implementation:
Merge requests assigned to somebody not updated in the last 45 days.
- uses [GitLab Triage](https://gitlab.com/gitlab-org/gitlab-triage)
- [[!tails_gitweb bin/gitlab-triage-gardener]]
- [[!tails_gitweb_dir config/gitlab-triage]]
An email reminder sends everyone the list of such MRs that are assigned to
them, suggesting them to take a look there.
### Stalled WIP
* Scope = issues assigned to somebody, labeled *Doing*,
and not updated for a while
* Output = a summary issue, which:
- mentions each GitLab user who has such issues assigned to them;
this adds an item to the To-Do list of these users
- lists these issues, grouped by assignee
### Stalled validation
* Scope = issues assigned to somebody, labeled *Needs Validation*,
and not updated for a while
* Output = a summary issue, which:
- mentions each GitLab user who has such issues assigned to them;
this adds an item to the To-Do list of these users
- lists these issues, grouped by assignee
### Stalled merge requests
* Scope = merge requests assigned to somebody not updated for a while
* Output = a summary issue, which:
- mentions each GitLab user who has such MRs assigned to them;
this adds an item to the To-Do list of these users
- lists these MRs, grouped by assignee
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment