Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alice python - 3 Integration #20

Open
wants to merge 207 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
207 commits
Select commit Hold shift + click to select a range
762ff2a
Alice 3.0 restructuring
ParasJain-dev Aug 2, 2019
351c153
Alice 3.0 integration done/working
ParasJain-dev Aug 7, 2019
753dc5b
Integrated function with actor
ParasJain-dev Aug 7, 2019
6739626
Removed tokens
ParasJain-dev Aug 7, 2019
19f7a40
Removed Token
ParasJain-dev Aug 7, 2019
aa2c2c6
Added token rotation on rate limiting
ParasJain-dev Aug 8, 2019
77bde53
Added alternate git token in yaml
ParasJain-dev Aug 8, 2019
5ccf390
Removed redundant data
ParasJain-dev Aug 23, 2019
e51c6b4
removed old tokens
ParasJain-dev Aug 23, 2019
637783c
Removed conflict
ParasJain-dev Aug 23, 2019
8bfd8e7
restructured
ParasJain-dev Aug 23, 2019
20a7da5
Corrected yaml file
ParasJain-dev Aug 24, 2019
efe76b6
Alice code changed to python 3
ParasJain-dev Aug 26, 2019
68385ee
Python 3 integration done
ParasJain-dev Aug 28, 2019
9e120f6
Changes in yaml file
ParasJain-dev Aug 28, 2019
1288e46
Removed useless files
ParasJain-dev Aug 30, 2019
8e51479
Updated gitignore file
ParasJain-dev Aug 30, 2019
cd0fefe
Change pyyaml version to 5.1
ParasJain-dev Sep 3, 2019
150179e
Changed pyyaml in requirements.txt
ParasJain-dev Sep 3, 2019
88e0029
changed shield settings/Added github webhook
ParasJain-dev Sep 9, 2019
bd27465
Added shield for commons repo
ParasJain-dev Sep 9, 2019
b8b1e9a
Changed code for Request having status parameter
ParasJain-dev Sep 9, 2019
87bdb4a
added code for missing params
ParasJain-dev Sep 9, 2019
7f74e9b
CHanged exception settings
ParasJain-dev Sep 9, 2019
9323ff9
Changed code for closed repo
ParasJain-dev Sep 9, 2019
1c57abf
Chnaged code for moengage repo
ParasJain-dev Sep 10, 2019
5178375
Corrected param dict
ParasJain-dev Sep 10, 2019
30a863b
Major changes
ParasJain-dev Sep 11, 2019
7904444
Removed error
ParasJain-dev Sep 11, 2019
25eae8f
rectify bug
ParasJain-dev Sep 11, 2019
6bca82f
Python3 datetime
ParasJain-dev Sep 11, 2019
bd216f7
Fixed api manager issue
ParasJain-dev Sep 12, 2019
d566f15
Corrected segmentation error
ParasJain-dev Sep 12, 2019
13e13bb
Change config for constants(Major)
ParasJain-dev Sep 16, 2019
074e8f9
Made file read generic
ParasJain-dev Sep 16, 2019
52eaa7e
FIxed python2 bugs
ParasJain-dev Sep 17, 2019
b07a415
Tested and fixed python2 bugs
ParasJain-dev Sep 17, 2019
6710fc8
Refactored code
ParasJain-dev Sep 19, 2019
e53ee45
Added check for jenkins on debug
ParasJain-dev Sep 19, 2019
38cde07
Fixed slack issue(naming)
ParasJain-dev Sep 19, 2019
11dc5e4
Changed posttoslackwarning
ParasJain-dev Sep 20, 2019
48b1c19
Fixed issue
ParasJain-dev Sep 20, 2019
1d96526
Fixed issue related to slack
ParasJain-dev Sep 20, 2019
38253d8
Added feature for infra requests
ParasJain-dev Sep 21, 2019
deb81e8
Rectified bug of freeze repo
ParasJain-dev Sep 22, 2019
64d19e8
Added git and slack mapping
ParasJain-dev Sep 23, 2019
5ee91b3
Changed username
ParasJain-dev Sep 23, 2019
f7cdef9
Added try except for failure catching
ParasJain-dev Sep 23, 2019
59958dc
Changed function call for moengage repo
ParasJain-dev Sep 24, 2019
8836499
Added cases for commons repo
ParasJain-dev Sep 24, 2019
f5a8c1d
removed duplicated function
ParasJain-dev Sep 24, 2019
f348253
Patch channel name
ParasJain-dev Sep 24, 2019
875d392
Infra-request patch
ParasJain-dev Sep 24, 2019
083c327
Unit test fix
ParasJain-dev Sep 24, 2019
ba4e32e
Changed routes for task and issue
ParasJain-dev Sep 24, 2019
8c02152
Dashboard fix
ParasJain-dev Sep 24, 2019
261ed6f
Patch fixer
ParasJain-dev Sep 24, 2019
b01aa0b
Changes in constants
ParasJain-dev Sep 24, 2019
c56975e
Fixed extracodes
ParasJain-dev Sep 25, 2019
36d8ca7
Added fail safe
ParasJain-dev Sep 25, 2019
4a6602f
added notification for seg repo
ParasJain-dev Sep 25, 2019
5a5b085
Changed username in jenkins
ParasJain-dev Sep 25, 2019
8f7d523
Fixed name in infra reqeust
ParasJain-dev Sep 26, 2019
53aa074
Added new repos in python repo
ParasJain-dev Sep 26, 2019
9166140
Calling close Dangerous pr from function
ParasJain-dev Sep 27, 2019
be60fa9
Fixed dangerous pr
ParasJain-dev Sep 27, 2019
5eab231
Changed error message
ParasJain-dev Sep 27, 2019
ad9ade7
Added logic for Checking sensitive filed
ParasJain-dev Sep 30, 2019
d032bbb
Changes error message
ParasJain-dev Oct 1, 2019
c3b6ba5
Commented freeze other repos
ParasJain-dev Oct 1, 2019
2e57aab
Changed pr close message
ParasJain-dev Oct 3, 2019
b279b9e
Added hotfix option for close dangerous pr
ParasJain-dev Oct 3, 2019
3d8dc9e
Added message for printing in terminal
ParasJain-dev Oct 4, 2019
30c087b
Added timer for pr to close
ParasJain-dev Oct 9, 2019
70a846e
Added settings for integration test
ParasJain-dev Oct 15, 2019
39d2d21
Updated merge message
ParasJain-dev Oct 16, 2019
b278937
Fix parse
ParasJain-dev Oct 17, 2019
57fe37a
Integrated idp-metadata
ParasJain-dev Oct 24, 2019
065c54c
Major shield job change
ParasJain-dev Oct 24, 2019
66060c5
Added fix for other branches
ParasJain-dev Nov 4, 2019
af0eaad
Added drone file
ParasJain-dev Nov 14, 2019
ed2318d
removed drone file
ParasJain-dev Nov 14, 2019
092ef42
Added option for py and nose test
ParasJain-dev Nov 14, 2019
6afdf7e
Changed channel name
ParasJain-dev Nov 15, 2019
702b3ec
Added code for edited action
ParasJain-dev Nov 18, 2019
5b508c1
Added hotfix
ParasJain-dev Nov 18, 2019
808d9d1
Added code for datapoint repo
ParasJain-dev Nov 18, 2019
23698ea
fix
ParasJain-dev Nov 18, 2019
67f7af2
Fixed recursion when action is edited
ParasJain-dev Nov 18, 2019
5382d96
fixed close pr logic
ParasJain-dev Nov 18, 2019
e425361
Create .drone.yml
ParasJain-dev Nov 22, 2019
2fb64f2
Update .drone.yml
ParasJain-dev Nov 22, 2019
829d7a5
Added drone file
ParasJain-dev Nov 22, 2019
21ac8ff
Added drone file
ParasJain-dev Nov 22, 2019
780477a
Added drone file
ParasJain-dev Nov 22, 2019
9994b7e
Update .drone.yml
ParasJain-dev Nov 27, 2019
2a45945
Create a.py
ParasJain-dev Nov 27, 2019
87e8a4e
Delete a.py
ParasJain-dev Nov 27, 2019
be3e054
Update .drone.yml
ParasJain-dev Nov 27, 2019
99de9f9
Update .drone.yml
ParasJain-dev Nov 27, 2019
5596549
Update .drone.yml
ParasJain-dev Nov 27, 2019
f8b9278
Update .drone.yml
ParasJain-dev Nov 27, 2019
c437d1e
Update .drone.yml
ParasJain-dev Nov 27, 2019
103c6e2
Update .drone.yml
ParasJain-dev Nov 27, 2019
3beee50
Update .drone.yml
ParasJain-dev Nov 27, 2019
c297bd0
Update .drone.yml
ParasJain-dev Nov 27, 2019
437c1eb
Update .drone.yml
ParasJain-dev Nov 27, 2019
87ee0cb
Update .drone.yml
ParasJain-dev Nov 27, 2019
6579cdb
Update .drone.yml
ParasJain-dev Nov 27, 2019
e1e5165
Update .drone.yml
ParasJain-dev Nov 27, 2019
84f9ad1
Update .drone.yml
ParasJain-dev Nov 27, 2019
484e3bd
Update .drone.yml
ParasJain-dev Nov 27, 2019
6157bd7
Update .drone.yml
ParasJain-dev Nov 27, 2019
fd2f520
Update .drone.yml
ParasJain-dev Nov 27, 2019
bd5d9fe
Update .drone.yml
ParasJain-dev Nov 28, 2019
ff0cc07
Update .drone.yml
ParasJain-dev Nov 28, 2019
7c0d364
Update .drone.yml
ParasJain-dev Nov 28, 2019
db116c7
Update .drone.yml
ParasJain-dev Nov 28, 2019
69d815e
Update .drone.yml
ParasJain-dev Nov 28, 2019
52242d4
Update .drone.yml
ParasJain-dev Nov 28, 2019
7ea6d2b
Update .drone.yml
ParasJain-dev Nov 28, 2019
1c7303d
Update .drone.yml
ParasJain-dev Nov 28, 2019
a14ea31
Update .drone.yml
ParasJain-dev Nov 28, 2019
a4c58f4
Update .drone.yml
ParasJain-dev Nov 28, 2019
4d22f25
Update .drone.yml
ParasJain-dev Nov 28, 2019
4ca8e58
Update .drone.yml
ParasJain-dev Nov 28, 2019
d36e306
Update .drone.yml
ParasJain-dev Nov 28, 2019
0ae2124
Update .drone.yml
ParasJain-dev Nov 28, 2019
f7c21bb
Update .drone.yml
ParasJain-dev Nov 28, 2019
9ea647c
Update .drone.yml
ParasJain-dev Nov 28, 2019
0e70e6c
Update .drone.yml
ParasJain-dev Nov 28, 2019
ad2590c
Update .drone.yml
ParasJain-dev Nov 28, 2019
59417fe
Added check for dashboard change
ParasJain-dev Dec 5, 2019
1e482d0
Merge branch 'alice-dev-python3' of github.com:moengage/alice into al…
ParasJain-dev Dec 5, 2019
f82f36f
Added new repo oauth2
ParasJain-dev Dec 6, 2019
38491ef
Added drone code
ParasJain-dev Dec 16, 2019
75e114c
Added drone setting
ParasJain-dev Dec 16, 2019
0f3839f
fixed bug
ParasJain-dev Dec 16, 2019
1ce1188
Added security
ParasJain-dev Dec 16, 2019
871bce4
Working alice
ParasJain-dev Dec 16, 2019
8f562a5
Changed messaging format
ParasJain-dev Dec 17, 2019
d62a8ec
Changed status
ParasJain-dev Dec 18, 2019
48ae9f4
added security
ParasJain-dev Dec 18, 2019
296549b
Added security for git
ParasJain-dev Dec 24, 2019
8003610
Security fix
ParasJain-dev Dec 24, 2019
e467f65
Added encoding
ParasJain-dev Dec 24, 2019
a1ef6ba
Converted to str
ParasJain-dev Dec 24, 2019
82b403a
Added string matching
ParasJain-dev Dec 24, 2019
d0844f9
Changed jira code
ParasJain-dev Dec 26, 2019
aca30a7
Added api test support
ParasJain-dev Jan 21, 2020
8216b86
Commented drone code
ParasJain-dev Jan 21, 2020
f1986a7
Added saas repo
ParasJain-dev Jan 22, 2020
9a4273a
Whitelist services for closing in alice
ParasJain-dev Jan 29, 2020
4f9ece2
Removed integration test from moengage
ParasJain-dev Feb 3, 2020
e9b0ebb
Added safe check for action= closed
ParasJain-dev Feb 3, 2020
572492b
Removed check to stop integration test
ParasJain-dev Feb 10, 2020
6ef5657
Added dash repo
ParasJain-dev Feb 19, 2020
734cff3
Added check for partial branch
ParasJain-dev Feb 20, 2020
b7c19d1
Added sensitive branch code
ParasJain-dev Feb 20, 2020
7343476
Resoleved bug
ParasJain-dev Feb 21, 2020
2e45196
changed .gitignore
ParasJain-dev Feb 23, 2020
1142b61
Added moedatascience
ParasJain-dev Mar 17, 2020
2733145
Added exception handling
ParasJain-dev Mar 17, 2020
32053b3
Added skip status for Java repo
ParasJain-dev Apr 2, 2020
e6c5f96
Added context for java
ParasJain-dev Apr 2, 2020
c6e1726
Added user_profile
ParasJain-dev Apr 3, 2020
61c7c39
Added support for new repos
ParasJain-dev Apr 6, 2020
6700e47
Added skip test for dependent bot
ParasJain-dev Apr 14, 2020
01a0356
Added shield triggers for edit action
ParasJain-dev Apr 14, 2020
dc2f42e
revert
ParasJain-dev Apr 14, 2020
a0dedd8
Again added feature
ParasJain-dev Apr 14, 2020
eecb0d8
added ami change code
ParasJain-dev Apr 24, 2020
e28da75
Added shield
ParasJain-dev Apr 24, 2020
fe7ffb5
Added message
ParasJain-dev Apr 24, 2020
a039e4d
Added for sensitive check
ParasJain-dev Apr 27, 2020
e081d71
Added code for limiting alerting
ParasJain-dev Apr 28, 2020
ba64a68
Added print message
ParasJain-dev Apr 28, 2020
a823e7e
Added comments and sleep
ParasJain-dev Apr 28, 2020
5a85f8e
CHanged channel
ParasJain-dev Apr 28, 2020
7d0244c
Added label
ParasJain-dev Apr 28, 2020
04166c7
Fixed issue
ParasJain-dev Apr 28, 2020
4ca6ed1
Updated channel name
ParasJain-dev Apr 28, 2020
6c295bf
Added error message for HTTP erro
ParasJain-dev Apr 30, 2020
f046a8d
Changed lint path issue
ParasJain-dev Apr 30, 2020
d62f8fe
Reduced no of calls to external service to 3x
ParasJain-dev Apr 30, 2020
d0da9b1
Replace weekly release to releases
ParasJain-dev May 11, 2020
9be28c4
changed channel name
ParasJain-dev May 13, 2020
21a837c
new integration for cards repo
Jul 2, 2020
37196dd
Added version change for moengage
ParasJain-dev Aug 7, 2020
1901162
Merge branch 'alice-dev-python3' of https://github.com/moengage/alice…
Aug 7, 2020
25e3994
Rectified code
ParasJain-dev Aug 7, 2020
dabfdbf
Merge branch 'alice-dev-python3' of https://github.com/moengage/alice…
Aug 7, 2020
9ec6142
Added success status
ParasJain-dev Aug 7, 2020
9cb0e6e
Merge branch 'alice-dev-python3' of https://github.com/moengage/alice…
Aug 7, 2020
210d6cf
changed context name
Aug 7, 2020
4f4d908
Added check to run only for moengage
ParasJain-dev Aug 18, 2020
6ca9c9d
merge change
ParasJain-dev Aug 18, 2020
d6d6d3d
changed context
ParasJain-dev Aug 19, 2020
0339c7c
ADded email-campaign repo in release checklist
ParasJain-dev Aug 24, 2020
c0aaf56
removed dashboard builder prod
ParasJain-dev Sep 21, 2020
d8c7c69
added campaign reports repo
ParasJain-dev Jan 28, 2021
f0b9de8
commented slack alert
ParasJain-dev Jun 29, 2021
9f9c996
slack helper commented
ParasJain-dev Jun 29, 2021
5e1e830
commented inapp rest service job
ParasJain-dev Jul 30, 2021
ad2f2c5
ami change commented
ParasJain-dev Sep 16, 2021
20092c7
Adding support master py2 dev py3 (#27)
habin-163 Jan 10, 2023
32990ff
Adding support master py2 dev py3 (#28)
habin-163 Jan 10, 2023
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
8 changes: 5 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ build/
*.egg
.egg-info/
trail


alice/dump.rdb
dump.rdb
.DS_Store
*/.DS_Store

# Created by https://www.gitignore.io/api/flask,python,visualstudiocode
# Edit at https://www.gitignore.io/?templates=flask,python,visualstudiocode
Expand Down Expand Up @@ -208,4 +210,4 @@ dmypy.json
# Ignore all local history of files
.history

# End of https://www.gitignore.io/api/flask,python,visualstudiocode
# End of https://www.gitignore.io/api/flask,python,visualstudiocode
10 changes: 5 additions & 5 deletions alice/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@

app = Flask(__name__)


@app.route("/alice", methods=['POST'])
def alice():
if request.method != 'POST':
abort(501)
payload = request.get_data()
data = json.loads(unicode(payload, errors='replace'), strict=False)
merge_correctness = RunChecks().run_checks(request, data)
payload = json.loads(payload)
merge_correctness = RunChecks().run_checks(payload)
return jsonify(merge_correctness)


@app.route("/", methods=['GET', 'POST'])
def home():
return "************ Welcome to the wonderful world of Alice ***********"
Expand All @@ -29,7 +29,7 @@ def jira_integration():
if request.method == 'POST':
payload = request.get_data()
print("************* payload ***************", payload)
data = json.loads(unicode(payload, errors='replace'), strict=False)
data = json.loads(payload)
print("************* data ***************", data)
parsed_data = JiraPayloadParser(request, data)
actor_obj = JiraActor(parsed_data)
Expand Down
43 changes: 42 additions & 1 deletion alice/checker_impl.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,55 @@
from alice.main.checks import Checks


class PRFilesNotFoundException(Exception):
def __init__(self, pr_response):
self.pr_response = pr_response
super(PRFilesNotFoundException, self).__init__(str(self.pr_response))


class CheckImpl(Checks):

def __init__(self, push_payload_parser):
super(CheckImpl, self).__init__(push_payload_parser)
self.pr = push_payload_parser

# def get_diff_files(self, repo):
# #Implement old function only
# from subprocess import Popen, PIPE, STDOUT
# import subprocess
# import os
# """
# First, It fetches commits of a repo, then we compare
# top two commit of a repo and we get the file difference.
# :param repo:
# :return:
# """
# # command = 'git log -2'
# # run_cmd = Popen(command, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True)
# # commit_data = run_cmd.stdout.read()
# # commits = []
# # for line in commit_data.split('\n'):
# # first_six = line[:6]
# # if first_six == 'commit':
# # commits.append(line.split(' ')[1])
# # first_commit = str(commits[0])
# # second_commit = str(commits[1])
# first_commit = str(self.pr.base_sha)
# second_commit = str(self.pr.head_sha)
# command = 'git diff %s'%second_commit + '...%s'%first_commit
# p = Popen(command, shell=True, stdin=PIPE, stdout=PIPE)
# diff_data = p.stdout.read()
# file_edited = []
# for line in diff_data.split('\n'):
# first_three = line[:3]
# if first_three == "+++":
# file_name = line.split('+++')[1].split('/')[1:]
# file_path = "/".join(file_name)
# file_edited.append(file_path)
# print(file_edited)
# return file_edited

"""
"""
Implement your check here, will be automatically called

To get pull request related data, access with self.pr Ex.
Expand Down
36 changes: 34 additions & 2 deletions alice/commons/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,17 @@ class Base(object):


class PushPayloadParser(Base):
"""
Adding global config as we want to
want to access jenkins token
"""

def __init__(self, request, payload):
self.request = request
def __init__(self, payload):
self.payload = payload
self.pr = payload["pull_request"]
LOG.debug("Repo=" + self.repo)
self.config = ConfigProvider(self.repo)
self.global_config = ConfigProvider()

@property
def repo(self):
Expand Down Expand Up @@ -78,6 +82,8 @@ def comments_section(self):

@property
def is_sensitive_branch(self):
if self.config.sensitiveBranches is None:
return None
return self.base_branch in self.config.sensitiveBranches

@property
Expand All @@ -88,4 +94,30 @@ def title(self):
def description(self):
return self.pr["body"]

@property
def head_ref(self):
return self.pr["base"]

@property
def head_label(self):
return self.pr["head"]["label"]

@property
def ssh_url(self):
return self.pr["head"]["repo"]["ssh_url"]

@property
def link_pr(self):
return self.payload["pull_request"]["_links"]["html"]["href"]

@property
def statuses_url(self):
return self.payload["pull_request"]["statuses_url"]

@property
def head_sha(self):
return self.payload["pull_request"]["head"]["sha"]

@property
def base_sha(self):
return self.payload["pull_request"]["base"]["sha"]
4 changes: 4 additions & 0 deletions alice/config/config_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ def organisation(self):
def githubToken(self):
return self.config.get('tokens').get("github")

@property
def github_alternate_token(self):
return self.config.get('tokens').get("github_alternate")

@property
def slackToken(self):
return self.config.get('tokens').get("slack")
Expand Down
2 changes: 2 additions & 0 deletions alice/config/message_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
"- [ ] Release Notes linked?"
}

ADDITIONAL_COMMENT = [ "- [ ] Testing comments\n", "- Testing comments 2\n"]

DOC_CHECK_NOT_FOUND = "\"{check_name}\" Check is not found (please cross check the checks defined in config file). \n" \
"If you wish to implement this new check yourself, please read here: " + Blinking_Colors.OKBLUE + \
"{doc_link}" + Blinking_Colors.END
Expand Down
28 changes: 26 additions & 2 deletions alice/helper/api_manager.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,40 @@
import requests
import json
from alice.config.config_provider import ConfigProvider


class ApiManager(object):
"""
Get function is used for making get calls
Post function is used for making Post calls
Check function is used for token rotation when we get rate limiting.
Check function is called in get and post function for checking and rotating the token.
"""

@staticmethod
def get(url, headers, data=None):
response = requests.get(url, headers=headers, data=data)
response = ApiManager.check(response, url, headers, data, "get")
return {"status_code": response.status_code, "content": response.content, "response": response}


@staticmethod
def post(url, headers, data=None):
pass
response = requests.post(url, headers=headers, data=data)
response = ApiManager.check(response, url, headers, data, "post")
return {"status_code": response.status_code, "content": response.content, "response": response}

@staticmethod
def check(response, url, headers, data, request_type):
response_data = json.loads(response.content)
if type(response_data) is dict and "message" in response_data and "documentation_url" in response_data:
token = ConfigProvider().github_alternate_token
headers["Authorization"] = "token %s"%token
if request_type == "get":
response = requests.get(url, headers=headers, data=data)
else:
response = requests.post(url, headers=headers, data=data)
return response
else:
return response


2 changes: 1 addition & 1 deletion alice/helper/common_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def getSlackUsers():

for item in users["members"]:
slack_mappings[item["name"]] = item["profile"].get("email","bot@gmail.com")
print slack_mappings
print(slack_mappings)

@staticmethod
def getSlackNicksFromGitNicks(key):
Expand Down
76 changes: 76 additions & 0 deletions alice/helper/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,79 @@
THUMBS_UP_ICON = "\ud83d\udc4d"
SLACK_ICON = "https://cloud.githubusercontent.com/assets/12966925/25132384/021095fc-2467-11e7-95c0-78917bf4d52a.png"
bot_name = "alice"



"""
alice 3.0 constants
"""

auto_revert = False
ui_change = False
base_api_cmd = "https://api.github.com/repos/moengage/"
ui_repo = ["dashboard-ui"]

context = "shield-syntax-validator-python"
context_react = "shield-linter-react"
context_angular = "shield-linter-angular"

package_builder_branches_repo_wise = {
"dashboard-ui": ["qa", "master"]
}
python_repo = ["MoEngage", "MoeDataScience", "mongoengine", "inapp-rest-service", "mongo", "segmentation",
"commons",
"moengcache", "MoeAbTesting", "apns_client", "Bugsy_Backend", "product-management",
"product-recommendation", "s2s", "email-campaigns", "campaigns-core", "url_tracking"]

file_path = "/opt/alice/release_items.txt"
file_mergedBy = "/opt/alice/release_mergedby.txt"
code_freeze_details_path = "/opt/alice/code_freeze_details.txt"
release_freeze_details_path = "/opt/alice/release_freeze_details.txt"
job_dir = "moe_repo_shield/"
job_name = job_dir + "CI_SyntaxValidator"
context_description = "Syntax Validation"
action_commit_to_investigate = ["opened", "open", "reopened", "synchronize"]

sensitive_branches_repo_wise = {"moengage": ["dev", "qa", "master"],
"dashboard-ui": ["dev", "qa", "master"],
"segmentation": ["develop", "release", "master", "qa"],
"commons": ["develop", "release", "master", "qa"],
"product-management": ["develop", "release", "master", "qa"]
}

sensitive_branches_default = ["develop", "release", "master", "qa", "dev"]

release_freeze_details_path = "/opt/alice/release_freeze_details.txt"
alice_product_team = ["@pooja"]
alice_qa_team = ["@U067GM3DW"]
bot_name = "Alice"
applaud_list = ["Awesome", "Great Efforts", "Good work", "Appreciate your efforts", "Perfect"]
post_checklist_msg = ["planned for VodQA? Click here to read more",
"here is your post release activities list", "had your vodQA? :thinking_face:",
"Click here for your checklist", "Scheduled Automation class?",
"Did you check *Let's Shine* here?",
"on your behalf, I have reminded PMs to update the release notes for next release. here is your checklist",
"6 points you may want to check now"]
code_freeze_details_path = "/opt/alice/code_freeze_details.txt"

# valid_contributors = ["ajishnair", "shahp00ja", "vandanamoriwal", "geetima12", "akgoel-mo", "naveenkumarkokku",
# "prashanthegde9", "moeoperation", "BhuvanThejaChennuru", "kanikapuniya2", "siri-murthy",
# "gagana11", "madhurjyaparashar", "rkjas12", "Madhukirankm"]

pkg_people_to_notify = {"commons": "pooja"} # ["@pooja"]
alice_dev_team_MoEngage_repo = "@pooja"
to_be_notified = "pooja"
tech_leads_to_notify_always_slack = "<@pooja>"
product_notify_slack = "<@pooja>"
dev_ops_team = "<@pooja>"
channel_name = "#tmp"
merged_by_slack_name = ""
alice_tech_leads_MoEngage_Repo = ""

organization_repo = 'moengage'
master_branch = 'master'
staging_branch = 'qa'
dev_branch = 'dev'

repo_site_url = 'https://api.github.com/'

2 changes: 1 addition & 1 deletion alice/helper/decorators/retry.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def retries(*args, **kwargs):
return func(*args, **kwargs)
except self.exceptions_to_catch:
if i == self.max_retries - 1 and self.default_value is None:
raise sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2]
raise(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])
time.sleep(self.after)
#self.logger.info(task=func.__name__, message="retrying function")
# logger.debug(task=func.__name__, message="retrying function",
Expand Down
2 changes: 1 addition & 1 deletion alice/helper/file_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def get_dict_from_yaml(file_path):
data = {}
with open(file_path, 'r') as stream:
try:
data = yaml.load(stream)
data = yaml.load(stream, yaml.Loader)
Copy link
Contributor

Choose a reason for hiding this comment

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

.load need not be replaced with .safe_load?

except yaml.YAMLError as exc:
LOG.error("\nPlease validate your config file, if it is correct. Can use http://www.yamllint.com/ to debug quicker")
raise (exc)
Expand Down
7 changes: 3 additions & 4 deletions alice/helper/github_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,21 @@ def __init__(self, pr):
" the organisation or the repository")

def comment_pr(self, comment_section, comment):
resp = requests.post(comment_section, headers=self.headers,
data=json.dumps(comment))
resp = ApiManager.post(comment_section, self.headers, json.dumps(comment))
LOG.debug(resp.content)

def modify_pr(self, msg, state):
data = {
"title": msg,
"state": state
}
resp = requests.post(self.pr_api_link, json.dumps(data), headers=self.headers)
resp = ApiManager.post(self.pr_api_link, self.headers, json.dumps(data))
LOG.debug(resp.content)

def get_reviews(self):
url = self.pr_api_link + "/" + EP_REVIEWS
self.headers["Accept"] = API_GITHUB_REVIEW_ACCEPT_KEY
return requests.get(url, headers=self.headers)
return ApiManager.get(url, headers=self.headers)

def get_files_requests(self):
url = self.pr_api_link + "/files"
Expand Down
Loading