Disable update github issue job.

* BOT will be configured to listen for treasuremap repo changes and
  add/update comments and issues status ( close ) as applicable.

Change-Id: I2e2070461e60fc75dd2066432c4f5cd48023c5e3
This commit is contained in:
siraj.yasin 2021-04-29 17:26:19 +00:00
parent 8df65e5109
commit 25ad182f32
5 changed files with 0 additions and 143 deletions

View File

@ -1,34 +0,0 @@
# 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.
- hosts: primary
tasks:
- name: Install python setuptools
package:
name:
- python3-pip
- python3-setuptools
state: present
become: yes
- name: Install script dependencies
pip:
name:
- PyGithub==1.46
executable: pip3
- name: Run python script
script: >
update_github_issues.py "{{ github_credentials.token }}" \
"{{ zuul.message | b64decode }}" \
"{{ zuul.change_url }}"
args:
executable: python3

View File

@ -1,82 +0,0 @@
# 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.
import logging
import re
import sys
import github
GH_TOKEN = sys.argv[1]
ZUUL_MESSAGE = sys.argv[2]
GERRIT_URL = sys.argv[3]
REPO_NAME = 'airshipit/airshipctl'
PROCESS_LABELS = ['wip', 'ready for review', 'triage', 'blocked']
def construct_issue_list(match_list: list) -> set:
new_list = []
for _issue in match_list:
try:
new_list.append(int(_issue))
except ValueError:
logging.warning(f'Value {_issue} could not be converted to `int` type')
return set(new_list)
def parse_issue_number(commit_msg: str) -> dict:
# Searches for Relates-To or Closes tags first to match and return
logging.debug(f'Parsing commit message: {commit_msg}')
related = re.findall(r'(?<=Relates-To: #)([0-9]+?)(?=\n)', commit_msg)
logging.debug(f'Captured related issues: {related}')
closes = re.findall(r'(?<=Closes: #)([0-9]+?)(?=\n)', commit_msg)
logging.debug(f'Captured closes issues: {closes}')
if related or closes:
return {
'related': construct_issue_list(related),
'closes': construct_issue_list(closes)
}
# If no Relates-To or Closes tags are defined, find legacy [#X] style tags
logging.debug('Falling back to legacy tags')
legacy_matches = re.findall(r'(?<=\[#)([0-9]+?)(?=\])', commit_msg)
logging.debug(f'Captured legacy issues: {legacy_matches}')
if not legacy_matches:
return {}
return {
'related': construct_issue_list(legacy_matches)
}
def remove_duplicated_issue_numbers(issue_dict: dict) -> dict:
if 'closes' in issue_dict:
issue_dict['related'] = [x for x in issue_dict.get('related', []) if x not in issue_dict['closes']]
return issue_dict
if __name__ == '__main__':
issue_number_dict = parse_issue_number(ZUUL_MESSAGE)
issue_number_dict = remove_duplicated_issue_numbers(issue_number_dict)
gh = github.Github(GH_TOKEN)
repo = gh.get_repo(REPO_NAME)
for key, issue_list in issue_number_dict.items():
for issue_number in issue_list:
issue = repo.get_issue(number=issue_number)
comment_msg = ''
link_exists = False
if key == 'closes':
issue.create_comment(f'The [Change]({GERRIT_URL}) that closes this issue was merged.')
for label in PROCESS_LABELS:
try:
issue.remove_from_labels(label)
except github.GithubException:
pass
else:
issue.create_comment(f'A [Related Change]({GERRIT_URL} was merged. This issue may be ready to close.')

View File

@ -10,15 +10,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
- job:
name: airship-treasuremap-update-github-issues
description: Updates and/or closes related issues on Github on merge
run: playbooks/airship-treasuremap-update-github-issues.yaml
nodeset: airship-treasuremap-single-node
secrets:
- name: github_credentials
secret: airship_treasuremap_airshipit_github_token
- job:
name: airship-treasuremap-validate-site-docs
timeout: 5400

View File

@ -30,9 +30,6 @@
post:
jobs:
- treasuremap-upload-git-mirror
promote:
jobs:
- airship-treasuremap-update-github-issues
tag:
jobs:
- treasuremap-upload-git-mirror

View File

@ -57,18 +57,3 @@
EjON6sxnRPCkcekmpUGqD/IXFYV/qxdvfnoDdVW5M2SZWzsHdMoJdBhL53FFaYDyPxTaR
4+kMmn8VTejOT2zQfny3zBoxMt30hYsAjHfDS62lxYJL/404uShhAi+1bpnyy+uxU39nQ
v3QSn8NtjBdh/WKptpsma1yZEHKAJJjfU9pmSrFHBfvokOmvTygjIC2uxP0ppo=
- secret:
name: airship_treasuremap_airshipit_github_token
data:
token: !encrypted/pkcs1-oaep
- HfAe26Qs2v8ezEsRe+cfrfHloleRHQY6aj+e4OvEKEJoxXi9Ok/slZOX1MMIPa9s9Ax3v
XFU4CPtUCfGUlYBlWtYTtr5vFtj+8i2BnbhUyEMzw/ZtzLEOFBKyV1nOvRmc3yAjHfLYy
F/gU+ezmhwCYHb6qCgKWqX4gngdIB0AOL3v5hyPN0S9skuxhTZP8rbyIUVSC/ZxWNy6y0
sGHXZHm/JfqaSH1zwsP4X/AGVBsXtmI8R3TCJE2bgn8aP5MAeV4hWD1AuO/+cqWtF7F+u
n1WNWP5C2ZujYcx/eqf/wh69pBCXwUaawbiT5IZSW1EG8kCy43038qzmbFmtbNODOfvcy
pEGYlOihhxTSIj9cslu+frV1cAsbiV8h8X6/7a4+z2gT96y2h58vTCMnkpUa2UUIuXUzT
kaUG+pTQZS0Tn1UbDGOrV2ANiIYbYzTeRqwXmwRukor+iUg/0pCiI1x8Hj2eA8l+oq4G8
EjjvYG6mXvOHQzz4sjJ3DLlOZLmkuDkvNft2ySLad93j78Hqs+YXrtv9r8o8txKGq52+j
TBmIUsB5MSYHRlS/GRmnCHH4CoKdXVzBNaxNge6HsNTUkanXQ5jQ1D4aN/h/rTC8Uv8tm
gOU85V71LEjayJ0X2bYkLwVcLcboC0Gf53IBfQyleVykiPfPUNNHFONyS/PgRY=