From 8b9f59ba944eb5291e8700c1af24310d22857e23 Mon Sep 17 00:00:00 2001 From: kongr45gpen Date: Wed, 7 Dec 2016 19:35:39 +0200 Subject: Add support for AppVeyor notifications Implements #12 --- __init__.py | 2 ++ local/handler/AppVeyorHandler.py | 13 ++++++++++ local/handler/GithubHandler.py | 3 +++ samples/appveyor.json | 51 ++++++++++++++++++++++++++++++++++++++++ test.py | 14 +++++++++++ 5 files changed, 83 insertions(+) create mode 100644 local/handler/AppVeyorHandler.py create mode 100644 samples/appveyor.json diff --git a/__init__.py b/__init__.py index 953dd50..92c68a6 100644 --- a/__init__.py +++ b/__init__.py @@ -39,6 +39,7 @@ import local.handler.StatusHandler import local.handler.TravisHandler import local.handler.MessageHandler import local.handler.ReleaseHandler +import local.handler.AppVeyorHandler import local.handler.CreateDeleteHandler import local.handler.IssueCommentHandler import local.theme.Theme @@ -55,6 +56,7 @@ reload(local.handler.StatusHandler) reload(local.handler.TravisHandler) reload(local.handler.MessageHandler) reload(local.handler.ReleaseHandler) +reload(local.handler.AppVeyorHandler) reload(local.handler.CreateDeleteHandler) reload(local.handler.IssueCommentHandler) reload(local.theme.Theme) diff --git a/local/handler/AppVeyorHandler.py b/local/handler/AppVeyorHandler.py new file mode 100644 index 0000000..f60fece --- /dev/null +++ b/local/handler/AppVeyorHandler.py @@ -0,0 +1,13 @@ +from ..utility import * + +def handle(data, theme): + if isStatusVisible(data['eventData']['projectId'], data['eventData']['status'].lower()): + theme.travis( + branch = data['eventData']['branch'], + repo = data['eventData']['repositoryName'].split('/')[1], + status = data['eventData']['status'], + commitId = data['eventData']['commitId'], + commitMessage = data['eventData']['commitMessage'], + commitAuthor = data['eventData']['commitAuthor'], + buildUrl = getShortURL(data['eventData']['buildUrl']) + ) diff --git a/local/handler/GithubHandler.py b/local/handler/GithubHandler.py index 6b2dd30..ce6edd2 100644 --- a/local/handler/GithubHandler.py +++ b/local/handler/GithubHandler.py @@ -35,6 +35,7 @@ import StatusHandler import TravisHandler import MessageHandler import ReleaseHandler +import AppVeyorHandler import CreateDeleteHandler import IssueCommentHandler @@ -178,6 +179,8 @@ class GithubHandler(BaseHTTPServer.BaseHTTPRequestHandler): PingHandler.handle(data, theme) elif 'message' in data: MessageHandler.handle(data, theme) + elif 'eventName' in data: + AppVeyorHandler.handle(data, theme) else: theme.unknown(eventType) diff --git a/samples/appveyor.json b/samples/appveyor.json new file mode 100644 index 0000000..7e4c5c5 --- /dev/null +++ b/samples/appveyor.json @@ -0,0 +1,51 @@ +{ + "eventData": { + "branch": "pullr1", + "buildId": 6010485, + "buildNumber": 2, + "buildUrl": "https://ci.appveyor.com/project/kongr45gpen/test/build/1.0.2", + "buildVersion": "1.0.2", + "commitAuthor": "alezakos", + "commitAuthorEmail": "electrovesta@gmail.com", + "commitAuthorUsername": "kongr45gpen", + "commitDate": "10/10/2016 7:39 PM", + "commitId": "3be0d004b9", + "commitMessage": "Update README.md", + "commitMessageExtended": "", + "commitUrl": "https://github.com/kongr45gpen/test/commit/3be0d004b9", + "committerEmail": "noreply@github.com", + "committerName": "GitHub", + "duration": "00:00:03.7343550", + "failed": true, + "finished": "12/7/2016 5:08 PM", + "isPullRequest": false, + "jobs": [ + { + "artifacts": [], + "compilationMessages": [], + "duration": "00:00:03.9843642", + "failed": true, + "finished": "12/7/2016 5:08 PM", + "id": "e80o7hecyuqcb89k", + "messages": [], + "messagesError": 0, + "messagesTotal": 0, + "name": "", + "passed": false, + "started": "12/7/2016 5:08 PM", + "status": "Failed" + } + ], + "messages": [], + "notificationSettingsUrl": "https://ci.appveyor.com/notifications", + "passed": false, + "projectId": 261821, + "projectName": "test", + "repositoryName": "kongr45gpen/test", + "repositoryProvider": "gitHub", + "repositoryScm": "git", + "started": "12/7/2016 5:08 PM", + "status": "failed" + }, + "eventName": "build_failure" +} \ No newline at end of file diff --git a/test.py b/test.py index 7c455a6..e52e099 100644 --- a/test.py +++ b/test.py @@ -84,6 +84,20 @@ class GithubTestCase(ExpectationPluginTestCase): self.assertError('get second message') + def testAppVeyor(self): + self.sendRequest('appveyor') + + self.describe('first message', + it().should.contain('pullr1 @ test'), + it().should.contain('failed'), + it().should.contain('3be0d'), + it().should.contain('alezakos'), + it().should.contain('Update README.md'), + it().should.contain('https://ci.appveyor.com/project/kongr45gpen/test/build/1.0.2') + ) + + self.assertError('get second message') + def testCreateTag(self): self.sendRequest('create-tag') -- cgit v1.2.3