chat_notifier 0.2.0 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -2
- data/README.md +28 -3
- data/lib/chat_notifier/chatter/slack.rb +1 -1
- data/lib/chat_notifier/version.rb +1 -1
- data/lib/chat_notifier.rb +21 -5
- data/lib/minitest/chat_notifier_plugin.rb +15 -0
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ebe5f694e93b0b1e9481da7ed105d05920bd542139d9247088d6318429f1f2ba
|
4
|
+
data.tar.gz: 62579d8a4549f2b226e13cc79e6ec638fc53f55555fc36f7cd59ad28b1cfc9ec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9bb0a22712965f884e23355247576e3808b064e7fc207a0e6edd45211b93db4434d44582aa7d0483b348e558b79f4ede2c5a93e8cc71a8244dd1a20bd2d21fca
|
7
|
+
data.tar.gz: 2e44b3715a7ee5cc0947eb19e918df746d8b61689bd77f1be4abc81dce3c043f1badf108ea775a2beea7a390ac94988b2d2d1694565e267a15fe7e6a448a0608
|
data/CHANGELOG.md
CHANGED
@@ -5,8 +5,22 @@ All notable changes to this project will be documented in this file.
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
7
|
|
8
|
-
## 0.
|
8
|
+
## [0.2.2] - 2024-09-05
|
9
9
|
|
10
10
|
### Added
|
11
11
|
|
12
|
-
-
|
12
|
+
- Test on ruby 3.3
|
13
|
+
|
14
|
+
### Fixed
|
15
|
+
|
16
|
+
- Load "chat_notifier" from the minitest plugin
|
17
|
+
|
18
|
+
## [0.2.1] - 2024-07-01
|
19
|
+
|
20
|
+
### Added
|
21
|
+
|
22
|
+
- Version and release management with reissue gem.
|
23
|
+
|
24
|
+
### Changed
|
25
|
+
|
26
|
+
- Slack chatter looks for NOTIFY_SLACK ENV variables instead of just SLACK
|
data/README.md
CHANGED
@@ -4,15 +4,21 @@ Notify a chat room with data from your test run.
|
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
7
|
-
```
|
7
|
+
```ruby
|
8
8
|
gem "chat_notifier", git: "https://github.com/SOFware/chat_notifier.git"
|
9
9
|
```
|
10
10
|
|
11
11
|
## Usage
|
12
12
|
|
13
|
+
### Minitest
|
14
|
+
|
15
|
+
Your minitest suite should pick up the formatter automatically.
|
16
|
+
|
17
|
+
### RSpec
|
18
|
+
|
13
19
|
Add to your `spec_helper.rb` or `rails_helper.rb`:
|
14
20
|
|
15
|
-
```
|
21
|
+
```ruby
|
16
22
|
require "chat_notifier/rspec_formatter"
|
17
23
|
|
18
24
|
config.add_formatter "ChatNotifier::RspecFormatter" if ENV["CI"]
|
@@ -20,7 +26,7 @@ config.add_formatter "ChatNotifier::RspecFormatter" if ENV["CI"]
|
|
20
26
|
|
21
27
|
Add to your config/application.rb within your namespaced module
|
22
28
|
|
23
|
-
```
|
29
|
+
```ruby
|
24
30
|
def self.sha
|
25
31
|
`git rev-parse --short HEAD`.chomp
|
26
32
|
end
|
@@ -39,6 +45,12 @@ Add these variables to your env files
|
|
39
45
|
NOTIFY_TEST_RUN_ID
|
40
46
|
```
|
41
47
|
|
48
|
+
If you are _not_ using Rails, you will need to add this ENV variable:
|
49
|
+
|
50
|
+
```
|
51
|
+
NOTIFY_APP_NAME
|
52
|
+
```
|
53
|
+
|
42
54
|
### Debug your Slack setup
|
43
55
|
|
44
56
|
Create rake task to test the connection to your Slack channel
|
@@ -54,6 +66,7 @@ namespace :chat_notifier do
|
|
54
66
|
ENV["DEBUG"] = "1"
|
55
67
|
ENV["NOTIFY_CURRENT_REPOSITORY_URL"] = "https://example.com"
|
56
68
|
ENV["NOTIFY_TEST_RUN_ID"] = "9999"
|
69
|
+
ENV["NOTIFY_APP_NAME"] = "Example App" # Defaults to your Rails app name
|
57
70
|
require "chat_notifier"
|
58
71
|
|
59
72
|
failure = ChatNotifier::DebugExceptionLocation.new(location: "fake/path.rb")
|
@@ -63,3 +76,15 @@ namespace :chat_notifier do
|
|
63
76
|
end
|
64
77
|
end
|
65
78
|
```
|
79
|
+
|
80
|
+
## Contributing
|
81
|
+
|
82
|
+
This gem is managed with [Reissue](https://github.com/SOFware/reissue).
|
83
|
+
|
84
|
+
Releasing a new version:
|
85
|
+
|
86
|
+
```sh
|
87
|
+
rake build:checksum
|
88
|
+
rake release
|
89
|
+
git push
|
90
|
+
```
|
data/lib/chat_notifier.rb
CHANGED
@@ -12,6 +12,18 @@ module ChatNotifier
|
|
12
12
|
DebugSummary = Data.define(:failed_examples)
|
13
13
|
|
14
14
|
class << self
|
15
|
+
require "logger"
|
16
|
+
@logger = Logger.new($stdout)
|
17
|
+
attr_accessor :logger
|
18
|
+
|
19
|
+
def app
|
20
|
+
if defined?(::Rails)
|
21
|
+
Rails.application.class.module_parent
|
22
|
+
else
|
23
|
+
ENV.fetch("NOTIFY_APP_NAME")
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
15
27
|
# In order to test this locally see `rake chat_notifier:debug`
|
16
28
|
def debug!(env, summary:, notifier: :Debug)
|
17
29
|
repository = Repository.for(env)
|
@@ -24,9 +36,9 @@ module ChatNotifier
|
|
24
36
|
)
|
25
37
|
messenger = Messenger.for(
|
26
38
|
summary,
|
27
|
-
app
|
28
|
-
repository
|
29
|
-
environment:
|
39
|
+
app:,
|
40
|
+
repository:,
|
41
|
+
environment:
|
30
42
|
)
|
31
43
|
|
32
44
|
chatter.post(messenger)
|
@@ -43,13 +55,17 @@ module ChatNotifier
|
|
43
55
|
|
44
56
|
messenger = Messenger.for(
|
45
57
|
summary,
|
46
|
-
app
|
58
|
+
app:,
|
47
59
|
repository:,
|
48
60
|
environment:
|
49
61
|
)
|
50
62
|
|
51
63
|
chatter.each do |box|
|
52
|
-
|
64
|
+
begin
|
65
|
+
box.conditional_post(messenger)
|
66
|
+
rescue => exception
|
67
|
+
logger.error("ChatNotifier: #{box.webhook_url} #{exception.class}: #{exception.message}")
|
68
|
+
end
|
53
69
|
end
|
54
70
|
end
|
55
71
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Minitest
|
2
|
+
def self.plugin_chat_notifier_init(options)
|
3
|
+
require "chat_notifier"
|
4
|
+
Minitest.reporter << ChatNotifierPlugin.new(options[:io], options)
|
5
|
+
end
|
6
|
+
|
7
|
+
class ChatNotifierPlugin < SummaryReporter
|
8
|
+
ExceptionLocation = Data.define(:location)
|
9
|
+
Summary = Data.define(:failed_examples)
|
10
|
+
def report
|
11
|
+
summary = Summary[(results.map{ |result| ExceptionLocation[result.source_location] })]
|
12
|
+
::ChatNotifier.call(summary:)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
metadata
CHANGED
@@ -1,18 +1,20 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chat_notifier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jim Gay
|
8
|
+
- Savannah Albanez
|
8
9
|
autorequire:
|
9
10
|
bindir: exe
|
10
11
|
cert_chain: []
|
11
|
-
date:
|
12
|
+
date: 2024-09-05 00:00:00.000000000 Z
|
12
13
|
dependencies: []
|
13
14
|
description: Send test results to chat
|
14
15
|
email:
|
15
16
|
- jim@saturnflyer.com
|
17
|
+
- sealbanez@gmail.com
|
16
18
|
executables: []
|
17
19
|
extensions: []
|
18
20
|
extra_rdoc_files: []
|
@@ -33,6 +35,7 @@ files:
|
|
33
35
|
- lib/chat_notifier/test_environment/debug.rb
|
34
36
|
- lib/chat_notifier/test_environment/github.rb
|
35
37
|
- lib/chat_notifier/version.rb
|
38
|
+
- lib/minitest/chat_notifier_plugin.rb
|
36
39
|
homepage:
|
37
40
|
licenses: []
|
38
41
|
metadata:
|
@@ -53,7 +56,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
53
56
|
- !ruby/object:Gem::Version
|
54
57
|
version: '0'
|
55
58
|
requirements: []
|
56
|
-
rubygems_version: 3.
|
59
|
+
rubygems_version: 3.5.9
|
57
60
|
signing_key:
|
58
61
|
specification_version: 4
|
59
62
|
summary: Notify chat of test results
|