quintocumber 1.1.4 → 1.1.5
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 +4 -4
- data/.gitignore +4 -0
- data/lib/plugins/publish_reports.rb +55 -2
- data/lib/quintocumber/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f286f29c0794ce5ba2c73c68f0ebc5affda82b35
|
4
|
+
data.tar.gz: 8638379409f533461b03352caac6df3617eff085
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa083be43ee100b8a291ae0b9c7fcde99741f0f690ad3b01884c5569f73afc18acef044c90203f95338e63dd14eaa64552cbe80dabff357c9de56c53433aa217
|
7
|
+
data.tar.gz: 81717c9ee1ac57df4405c6ff07a8034c5d2cc2d430602ac332d7089a36ee2e557a38e9c36b42ae9f3855f62c7fcebafa57f180090602fe5d50f7475a80074ded
|
data/.gitignore
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'httparty'
|
4
4
|
require 'aws-sdk'
|
5
|
+
require 'json'
|
5
6
|
|
6
7
|
tests_failed = []
|
7
8
|
|
@@ -9,7 +10,7 @@ def pagerduty_payload(failed_length, reports_list_str)
|
|
9
10
|
{
|
10
11
|
payload: {
|
11
12
|
summary: failed_length.to_s + " #{PROJECT_NAME} test(s) failed",
|
12
|
-
source:
|
13
|
+
source: PROJECT_NAME.to_s,
|
13
14
|
severity: 'critical',
|
14
15
|
custom_details: "Failed test(s):\n- #{reports_list_str}"
|
15
16
|
},
|
@@ -75,8 +76,60 @@ def report_to_pagerduty(report_url, tests_failed)
|
|
75
76
|
body: payload.to_json
|
76
77
|
end
|
77
78
|
|
79
|
+
def notify_slack(webhook_url, payload)
|
80
|
+
HTTParty.post webhook_url.to_s,
|
81
|
+
headers: { 'Content-Type' => 'application/json' },
|
82
|
+
body: payload.to_json
|
83
|
+
end
|
84
|
+
|
85
|
+
def slack_text(report_url, tests_failed)
|
86
|
+
txt = if tests_failed.empty?
|
87
|
+
'Success! All tests passed.'
|
88
|
+
else
|
89
|
+
"Failure! There are #{tests_failed.length} failed tests: "\
|
90
|
+
"\n\t#{tests_failed.join("\n\t")}"\
|
91
|
+
end
|
92
|
+
txt
|
93
|
+
end
|
94
|
+
|
95
|
+
def slack_pretext(report_url)
|
96
|
+
pretext = if report_url
|
97
|
+
"Full report at #{report_url}"
|
98
|
+
else
|
99
|
+
'Report was not published.'
|
100
|
+
end
|
101
|
+
pretext
|
102
|
+
end
|
103
|
+
|
104
|
+
def slack_color(tests_failed)
|
105
|
+
color = if tests_failed.empty?
|
106
|
+
'good'
|
107
|
+
else
|
108
|
+
'danger'
|
109
|
+
end
|
110
|
+
color
|
111
|
+
end
|
112
|
+
|
113
|
+
def slack_payload(report_url, tests_failed)
|
114
|
+
{
|
115
|
+
attachments: [
|
116
|
+
pretext: slack_pretext(report_url),
|
117
|
+
text: slack_text(report_url, tests_failed),
|
118
|
+
color: slack_color(tests_failed)
|
119
|
+
]
|
120
|
+
}
|
121
|
+
end
|
122
|
+
|
123
|
+
def report_to_slack(report_url, tests_failed)
|
124
|
+
return unless ENV['SLACK_WEBHOOK_URL']
|
125
|
+
puts 'Sending test report link to Slack'
|
126
|
+
payload = slack_payload(report_url, tests_failed)
|
127
|
+
notify_slack(ENV['SLACK_WEBHOOK_URL'], payload)
|
128
|
+
end
|
129
|
+
|
78
130
|
at_exit do
|
79
131
|
report_url = generate_report_and_upload_to_s3
|
80
|
-
puts "Report url: #{report_url}"
|
132
|
+
puts "Report url: #{report_url}" if report_url
|
133
|
+
report_to_slack(report_url, tests_failed)
|
81
134
|
report_to_pagerduty(report_url, tests_failed)
|
82
135
|
end
|
data/lib/quintocumber/version.rb
CHANGED