You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by kn...@apache.org on 2021/04/16 09:46:12 UTC
[flink-jira-bot] branch master updated (93679d9 -> 8bf7d6a)
This is an automated email from the ASF dual-hosted git repository.
knaufk pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/flink-jira-bot.git.
from 93679d9 Merge pull request #4 from knaufk/hotfix-jira
new e575ac6 [hotfix] fix tyop in Github Actions workflow
new a38d571 [FLINK-22033] add rule 2, which unassign stale assigned tickets after some time
new 77943a1 [FLINK-22033] add docstring for rule classes
new 8bf7d6a Merge pull request #5 from knaufk/FLINK-22033
The 21 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.github/workflows/actions.yaml | 2 +-
README.md | 8 ++-
config.yaml | 8 +++
flink_jira_bot.py | 128 ++++++++++++++++++++++++++++++++++++++---
4 files changed, 134 insertions(+), 12 deletions(-)
[flink-jira-bot] 02/21: [FLINK-22032] add Makefile and
requirements.txt
Posted by kn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
knaufk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink-jira-bot.git
commit f5aa96e9fddf0607471fc587147db6e7037a198c
Author: Konstantin Knauf <kn...@gmail.com>
AuthorDate: Fri Apr 9 11:30:03 2021 +0200
[FLINK-22032] add Makefile and requirements.txt
---
.gitignore | 1 +
Makefile | 26 ++++++++++++++++++++++++++
requirements.txt | 19 +++++++++++++++++++
3 files changed, 46 insertions(+)
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..5ceb386
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+venv
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..a9c933b
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,26 @@
+# define the name of the virtual environment directory
+VENV := venv
+
+# default target, when make executed without arguments
+all: venv
+
+$(VENV)/bin/activate: requirements.txt
+ python3 -m venv $(VENV)
+ ./$(VENV)/bin/pip install -r requirements.txt
+
+# venv is a shortcut target
+venv: $(VENV)/bin/activate
+
+run: venv
+ ./$(VENV)/bin/python3 flink_jira_bot/flink_jira_bot.py
+
+format: venv
+ ./$(VENV)/bin/python3 -m black .
+
+clean:
+ rm -rf $(VENV)
+ find . -type f -name '*.pyc' -delete
+
+
+
+.PHONY: all venv run clean
\ No newline at end of file
diff --git a/requirements.txt b/requirements.txt
new file mode 100644
index 0000000..d058698
--- /dev/null
+++ b/requirements.txt
@@ -0,0 +1,19 @@
+appdirs==1.4.4
+atlassian-python-api==3.8.0
+black @ git+git://github.com/psf/black@e114ef5514e95cb9908b38c2397978f2070c1b0e
+certifi==2020.12.5
+chardet==4.0.0
+click==7.1.2
+Deprecated==1.2.12
+idna==2.10
+mypy-extensions==0.4.3
+oauthlib==3.1.0
+pathspec==0.8.1
+pycparser==2.20
+regex==2021.4.4
+requests==2.25.1
+requests-oauthlib==1.3.0
+six==1.15.0
+toml==0.10.2
+urllib3==1.26.4
+wrapt==1.12.1
[flink-jira-bot] 03/21: [FINK-22032] add freeze target to Makefile
Posted by kn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
knaufk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink-jira-bot.git
commit bf4c4c1144ce3f9f7fca5cccb8ce05b8541efe28
Author: Konstantin Knauf <kn...@gmail.com>
AuthorDate: Fri Apr 9 11:34:34 2021 +0200
[FINK-22032] add freeze target to Makefile
---
Makefile | 3 +++
1 file changed, 3 insertions(+)
diff --git a/Makefile b/Makefile
index a9c933b..40ca9f7 100644
--- a/Makefile
+++ b/Makefile
@@ -17,6 +17,9 @@ run: venv
format: venv
./$(VENV)/bin/python3 -m black .
+freeze: venv
+ ./$(VENV)/bin/pip freeze > requirements.txt
+
clean:
rm -rf $(VENV)
find . -type f -name '*.pyc' -delete
[flink-jira-bot] 09/21: Merge pull request #1 from
knaufk/FLINK-22032
Posted by kn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
knaufk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink-jira-bot.git
commit ad9bbe7575797603b95e63ccfecfa13f4d68dac0
Merge: 647197b 3cfda47
Author: Konstantin Knauf <me...@konstantin-knauf.de>
AuthorDate: Mon Apr 12 18:02:41 2021 +0200
Merge pull request #1 from knaufk/FLINK-22032
[Flink-22032] Adding Bot with Initial Rule
.gitignore | 19 ++++++
Makefile | 54 +++++++++++++++
README.md | 55 ++++++++++++++++
config.yaml | 26 ++++++++
flink_jira_bot.py | 192 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
requirements.txt | 41 ++++++++++++
6 files changed, 387 insertions(+)
[flink-jira-bot] 04/21: [FLINK-22032] add confuse for YAML
configuration parsing
Posted by kn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
knaufk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink-jira-bot.git
commit c343d837f21aec32cf9696be3db1308c8de70c88
Author: Konstantin Knauf <kn...@gmail.com>
AuthorDate: Fri Apr 9 11:34:48 2021 +0200
[FLINK-22032] add confuse for YAML configuration parsing
---
requirements.txt | 2 ++
1 file changed, 2 insertions(+)
diff --git a/requirements.txt b/requirements.txt
index d058698..c5e1dd1 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -4,12 +4,14 @@ black @ git+git://github.com/psf/black@e114ef5514e95cb9908b38c2397978f2070c1b0e
certifi==2020.12.5
chardet==4.0.0
click==7.1.2
+confuse==1.4.0
Deprecated==1.2.12
idna==2.10
mypy-extensions==0.4.3
oauthlib==3.1.0
pathspec==0.8.1
pycparser==2.20
+PyYAML==5.4.1
regex==2021.4.4
requests==2.25.1
requests-oauthlib==1.3.0
[flink-jira-bot] 17/21: Merge pull request #4 from
knaufk/hotfix-jira
Posted by kn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
knaufk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink-jira-bot.git
commit 93679d9fdd56cc6c0fd2850f08637bf5d8299a5e
Merge: 4cc0b90 310b9cc
Author: Konstantin Knauf <me...@konstantin-knauf.de>
AuthorDate: Wed Apr 14 19:42:56 2021 +0200
Merge pull request #4 from knaufk/hotfix-jira
[hotfix] fix runtime errors in flink_jira_bot.py
flink_jira_bot.py | 34 ++++++++++++++++++----------------
1 file changed, 18 insertions(+), 16 deletions(-)
[flink-jira-bot] 14/21: [hotfix] fix name of github action
Posted by kn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
knaufk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink-jira-bot.git
commit 4bd79cfa90fc4c323c7c09dd58d3e05001af6ba9
Author: Konstantin Knauf <kn...@gmail.com>
AuthorDate: Wed Apr 14 12:12:42 2021 +0200
[hotfix] fix name of github action
---
.github/workflows/actions.yaml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/actions.yaml b/.github/workflows/actions.yaml
index 4af2e33..d9ef9fe 100644
--- a/.github/workflows/actions.yaml
+++ b/.github/workflows/actions.yaml
@@ -1,4 +1,4 @@
-name: Run Flink Jira Bot Hourly
+name: Run Flink Jira Twice Daily
on:
schedule:
[flink-jira-bot] 06/21: [FLINK-22032] introduce dry-run mode and
add actual actions to rule 3
Posted by kn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
knaufk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink-jira-bot.git
commit 0561a81f9b9d7db4a277db1465090b97a0c21936
Author: Konstantin Knauf <kn...@gmail.com>
AuthorDate: Fri Apr 9 14:15:15 2021 +0200
[FLINK-22032] introduce dry-run mode and add actual actions to rule 3
---
Makefile | 6 ++++
config.yaml | 6 ++--
flink_jira_bot.py | 102 +++++++++++++++++++++++++++++++++++++++++++++++++-----
requirements.txt | 4 ++-
4 files changed, 106 insertions(+), 12 deletions(-)
diff --git a/Makefile b/Makefile
index 677c9cc..adfff3d 100644
--- a/Makefile
+++ b/Makefile
@@ -11,6 +11,12 @@ $(VENV)/bin/activate: requirements.txt
# venv is a shortcut target
venv: $(VENV)/bin/activate
+help: venv
+ ./$(VENV)/bin/python3 flink_jira_bot.py --help
+
+dry-run: venv
+ ./$(VENV)/bin/python3 flink_jira_bot.py -d
+
run: venv
./$(VENV)/bin/python3 flink_jira_bot.py
diff --git a/config.yaml b/config.yaml
index d77f815..727da38 100644
--- a/config.yaml
+++ b/config.yaml
@@ -1,6 +1,8 @@
stale_minor:
stale_days: 180
warning_days: 7
- label: "stale-minor"
- comment: 'This issue (and any of its Sub-Tasks) has not been updated for {stale_days} days. So, it has been labeled "{label}". If you are still affected by this bug or are still interested in this issue, please give an update and remove the label. In {warning_days} days the issue will be closed automatically.'
+ warning_label: "stale-minor"
+ warning_comment: 'This issue and all of its Sub-Tasks have not been updated for {stale_days} days. So, it has been labeled "{warning_label}". If you are still affected by this bug or are still interested in this issue, please give an update and remove the label. In {warning_days} days the issue will be closed automatically.'
+ done_label: "auto-closed"
+ done_comment: 'This issue has been labeled "{warning_label}" for {warning_days} days. It is closed now. If you are still affected by this or would like to raise the priority of this ticket please re-open, removing the label "{done_label}" and raise the ticket priority accordingly.'
diff --git a/flink_jira_bot.py b/flink_jira_bot.py
index a092399..05541ca 100644
--- a/flink_jira_bot.py
+++ b/flink_jira_bot.py
@@ -3,14 +3,18 @@ import logging
import confuse
import os
import abc
+import sys
+from argparse import ArgumentParser
+from pathlib import Path
class FlinkJiraRule:
__metaclass__ = abc.ABCMeta
- def __init__(self, jira_client, config):
+ def __init__(self, jira_client, config, is_dry_run):
self.jira_client = jira_client
self.config = config
+ self.is_dry_run = is_dry_run
def has_recently_updated_subtask(self, parent, updated_within_days):
find_subtasks_updated_within = (
@@ -19,18 +23,54 @@ class FlinkJiraRule:
issues = self.jira_client.jql(find_subtasks_updated_within, limit=1)
return issues["total"] > 0
+ def add_label(self, issue, label):
+ labels = issue["fields"]["labels"] + [label]
+ fields = {"labels": labels}
+ key = issue["key"]
+
+ if not self.is_dry_run:
+ self.jira.update_issue_field(key, fields)
+ else:
+ logging.info(f'DRY RUN ({key}): Adding label "{label}".')
+
+ def replace_label(self, issue, old_label, new_label):
+ labels = issue["fields"]["labels"] + [new_label]
+ labels.remove(old_label)
+ fields = {"labels": labels}
+ key = issue["key"]
+
+ if not self.is_dry_run:
+ self.jira.update_issue_field(key, fields)
+ else:
+ logging.info(
+ f'DRY RUN ({key}): Replace label "{old_label}" for "{new_label}".'
+ )
+
+ def add_comment(self, key, comment):
+ if not self.is_dry_run:
+ jira.issue_add_comment(key, comment)
+ else:
+ logging.info(f'DRY_RUN ({key}): Adding comment "{comment}".')
+
+ def close_issue(self, key):
+ if not self.is_dry_run:
+ jira.issue_transition(key, "Closed")
+ else:
+ logging.info(f"DRY_RUN (({key})): Closing.")
+
@abc.abstractmethod
def run(self):
return
class Rule3(FlinkJiraRule):
- def __init__(self, jira_client, config):
- super().__init__(jira_client, config)
+ def __init__(self, jira_client, config, is_dry_run):
+ super().__init__(jira_client, config, is_dry_run)
self.stale_days = config["stale_minor"]["stale_days"].get()
self.warning_days = config["stale_minor"]["warning_days"].get()
- self.label = config["stale_minor"]["label"].get()
- self.comment = config["stale_minor"]["comment"].get()
+ self.warning_label = config["stale_minor"]["warning_label"].get()
+ self.done_label = config["stale_minor"]["done_label"].get()
+ self.warning_comment = config["stale_minor"]["warning_comment"].get()
def run(self):
self.close_tickets_marked_stale()
@@ -38,7 +78,7 @@ class Rule3(FlinkJiraRule):
def close_tickets_marked_stale(self):
- minor_tickets_marked_stale = f'project=FLINK AND Priority = Minor AND resolution = Unresolved AND labels in ("{self.label}") AND updated < startOfDay(-{self.warning_days}d)'
+ minor_tickets_marked_stale = f'project=FLINK AND Priority = Minor AND resolution = Unresolved AND labels in ("{self.warning_label}") AND updated < startOfDay(-{self.warning_days}d)'
logging.info(
f"Looking for minor tickets, which were previously marked as stale: {minor_tickets_marked_stale}"
)
@@ -50,6 +90,16 @@ class Rule3(FlinkJiraRule):
f"Found https://issues.apache.org/jira/browse/{key}. It is now closed due to inactivity."
)
+ formatted_comment = self.done_comment.format(
+ warning_days=self.warning_days,
+ warning_label=self.warning_label,
+ done_label=self.done_label,
+ )
+
+ self.add_comment(key, formatted_comment)
+ self.replace_label(issue, self.warning_label, self.done_label)
+ self.close_issue(key)
+
def mark_stale_tickets_stale(self):
stale_minor_tickets = f"project = FLINK AND Priority = Minor AND resolution = Unresolved AND updated < startOfDay(-{self.stale_days}d)"
@@ -66,19 +116,53 @@ class Rule3(FlinkJiraRule):
logging.info(
f"Found https://issues.apache.org/jira/browse/{key}. It is marked stale now."
)
+ formatted_comment = self.warning_comment.format(
+ stale_days=self.stale_days,
+ warning_days=self.warning_days,
+ warning_label=self.warning_label,
+ )
+
+ self.add_label(issue, self.warning_label)
+ self.add_comment(key, formatted_comment)
else:
- logging.debug(
+ logging.info(
f"Found https://issues.apache.org/jira/browse/{key}, but is has recently updated Subtasks. Ignoring for now."
)
+def is_dry_run():
+ opts = [opt for opt in sys.argv[1:] if opt.startswith("-")]
+ return "-d" in opts
+
+
+def get_args():
+ parser = ArgumentParser(description="Apache Flink Jira Bot")
+ parser.add_argument(
+ "-d",
+ "--dry-run",
+ dest="dryrun",
+ action="store_true",
+ help="no action on Jira, only logging",
+ )
+ parser.add_argument(
+ "-c",
+ "--config",
+ type=Path,
+ default=Path("config.yaml"),
+ help="path to config file (default: config.yaml)",
+ )
+ return parser.parse_args()
+
+
if __name__ == "__main__":
logging.getLogger().setLevel(logging.INFO)
+ args = get_args()
+
config = confuse.Configuration("flink-jira-bot", __name__)
- config.set_file("config.yaml")
+ config.set_file(args.config)
jira = Jira(
url="https://issues.apache.org/jira",
@@ -86,5 +170,5 @@ if __name__ == "__main__":
password=os.environ["JIRA_PASSWORD"],
)
- rule_3 = Rule3(jira, config)
+ rule_3 = Rule3(jira, config, args.dryrun)
rule_3.run()
diff --git a/requirements.txt b/requirements.txt
index c5e1dd1..336352b 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,6 +1,6 @@
appdirs==1.4.4
atlassian-python-api==3.8.0
-black @ git+git://github.com/psf/black@e114ef5514e95cb9908b38c2397978f2070c1b0e
+black==20.8b1
certifi==2020.12.5
chardet==4.0.0
click==7.1.2
@@ -17,5 +17,7 @@ requests==2.25.1
requests-oauthlib==1.3.0
six==1.15.0
toml==0.10.2
+typed-ast==1.4.3
+typing-extensions==3.7.4.3
urllib3==1.26.4
wrapt==1.12.1
[flink-jira-bot] 21/21: Merge pull request #5 from
knaufk/FLINK-22033
Posted by kn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
knaufk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink-jira-bot.git
commit 8bf7d6a01ffaf4f2b4c3a47b82562f3e71614f82
Merge: 93679d9 77943a1
Author: Konstantin Knauf <me...@konstantin-knauf.de>
AuthorDate: Fri Apr 16 11:46:02 2021 +0200
Merge pull request #5 from knaufk/FLINK-22033
[FLINK-22033] Implementation of Rule 2
.github/workflows/actions.yaml | 2 +-
README.md | 8 ++-
config.yaml | 8 +++
flink_jira_bot.py | 128 ++++++++++++++++++++++++++++++++++++++---
4 files changed, 134 insertions(+), 12 deletions(-)
[flink-jira-bot] 12/21: Merge pull request #2 from
knaufk/FLINK-22035
Posted by kn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
knaufk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink-jira-bot.git
commit 9afde4761b1d029c638a6067697a3523f179a588
Merge: ad9bbe7 e5fbb13
Author: Konstantin Knauf <me...@konstantin-knauf.de>
AuthorDate: Wed Apr 14 11:25:45 2021 +0200
Merge pull request #2 from knaufk/FLINK-22035
[FLINK-22035] Add Github Actions
.github/workflows/actions.yaml | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
[flink-jira-bot] 01/21: Initial commit with the ASL
Posted by kn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
knaufk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink-jira-bot.git
commit 647197b3f5c1ab663fd81db383d39fc537553437
Author: Robert Metzger <rm...@apache.org>
AuthorDate: Wed Apr 7 20:40:13 2021 +0200
Initial commit with the ASL
---
LICENSE | 201 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 201 insertions(+)
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..261eeb9
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,201 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
[flink-jira-bot] 16/21: [hotfix] fix runtime errors & warnings in
flink_jira_bot.py
Posted by kn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
knaufk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink-jira-bot.git
commit 310b9cc2757e2ee41f0f82b1e0596f9b4cd71864
Author: Konstantin Knauf <kn...@gmail.com>
AuthorDate: Wed Apr 14 17:56:42 2021 +0200
[hotfix] fix runtime errors & warnings in flink_jira_bot.py
---
flink_jira_bot.py | 34 ++++++++++++++++++----------------
1 file changed, 18 insertions(+), 16 deletions(-)
diff --git a/flink_jira_bot.py b/flink_jira_bot.py
index 72f13fe..f67e57e 100644
--- a/flink_jira_bot.py
+++ b/flink_jira_bot.py
@@ -21,7 +21,6 @@ import logging
import confuse
import os
import abc
-import sys
from argparse import ArgumentParser
from pathlib import Path
@@ -47,7 +46,7 @@ class FlinkJiraRule:
key = issue["key"]
if not self.is_dry_run:
- self.jira.update_issue_field(key, fields)
+ self.jira_client.update_issue_field(key, fields)
else:
logging.info(f'DRY RUN ({key}): Adding label "{label}".')
@@ -58,7 +57,7 @@ class FlinkJiraRule:
key = issue["key"]
if not self.is_dry_run:
- self.jira.update_issue_field(key, fields)
+ self.jira_client.update_issue_field(key, fields)
else:
logging.info(
f'DRY RUN ({key}): Replace label "{old_label}" for "{new_label}".'
@@ -66,13 +65,13 @@ class FlinkJiraRule:
def add_comment(self, key, comment):
if not self.is_dry_run:
- jira.issue_add_comment(key, comment)
+ self.jira_client.issue_add_comment(key, comment)
else:
logging.info(f'DRY_RUN ({key}): Adding comment "{comment}".')
def close_issue(self, key):
if not self.is_dry_run:
- jira.issue_transition(key, "Closed")
+ self.jira_client.issue_transition(key, "Closed")
else:
logging.info(f"DRY_RUN (({key})): Closing.")
@@ -88,6 +87,7 @@ class Rule3(FlinkJiraRule):
self.warning_days = config["stale_minor"]["warning_days"].get()
self.warning_label = config["stale_minor"]["warning_label"].get()
self.done_label = config["stale_minor"]["done_label"].get()
+ self.done_comment = config["stale_minor"]["done_comment"].get()
self.warning_comment = config["stale_minor"]["warning_comment"].get()
def run(self):
@@ -96,7 +96,10 @@ class Rule3(FlinkJiraRule):
def close_tickets_marked_stale(self):
- minor_tickets_marked_stale = f'project=FLINK AND Priority = Minor AND resolution = Unresolved AND labels in ("{self.warning_label}") AND updated < startOfDay(-{self.warning_days}d)'
+ minor_tickets_marked_stale = (
+ f"project=FLINK AND Priority = Minor AND resolution = Unresolved AND labels in "
+ f'("{self.warning_label}") AND updated < startOfDay(-{self.warning_days}d)'
+ )
logging.info(
f"Looking for minor tickets, which were previously marked as stale: {minor_tickets_marked_stale}"
)
@@ -120,7 +123,10 @@ class Rule3(FlinkJiraRule):
def mark_stale_tickets_stale(self):
- stale_minor_tickets = f"project = FLINK AND Priority = Minor AND resolution = Unresolved AND updated < startOfDay(-{self.stale_days}d)"
+ stale_minor_tickets = (
+ f"project = FLINK AND Priority = Minor AND resolution = Unresolved AND updated < "
+ f"startOfDay(-{self.stale_days}d)"
+ )
logging.info(
f"Looking for minor tickets, which are stale: {stale_minor_tickets}"
)
@@ -145,15 +151,11 @@ class Rule3(FlinkJiraRule):
else:
logging.info(
- f"Found https://issues.apache.org/jira/browse/{key}, but is has recently updated Subtasks. Ignoring for now."
+ f"Found https://issues.apache.org/jira/browse/{key}, but is has recently updated Subtasks. "
+ f"Ignoring for now."
)
-def is_dry_run():
- opts = [opt for opt in sys.argv[1:] if opt.startswith("-")]
- return "-d" in opts
-
-
def get_args():
parser = ArgumentParser(description="Apache Flink Jira Bot")
parser.add_argument(
@@ -179,8 +181,8 @@ if __name__ == "__main__":
args = get_args()
- config = confuse.Configuration("flink-jira-bot", __name__)
- config.set_file(args.config)
+ jira_bot_config = confuse.Configuration("flink-jira-bot", __name__)
+ jira_bot_config.set_file(args.config)
jira = Jira(
url="https://issues.apache.org/jira",
@@ -188,5 +190,5 @@ if __name__ == "__main__":
password=os.environ["JIRA_PASSWORD"],
)
- rule_3 = Rule3(jira, config, args.dryrun)
+ rule_3 = Rule3(jira, jira_bot_config, args.dryrun)
rule_3.run()
[flink-jira-bot] 18/21: [hotfix] fix tyop in Github Actions workflow
Posted by kn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
knaufk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink-jira-bot.git
commit e575ac6695ea89176fb68e9526b5200be57afa2c
Author: Konstantin Knauf <kn...@gmail.com>
AuthorDate: Thu Apr 15 18:21:11 2021 +0200
[hotfix] fix tyop in Github Actions workflow
---
.github/workflows/actions.yaml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/actions.yaml b/.github/workflows/actions.yaml
index d9ef9fe..1cc051b 100644
--- a/.github/workflows/actions.yaml
+++ b/.github/workflows/actions.yaml
@@ -1,4 +1,4 @@
-name: Run Flink Jira Twice Daily
+name: Run Flink Jira Bot Twice Daily
on:
schedule:
[flink-jira-bot] 10/21: [FLINK-22035] add simply github action to
run bot hourly
Posted by kn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
knaufk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink-jira-bot.git
commit c20522941bf683d33f9d5fabfd8a1ab584f480b8
Author: Konstantin Knauf <kn...@gmail.com>
AuthorDate: Mon Apr 12 15:12:15 2021 +0200
[FLINK-22035] add simply github action to run bot hourly
---
.github/workflows/actions.yaml | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/.github/workflows/actions.yaml b/.github/workflows/actions.yaml
new file mode 100644
index 0000000..b3dd688
--- /dev/null
+++ b/.github/workflows/actions.yaml
@@ -0,0 +1,25 @@
+name: Run Flink Jira Bot Hourly
+
+on:
+ schedule:
+ - cron: 0 * * * *
+jobs:
+ run:
+ env:
+ JIRA_PASSWORD: ${{ secrets.FLINK_JIRA_BOT_PASSWORD }}
+
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v2
+ - name: Set up Python 3.9
+ uses: actions/setup-python@v2
+ with:
+ python-version: 3.9
+ - name: Install dependencies
+ run: |
+ python -m pip install --upgrade pip
+ pip install -r requirements.txt
+ - name: Run Jira Bot
+ run: |
+ python flink_jira_bot.py
\ No newline at end of file
[flink-jira-bot] 07/21: [FLINK-22032] add minimal README
Posted by kn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
knaufk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink-jira-bot.git
commit 1709d0456fc50530f3b84dd7d2c4a29193b0aaec
Author: Konstantin Knauf <kn...@gmail.com>
AuthorDate: Fri Apr 9 14:23:23 2021 +0200
[FLINK-22032] add minimal README
---
README.md | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 55 insertions(+)
diff --git a/README.md b/README.md
index e69de29..befa400 100644
--- a/README.md
+++ b/README.md
@@ -0,0 +1,55 @@
+# Apache Flink Jira Bot
+
+The Flink Jira enforces some of the rules outlined in [the Apache Flink Confluence](https://cwiki.apache.org/confluence/display/FLINK/Flink+Jira+Process).
+
+## Usage
+
+```
+./venv/bin/python3 flink_jira_bot.py --help
+usage: flink_jira_bot.py [-h] [-d] [-c CONFIG]
+
+Apache Flink Jira Bot
+
+optional arguments:
+ -h, --help show this help message and exit
+ -d, --dry-run no action on Jira, only logging
+ -c CONFIG, --config CONFIG
+ path to config file (default: config.yaml)
+```
+
+There are also `make` targets for the important actions:
+
+### Run
+```
+make run
+```
+
+### Dry-Run
+
+The dry-run does not make any changes to the Apache Flink Jira, but instead only logs the actions it would do.
+
+```
+make dry-run
+```
+
+### Configuration
+
+Both `make run` and `make dry-run` look for the password of `flink-jira-bot` in an environment variable called `JIRA_PASSWORD`.
+
+The configuration of the rules can be found in [config.yaml](config.yaml).
+
+## About the Rules
+
+### Rule 1 (not implemented yet)
+
+### Rule 2 (not implemented yet)
+
+### Rule 3
+
+An unresolved Minor ticket without an update for {stale.minor.stale_days} is closed after a warning period of {stale.minor.warning_days} with a comment that encourages users to watch, comment and simply reopen with a higher priority if the problem insists.
+
+## About Apache Flink
+
+Apache Flink is an open source project of The Apache Software Foundation (ASF).
+
+Flink is distributed data processing framework with powerful stream and batch processing capabilities. Learn more about Flink at http://flink.apache.org/
\ No newline at end of file
[flink-jira-bot] 20/21: [FLINK-22033] add docstring for rule classes
Posted by kn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
knaufk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink-jira-bot.git
commit 77943a14746fbcdb8432863b07f0c8143d33f3fc
Author: Konstantin Knauf <kn...@gmail.com>
AuthorDate: Fri Apr 16 11:31:51 2021 +0200
[FLINK-22033] add docstring for rule classes
---
flink_jira_bot.py | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/flink_jira_bot.py b/flink_jira_bot.py
index e1cdc28..00ce80f 100644
--- a/flink_jira_bot.py
+++ b/flink_jira_bot.py
@@ -107,6 +107,12 @@ class FlinkJiraRule:
class Rule3(FlinkJiraRule):
+ """
+ An unresolved Minor ticket without an update for {stale_minor.stale_days} is closed after a warning period of
+ {stale_minor.warning_days} with a comment that encourages users to watch, comment and simply reopen with a higher
+ priority if the problem insists.
+ """
+
def __init__(self, jira_client, config, is_dry_run):
super().__init__(jira_client, config, is_dry_run)
self.stale_days = config["stale_minor"]["stale_days"].get()
@@ -181,6 +187,12 @@ class Rule3(FlinkJiraRule):
class Rule2(FlinkJiraRule):
+ """
+ Assigned tickets without an update for {stale_assigned.stale_days} are unassigned after a warning period of
+ {stale_assigned.warning_days}. Before this happens the assignee is notified that this is about to happen and
+ asked for an update on the status of her contribution.
+ """
+
def __init__(self, jira_client, config, is_dry_run):
super().__init__(jira_client, config, is_dry_run)
self.stale_days = config["stale_assigned"]["stale_days"].get()
[flink-jira-bot] 19/21: [FLINK-22033] add rule 2,
which unassign stale assigned tickets after some time
Posted by kn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
knaufk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink-jira-bot.git
commit a38d571a76c617d222e3fab5488c0ffe6d44119f
Author: Konstantin Knauf <kn...@gmail.com>
AuthorDate: Fri Apr 16 10:57:55 2021 +0200
[FLINK-22033] add rule 2, which unassign stale assigned tickets after some time
---
README.md | 8 ++--
config.yaml | 8 ++++
flink_jira_bot.py | 116 ++++++++++++++++++++++++++++++++++++++++++++++++++----
3 files changed, 121 insertions(+), 11 deletions(-)
diff --git a/README.md b/README.md
index befa400..503a762 100644
--- a/README.md
+++ b/README.md
@@ -42,11 +42,13 @@ The configuration of the rules can be found in [config.yaml](config.yaml).
### Rule 1 (not implemented yet)
-### Rule 2 (not implemented yet)
+### Rule 2: Unassign Stale Assigned Tickets
-### Rule 3
+Assigned tickets without an update for {stale_assigned.stale_days} are unassigned after a warning period of {stale_assigned.warning_days}. Before this happens the assignee is notified that this is about to happen and asked for an update on the status of her contribution.
-An unresolved Minor ticket without an update for {stale.minor.stale_days} is closed after a warning period of {stale.minor.warning_days} with a comment that encourages users to watch, comment and simply reopen with a higher priority if the problem insists.
+### Rule 3: Close Stale Minor Tickets
+
+An unresolved Minor ticket without an update for {stale_minor.stale_days} is closed after a warning period of {stale_minor.warning_days} with a comment that encourages users to watch, comment and simply reopen with a higher priority if the problem insists.
## About Apache Flink
diff --git a/config.yaml b/config.yaml
index 1afae72..d1cb3bb 100644
--- a/config.yaml
+++ b/config.yaml
@@ -16,6 +16,14 @@
# limitations under the License.
################################################################################
+stale_assigned:
+ stale_days: 7
+ warning_days: 7
+ warning_label: "stale-assigned"
+ warning_comment: 'This issue is assigned but has not received an update in {stale_days} days so it has been labeled "{warning_label}". If you are still working on the issue, please give an update and remove the label. If you are no longer working on the issue, please unassign so someone else may work on it. In {warning_days} days the issue will be automatically unassigned.'
+ done_label: "auto-unassigned"
+ done_comment: 'This issue was marked "{warning_label}" and has not received an update in {warning_days} days. It is now automatically unassigned. If you are still working on it, you can assign it to yourself again. Please also give an update about the status of the work.'
+
stale_minor:
stale_days: 180
warning_days: 7
diff --git a/flink_jira_bot.py b/flink_jira_bot.py
index f67e57e..e1cdc28 100644
--- a/flink_jira_bot.py
+++ b/flink_jira_bot.py
@@ -33,12 +33,32 @@ class FlinkJiraRule:
self.config = config
self.is_dry_run = is_dry_run
+ def get_issues(self, jql_query):
+ """Queries the JIRA PI for all issues that match the given JQL Query
+
+ This method is necessary as requests tend to time out if the number of results reaches a certain number.
+ So, this method requests the results in multiple queries and returns a final list of all issues.
+ :param jql_query: the search query
+ :return: a list of issues matching the query
+ """
+ limit = 200
+ current = 0
+ total = 1
+ issues = []
+ while current < total:
+ response = self.jira_client.jql(jql_query, limit=limit, start=current)
+ total = response["total"]
+ issues = issues + response["issues"]
+ current = len(issues)
+ logging.info(f'"{jql_query}" returned {len(issues)} issues')
+ return issues
+
def has_recently_updated_subtask(self, parent, updated_within_days):
find_subtasks_updated_within = (
f"parent = {parent} AND updated > startOfDay(-{updated_within_days}d)"
)
- issues = self.jira_client.jql(find_subtasks_updated_within, limit=1)
- return issues["total"] > 0
+ issues = self.get_issues(find_subtasks_updated_within)
+ return len(issues) > 0
def add_label(self, issue, label):
labels = issue["fields"]["labels"] + [label]
@@ -75,6 +95,12 @@ class FlinkJiraRule:
else:
logging.info(f"DRY_RUN (({key})): Closing.")
+ def unassign(self, key):
+ if not self.is_dry_run:
+ self.jira_client.assign_issue(key, None)
+ else:
+ logging.info(f"DRY_RUN (({key})): Unassigning.")
+
@abc.abstractmethod
def run(self):
return
@@ -101,11 +127,11 @@ class Rule3(FlinkJiraRule):
f'("{self.warning_label}") AND updated < startOfDay(-{self.warning_days}d)'
)
logging.info(
- f"Looking for minor tickets, which were previously marked as stale: {minor_tickets_marked_stale}"
+ f"Looking for minor tickets, which were previously marked as {self.warning_label}."
)
- issues = jira.jql(minor_tickets_marked_stale, limit=10000)
+ issues = self.get_issues(minor_tickets_marked_stale)
- for issue in issues["issues"]:
+ for issue in issues:
key = issue["key"]
logging.info(
f"Found https://issues.apache.org/jira/browse/{key}. It is now closed due to inactivity."
@@ -127,12 +153,84 @@ class Rule3(FlinkJiraRule):
f"project = FLINK AND Priority = Minor AND resolution = Unresolved AND updated < "
f"startOfDay(-{self.stale_days}d)"
)
+ logging.info(f"Looking for minor tickets, which are stale.")
+ issues = self.get_issues(stale_minor_tickets)
+
+ for issue in issues:
+ key = issue["key"]
+ issue = self.jira_client.get_issue(key)
+
+ if not self.has_recently_updated_subtask(key, self.stale_days):
+ logging.info(
+ f"Found https://issues.apache.org/jira/browse/{key}. It is marked stale now."
+ )
+ formatted_comment = self.warning_comment.format(
+ stale_days=self.stale_days,
+ warning_days=self.warning_days,
+ warning_label=self.warning_label,
+ )
+
+ self.add_label(issue, self.warning_label)
+ self.add_comment(key, formatted_comment)
+
+ else:
+ logging.info(
+ f"Found https://issues.apache.org/jira/browse/{key}, but is has recently updated Subtasks. "
+ f"Ignoring for now."
+ )
+
+
+class Rule2(FlinkJiraRule):
+ def __init__(self, jira_client, config, is_dry_run):
+ super().__init__(jira_client, config, is_dry_run)
+ self.stale_days = config["stale_assigned"]["stale_days"].get()
+ self.warning_days = config["stale_assigned"]["warning_days"].get()
+ self.warning_label = config["stale_assigned"]["warning_label"].get()
+ self.done_label = config["stale_assigned"]["done_label"].get()
+ self.done_comment = config["stale_assigned"]["done_comment"].get()
+ self.warning_comment = config["stale_assigned"]["warning_comment"].get()
+
+ def run(self):
+ self.unassign_tickets_marked_stale()
+ self.mark_stale_tickets_stale()
+
+ def unassign_tickets_marked_stale(self):
+
+ assigned_tickets_marked_stale = (
+ f"project=FLINK AND resolution = Unresolved AND labels in "
+ f'("{self.warning_label}") AND updated < startOfDay(-{self.warning_days}d)'
+ )
logging.info(
- f"Looking for minor tickets, which are stale: {stale_minor_tickets}"
+ f"Looking for assigned tickets, which were previously marked as {self.warning_label}."
+ )
+ issues = self.get_issues(assigned_tickets_marked_stale)
+
+ for issue in issues:
+ key = issue["key"]
+ logging.info(
+ f"Found https://issues.apache.org/jira/browse/{key}. It is now unassigned due to inactivity."
+ )
+
+ formatted_comment = self.done_comment.format(
+ warning_days=self.warning_days,
+ warning_label=self.warning_label,
+ done_label=self.done_label,
+ )
+
+ self.add_comment(key, formatted_comment)
+ self.replace_label(issue, self.warning_label, self.done_label)
+ self.unassign(key)
+
+ def mark_stale_tickets_stale(self):
+
+ stale_assigned_tickets = (
+ f"project = FLINK AND resolution = Unresolved AND assignee is not EMPTY AND updated < "
+ f"startOfDay(-{self.stale_days}d)"
)
- issues = self.jira_client.jql(stale_minor_tickets, limit=10000)
+ logging.info(f"Looking for assigned tickets, which are stale.")
+ issues = self.get_issues(stale_assigned_tickets)
- for issue in issues["issues"]:
+ for issue in issues:
key = issue["key"]
issue = self.jira_client.get_issue(key)
@@ -190,5 +288,7 @@ if __name__ == "__main__":
password=os.environ["JIRA_PASSWORD"],
)
+ rule_2 = Rule2(jira, jira_bot_config, args.dryrun)
rule_3 = Rule3(jira, jira_bot_config, args.dryrun)
+ rule_2.run()
rule_3.run()
[flink-jira-bot] 05/21: [FLINK-22032] add Rule 3 (logging only)
Posted by kn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
knaufk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink-jira-bot.git
commit 6f4e13c295cd09789d509db49496956751e7d9cd
Author: Konstantin Knauf <kn...@gmail.com>
AuthorDate: Fri Apr 9 13:42:42 2021 +0200
[FLINK-22032] add Rule 3 (logging only)
---
Makefile | 2 +-
README.md | 0
config.yaml | 6 ++++
flink_jira_bot.py | 90 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 97 insertions(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index 40ca9f7..677c9cc 100644
--- a/Makefile
+++ b/Makefile
@@ -12,7 +12,7 @@ $(VENV)/bin/activate: requirements.txt
venv: $(VENV)/bin/activate
run: venv
- ./$(VENV)/bin/python3 flink_jira_bot/flink_jira_bot.py
+ ./$(VENV)/bin/python3 flink_jira_bot.py
format: venv
./$(VENV)/bin/python3 -m black .
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..e69de29
diff --git a/config.yaml b/config.yaml
new file mode 100644
index 0000000..d77f815
--- /dev/null
+++ b/config.yaml
@@ -0,0 +1,6 @@
+stale_minor:
+ stale_days: 180
+ warning_days: 7
+ label: "stale-minor"
+ comment: 'This issue (and any of its Sub-Tasks) has not been updated for {stale_days} days. So, it has been labeled "{label}". If you are still affected by this bug or are still interested in this issue, please give an update and remove the label. In {warning_days} days the issue will be closed automatically.'
+
diff --git a/flink_jira_bot.py b/flink_jira_bot.py
new file mode 100644
index 0000000..a092399
--- /dev/null
+++ b/flink_jira_bot.py
@@ -0,0 +1,90 @@
+from atlassian import Jira
+import logging
+import confuse
+import os
+import abc
+
+
+class FlinkJiraRule:
+ __metaclass__ = abc.ABCMeta
+
+ def __init__(self, jira_client, config):
+ self.jira_client = jira_client
+ self.config = config
+
+ def has_recently_updated_subtask(self, parent, updated_within_days):
+ find_subtasks_updated_within = (
+ f"parent = {parent} AND updated > startOfDay(-{updated_within_days}d)"
+ )
+ issues = self.jira_client.jql(find_subtasks_updated_within, limit=1)
+ return issues["total"] > 0
+
+ @abc.abstractmethod
+ def run(self):
+ return
+
+
+class Rule3(FlinkJiraRule):
+ def __init__(self, jira_client, config):
+ super().__init__(jira_client, config)
+ self.stale_days = config["stale_minor"]["stale_days"].get()
+ self.warning_days = config["stale_minor"]["warning_days"].get()
+ self.label = config["stale_minor"]["label"].get()
+ self.comment = config["stale_minor"]["comment"].get()
+
+ def run(self):
+ self.close_tickets_marked_stale()
+ self.mark_stale_tickets_stale()
+
+ def close_tickets_marked_stale(self):
+
+ minor_tickets_marked_stale = f'project=FLINK AND Priority = Minor AND resolution = Unresolved AND labels in ("{self.label}") AND updated < startOfDay(-{self.warning_days}d)'
+ logging.info(
+ f"Looking for minor tickets, which were previously marked as stale: {minor_tickets_marked_stale}"
+ )
+ issues = jira.jql(minor_tickets_marked_stale, limit=10000)
+
+ for issue in issues["issues"]:
+ key = issue["key"]
+ logging.info(
+ f"Found https://issues.apache.org/jira/browse/{key}. It is now closed due to inactivity."
+ )
+
+ def mark_stale_tickets_stale(self):
+
+ stale_minor_tickets = f"project = FLINK AND Priority = Minor AND resolution = Unresolved AND updated < startOfDay(-{self.stale_days}d)"
+ logging.info(
+ f"Looking for minor tickets, which are stale: {stale_minor_tickets}"
+ )
+ issues = self.jira_client.jql(stale_minor_tickets, limit=10000)
+
+ for issue in issues["issues"]:
+ key = issue["key"]
+ issue = self.jira_client.get_issue(key)
+
+ if not self.has_recently_updated_subtask(key, self.stale_days):
+ logging.info(
+ f"Found https://issues.apache.org/jira/browse/{key}. It is marked stale now."
+ )
+
+ else:
+ logging.debug(
+ f"Found https://issues.apache.org/jira/browse/{key}, but is has recently updated Subtasks. Ignoring for now."
+ )
+
+
+if __name__ == "__main__":
+
+ logging.getLogger().setLevel(logging.INFO)
+
+ config = confuse.Configuration("flink-jira-bot", __name__)
+ config.set_file("config.yaml")
+
+ jira = Jira(
+ url="https://issues.apache.org/jira",
+ username="flink-jira-bot",
+ password=os.environ["JIRA_PASSWORD"],
+ )
+
+ rule_3 = Rule3(jira, config)
+ rule_3.run()
[flink-jira-bot] 11/21: [FLINK-22035] change cron schedule to twice
daily, not at the full hour
Posted by kn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
knaufk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink-jira-bot.git
commit e5fbb1388e35f5731b642fe742887e5b36538a4b
Author: Konstantin Knauf <kn...@gmail.com>
AuthorDate: Wed Apr 14 11:19:52 2021 +0200
[FLINK-22035] change cron schedule to twice daily, not at the full hour
---
.github/workflows/actions.yaml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/.github/workflows/actions.yaml b/.github/workflows/actions.yaml
index b3dd688..0fc9681 100644
--- a/.github/workflows/actions.yaml
+++ b/.github/workflows/actions.yaml
@@ -2,7 +2,7 @@ name: Run Flink Jira Bot Hourly
on:
schedule:
- - cron: 0 * * * *
+ - cron: 33 9,21 * * *
jobs:
run:
env:
@@ -22,4 +22,4 @@ jobs:
pip install -r requirements.txt
- name: Run Jira Bot
run: |
- python flink_jira_bot.py
\ No newline at end of file
+ python flink_jira_bot.py -d
\ No newline at end of file
[flink-jira-bot] 08/21: [FLINK-22023] add license headers
Posted by kn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
knaufk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink-jira-bot.git
commit 3cfda47472ddf6c4efe449b333637a0e578c7593
Author: Konstantin Knauf <kn...@gmail.com>
AuthorDate: Fri Apr 9 14:34:48 2021 +0200
[FLINK-22023] add license headers
---
.gitignore | 18 ++++++++++++++++++
Makefile | 19 +++++++++++++++++++
config.yaml | 18 ++++++++++++++++++
flink_jira_bot.py | 18 ++++++++++++++++++
requirements.txt | 18 ++++++++++++++++++
5 files changed, 91 insertions(+)
diff --git a/.gitignore b/.gitignore
index 5ceb386..4b8ee1e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,19 @@
+################################################################################
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+################################################################################
+
venv
diff --git a/Makefile b/Makefile
index adfff3d..7e2cc73 100644
--- a/Makefile
+++ b/Makefile
@@ -1,3 +1,22 @@
+################################################################################
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+################################################################################
+
+
# define the name of the virtual environment directory
VENV := venv
diff --git a/config.yaml b/config.yaml
index 727da38..1afae72 100644
--- a/config.yaml
+++ b/config.yaml
@@ -1,3 +1,21 @@
+################################################################################
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+################################################################################
+
stale_minor:
stale_days: 180
warning_days: 7
diff --git a/flink_jira_bot.py b/flink_jira_bot.py
index 05541ca..72f13fe 100644
--- a/flink_jira_bot.py
+++ b/flink_jira_bot.py
@@ -1,3 +1,21 @@
+################################################################################
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+################################################################################
+
from atlassian import Jira
import logging
import confuse
diff --git a/requirements.txt b/requirements.txt
index 336352b..4f3ae54 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,3 +1,21 @@
+################################################################################
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+################################################################################
+
appdirs==1.4.4
atlassian-python-api==3.8.0
black==20.8b1
[flink-jira-bot] 13/21: [hotfix] activate bot (remove dry-run flag)
Posted by kn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
knaufk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink-jira-bot.git
commit 648787f08974abfcc1902b1b65ba25fcd6648c61
Author: Konstantin Knauf <kn...@gmail.com>
AuthorDate: Wed Apr 14 12:10:12 2021 +0200
[hotfix] activate bot (remove dry-run flag)
---
.github/workflows/actions.yaml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/.github/workflows/actions.yaml b/.github/workflows/actions.yaml
index 0fc9681..4af2e33 100644
--- a/.github/workflows/actions.yaml
+++ b/.github/workflows/actions.yaml
@@ -2,7 +2,7 @@ name: Run Flink Jira Bot Hourly
on:
schedule:
- - cron: 33 9,21 * * *
+ - cron: 33 10,22 * * *
jobs:
run:
env:
@@ -22,4 +22,4 @@ jobs:
pip install -r requirements.txt
- name: Run Jira Bot
run: |
- python flink_jira_bot.py -d
\ No newline at end of file
+ python flink_jira_bot.py
\ No newline at end of file
[flink-jira-bot] 15/21: Merge pull request #3 from
knaufk/activate-bot
Posted by kn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
knaufk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink-jira-bot.git
commit 4cc0b90f655950c42dc06e4555631eb40ee51f42
Merge: 9afde47 4bd79cf
Author: Konstantin Knauf <me...@konstantin-knauf.de>
AuthorDate: Wed Apr 14 12:13:15 2021 +0200
Merge pull request #3 from knaufk/activate-bot
[hotfix] activate bot (remove dry-run flag)
.github/workflows/actions.yaml | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)