lita-travis-announcer 0.1.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: eb372bd9f0898488d345c0f611ad1296517ca2d1
4
- data.tar.gz: d1c57584eec5ef890da5ec7d84b03edf7518c612
3
+ metadata.gz: 3f7791db49ad0004ef4a23e9297afd0b163f34ea
4
+ data.tar.gz: 32f2326e4e94e837d03be5df53b1f516918f3d0d
5
5
  SHA512:
6
- metadata.gz: 49476b3f734945f92513f67728502cd974f2a27d5de86fdbdc20946fb02134c6a270c190487a90e9964381b15c02896e2d8baf1519bbf0e6325a5e8a2da488b1
7
- data.tar.gz: 16454255fb69e3c3815a7fa86ea8490360a9179fda9d92f0a2fc0982afadd7180a9a226ad8775af68073b6b779c906cf13e9a352e84dc68010e3513e8846af9e
6
+ metadata.gz: 190d7489f9d58f94e25660fb6e49e3c21cca241c81f9153c68f804860ff9557f344d1ab5b5eea56ed0142aa6250c363e29bd9ecf8277d306daef6c9268eb35f5
7
+ data.tar.gz: 5fb1c98e19cd41b75da80925a968cf8e59fb9a262fb9a77521f3fa856436b040079efb6d529f7d1370f364aed22e34634a49ad1a4540069d6df8f798ec67cc6e
data/Rakefile CHANGED
@@ -4,3 +4,9 @@ require "rspec/core/rake_task"
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
6
6
  task default: :spec
7
+
8
+ task :send_posts do
9
+ puts 'Running postman test suite with newman...'
10
+ `newman run ./spec/postman/*`
11
+ puts 'Done.'
12
+ end
@@ -4,7 +4,7 @@ module Lita
4
4
  module Handlers
5
5
  class TravisAnnouncer < Handler
6
6
 
7
- config :travis_room, default: '#general'
7
+ config :travis_room, default: 'shell'
8
8
 
9
9
  http.post '/travis-announcer/travis', :travis_webhook
10
10
 
@@ -17,17 +17,13 @@ module Lita
17
17
  end
18
18
 
19
19
  def handle_travis_build(hook)
20
- if hook.working?
21
- announce "we did it, twitch!"
22
- else
23
- announce "it was a bad build."
24
- end
20
+ announce '*Broken build!*' if hook.broken?
21
+ announce hook.notification_string
25
22
  end
26
23
 
27
24
  def announce(message)
28
- msg = "Received announcement: #{message}"
29
- puts msg
30
- robot.send_message Source.new(room: '#general'), msg
25
+ Lita.logger.debug "Received announcement: #{message}"
26
+ robot.send_message Source.new(room: '#general'), message
31
27
  end
32
28
 
33
29
  Lita.register_handler(self)
@@ -16,6 +16,14 @@ module Lita
16
16
  status_message
17
17
  end
18
18
 
19
+ def repo_name
20
+ repository.fetch 'name'
21
+ end
22
+
23
+ def notification_string
24
+ "*#{description}* [#{repo_name}] >> #{message} >> (#{compare_url})"
25
+ end
26
+
19
27
  def working?
20
28
  %w[Pending Passed Fixed].include? status_message
21
29
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = 'lita-travis-announcer'
3
- spec.version = '0.1.0'
3
+ spec.version = '1.0.0'
4
4
  spec.authors = ['Daniel J. Pritchett']
5
5
  spec.email = ['dpritchett@gmail.com']
6
6
  spec.description = 'Chatops tools for announcing and deploying successful software builds'
@@ -15,7 +15,7 @@ describe Lita::TravisWebhook do
15
15
  expect(subject.working?).to be_truthy
16
16
  expect(subject.broken?).to be_falsey
17
17
  end
18
-
18
+
19
19
  context 'a failed build' do
20
20
  let(:input_path) { 'travis_failure' }
21
21
 
@@ -0,0 +1,53 @@
1
+ {
2
+ "variables": [],
3
+ "info": {
4
+ "name": "lita travis hooks DEV",
5
+ "_postman_id": "40acfb2c-40c9-fcc3-f86c-8177e3fc6444",
6
+ "description": "",
7
+ "schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json"
8
+ },
9
+ "item": [
10
+ {
11
+ "name": "Travis Bad Build",
12
+ "request": {
13
+ "url": "localhost:8080/travis-announcer/travis",
14
+ "method": "POST",
15
+ "header": [],
16
+ "body": {
17
+ "mode": "formdata",
18
+ "formdata": [
19
+ {
20
+ "key": "payload",
21
+ "value": "{\n \"id\": 375024421,\n \"number\": \"56\",\n \"config\": {\n \"os\": \"linux\",\n \"rvm\": [\n \"2.3.3\"\n ],\n \"dist\": \"trusty\",\n \"group\": \"stable\",\n \".result\": \"configured\",\n \"language\": \"ruby\",\n \"services\": [\n \"redis-server\"\n ],\n \"notifications\": {\n \"webhooks\": [\n \"http:\\/\\/bookbot.pritchettbots.com\\/shipit\\/travis\",\n \"http:\\/\\/7c7e83e9.ngrok.io\\/shipit\\/travis\"\n ]\n }\n },\n \"type\": \"push\",\n \"state\": \"failed\",\n \"status\": 1,\n \"result\": 1,\n \"status_message\": \"Failed\",\n \"result_message\": \"Failed\",\n \"started_at\": \"2018-05-04T18:47:46Z\",\n \"finished_at\": \"2018-05-04T18:49:41Z\",\n \"duration\": 115,\n \"build_url\": \"https:\\/\\/travis-ci.org\\/dpritchett\\/ruby-bookbot\\/builds\\/375024421\",\n \"commit_id\": 112089127,\n \"commit\": \"64794d01af723add0f895383c1fa67cdfb865da3\",\n \"base_commit\": \"64794d01af723add0f895383c1fa67cdfb865da3\",\n \"head_commit\": null,\n \"branch\": \"djp\\/broken-build-for-travis\",\n \"message\": \"purposefully breaking the build for a travis fixture generation\",\n \"compare_url\": \"https:\\/\\/github.com\\/dpritchett\\/ruby-bookbot\\/commit\\/64794d01af72\",\n \"committed_at\": \"2018-05-04T18:47:26Z\",\n \"author_name\": \"Daniel J. Pritchett\",\n \"author_email\": \"dpritchett@gmail.com\",\n \"committer_name\": \"Daniel J. Pritchett\",\n \"committer_email\": \"dpritchett@gmail.com\",\n \"pull_request\": false,\n \"pull_request_number\": null,\n \"pull_request_title\": null,\n \"tag\": null,\n \"repository\": {\n \"id\": 12787622,\n \"name\": \"ruby-bookbot\",\n \"owner_name\": \"dpritchett\",\n \"url\": null\n },\n \"matrix\": [\n {\n \"id\": 375024422,\n \"repository_id\": 12787622,\n \"parent_id\": 375024421,\n \"number\": \"56.1\",\n \"state\": \"failed\",\n \"config\": {\n \"os\": \"linux\",\n \"rvm\": \"2.3.3\",\n \"dist\": \"trusty\",\n \"group\": \"stable\",\n \".result\": \"configured\",\n \"language\": \"ruby\",\n \"services\": [\n \"redis-server\"\n ],\n \"notifications\": {\n \"webhooks\": [\n \"http:\\/\\/bookbot.pritchettbots.com\\/shipit\\/travis\",\n \"http:\\/\\/7c7e83e9.ngrok.io\\/shipit\\/travis\"\n ]\n }\n },\n \"status\": 1,\n \"result\": 1,\n \"commit\": \"64794d01af723add0f895383c1fa67cdfb865da3\",\n \"branch\": \"djp\\/broken-build-for-travis\",\n \"message\": \"purposefully breaking the build for a travis fixture generation\",\n \"compare_url\": \"https:\\/\\/github.com\\/dpritchett\\/ruby-bookbot\\/commit\\/64794d01af72\",\n \"started_at\": null,\n \"finished_at\": null,\n \"committed_at\": \"2018-05-04T18:47:26Z\",\n \"author_name\": \"Daniel J. Pritchett\",\n \"author_email\": \"dpritchett@gmail.com\",\n \"committer_name\": \"Daniel J. Pritchett\",\n \"committer_email\": \"dpritchett@gmail.com\",\n \"allow_failure\": false\n }\n ]\n}\n",
22
+ "description": "",
23
+ "type": "text"
24
+ }
25
+ ]
26
+ },
27
+ "description": "It wa sa bad build."
28
+ },
29
+ "response": []
30
+ },
31
+ {
32
+ "name": "Travis Good Build",
33
+ "request": {
34
+ "url": "localhost:8080/travis-announcer/travis",
35
+ "method": "POST",
36
+ "header": [],
37
+ "body": {
38
+ "mode": "formdata",
39
+ "formdata": [
40
+ {
41
+ "key": "payload",
42
+ "value": "{\n \"id\": 375009707,\n \"number\": \"55\",\n \"config\": {\n \"os\": \"linux\",\n \"rvm\": [\n \"2.3.3\"\n ],\n \"dist\": \"trusty\",\n \"group\": \"stable\",\n \".result\": \"configured\",\n \"language\": \"ruby\",\n \"services\": [\n \"redis-server\"\n ],\n \"notifications\": {\n \"webhooks\": [\n \"http:\\/\\/bookbot.pritchettbots.com\\/shipit\\/travis\",\n \"http:\\/\\/7c7e83e9.ngrok.io\\/shipit\\/travis\"\n ]\n }\n },\n \"type\": \"push\",\n \"state\": \"passed\",\n \"status\": 0,\n \"result\": 0,\n \"status_message\": \"Passed\",\n \"result_message\": \"Passed\",\n \"started_at\": \"2018-05-04T18:12:31Z\",\n \"finished_at\": \"2018-05-04T18:14:52Z\",\n \"duration\": 141,\n \"build_url\": \"https:\\/\\/travis-ci.org\\/dpritchett\\/ruby-bookbot\\/builds\\/375009707\",\n \"commit_id\": 112084793,\n \"commit\": \"7379b6e92f7dc9328953d03d207732852c6e9401\",\n \"base_commit\": \"7379b6e92f7dc9328953d03d207732852c6e9401\",\n \"head_commit\": null,\n \"branch\": \"master\",\n \"message\": \"Trying out some travis magic\",\n \"compare_url\": \"https:\\/\\/github.com\\/dpritchett\\/ruby-bookbot\\/compare\\/632250aff63e...7379b6e92f7d\",\n \"committed_at\": \"2018-05-04T18:12:21Z\",\n \"author_name\": \"Daniel J. Pritchett\",\n \"author_email\": \"dpritchett@gmail.com\",\n \"committer_name\": \"Daniel J. Pritchett\",\n \"committer_email\": \"dpritchett@gmail.com\",\n \"pull_request\": false,\n \"pull_request_number\": null,\n \"pull_request_title\": null,\n \"tag\": null,\n \"repository\": {\n \"id\": 12787622,\n \"name\": \"ruby-bookbot\",\n \"owner_name\": \"dpritchett\",\n \"url\": null\n },\n \"matrix\": [\n {\n \"id\": 375009708,\n \"repository_id\": 12787622,\n \"parent_id\": 375009707,\n \"number\": \"55.1\",\n \"state\": \"passed\",\n \"config\": {\n \"os\": \"linux\",\n \"rvm\": \"2.3.3\",\n \"dist\": \"trusty\",\n \"group\": \"stable\",\n \".result\": \"configured\",\n \"language\": \"ruby\",\n \"services\": [\n \"redis-server\"\n ],\n \"notifications\": {\n \"webhooks\": [\n \"http:\\/\\/bookbot.pritchettbots.com\\/shipit\\/travis\",\n \"http:\\/\\/7c7e83e9.ngrok.io\\/shipit\\/travis\"\n ]\n }\n },\n \"status\": 0,\n \"result\": 0,\n \"commit\": \"7379b6e92f7dc9328953d03d207732852c6e9401\",\n \"branch\": \"master\",\n \"message\": \"Trying out some travis magic\",\n \"compare_url\": \"https:\\/\\/github.com\\/dpritchett\\/ruby-bookbot\\/compare\\/632250aff63e...7379b6e92f7d\",\n \"started_at\": null,\n \"finished_at\": null,\n \"committed_at\": \"2018-05-04T18:12:21Z\",\n \"author_name\": \"Daniel J. Pritchett\",\n \"author_email\": \"dpritchett@gmail.com\",\n \"committer_name\": \"Daniel J. Pritchett\",\n \"committer_email\": \"dpritchett@gmail.com\",\n \"allow_failure\": false\n }\n ]\n}\n",
43
+ "description": "",
44
+ "type": "text"
45
+ }
46
+ ]
47
+ },
48
+ "description": "We did it!"
49
+ },
50
+ "response": []
51
+ }
52
+ ]
53
+ }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lita-travis-announcer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel J. Pritchett
@@ -116,6 +116,7 @@ files:
116
116
  - spec/fixtures/travis_success.json
117
117
  - spec/lita/handlers/travis_announcer_spec.rb
118
118
  - spec/lita/travis_webhook_spec.rb
119
+ - spec/postman/lita-travis-hooks-dev.postman_collection
119
120
  - spec/spec_helper.rb
120
121
  - templates/.gitkeep
121
122
  homepage: https://github.com/dpritchett/lita-travis-announcer
@@ -148,4 +149,5 @@ test_files:
148
149
  - spec/fixtures/travis_success.json
149
150
  - spec/lita/handlers/travis_announcer_spec.rb
150
151
  - spec/lita/travis_webhook_spec.rb
152
+ - spec/postman/lita-travis-hooks-dev.postman_collection
151
153
  - spec/spec_helper.rb