gh-events 0.7.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +60 -0
- data/Gemfile.lock +4 -1
- data/exe/{gh-event2slack → gh-event2text} +1 -1
- data/exe/gh-events +5 -1
- data/gh-events.gemspec +1 -0
- data/lib/gh/events/{slack.rb → text.rb} +14 -8
- data/lib/gh/events/version.rb +1 -1
- data/lib/gh/events.rb +4 -2
- data/lib/hash.rb +9 -0
- data/res/events.yml +1 -1
- data/res/plain.yml +118 -0
- metadata +21 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e1cff1386c5673a98772cf99e50149162e0f010f65c8e59a6bb40779fbc10233
|
4
|
+
data.tar.gz: fede3370b5bd12f80c75a6cc4b239e324df11bbc0d970419ef4a44eab3f4a7bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 70e2bd1df73c6641d6645d40804e7526de092512fd068d02924f7d8a5966d1cb2a120a6d3e38894f77ee4cb390992dfc63b3db81c6f10c401cc620fed61b9944
|
7
|
+
data.tar.gz: 8dd77aaaed11e14dccb267a86f9ce211998cd91bb45de3c8db8f53dec76d8fbc837e45d9a4a0551489ac79a14f6e50f9f9f64ebc7e9984c789b037ceed9fd489
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# Ruby CircleCI 2.0 configuration file
|
2
|
+
#
|
3
|
+
# Check https://circleci.com/docs/2.0/language-ruby/ for more details
|
4
|
+
#
|
5
|
+
version: 2
|
6
|
+
jobs:
|
7
|
+
build:
|
8
|
+
docker:
|
9
|
+
# specify the version you desire here
|
10
|
+
- image: circleci/ruby:2.6.5
|
11
|
+
|
12
|
+
# Specify service dependencies here if necessary
|
13
|
+
# CircleCI maintains a library of pre-built images
|
14
|
+
# documented at https://circleci.com/docs/2.0/circleci-images/
|
15
|
+
# - image: circleci/postgres:9.4
|
16
|
+
|
17
|
+
working_directory: ~/repo
|
18
|
+
|
19
|
+
steps:
|
20
|
+
- checkout
|
21
|
+
|
22
|
+
# Download and cache dependencies
|
23
|
+
- restore_cache:
|
24
|
+
keys:
|
25
|
+
- v1-dependencies-{{ checksum "Gemfile.lock" }}
|
26
|
+
# fallback to using the latest cache if no exact match is found
|
27
|
+
- v1-dependencies-
|
28
|
+
|
29
|
+
- run:
|
30
|
+
name: install dependencies
|
31
|
+
command: |
|
32
|
+
gem install bundler:2.0.2
|
33
|
+
bundle install --jobs=4 --retry=3 --path vendor/bundle
|
34
|
+
|
35
|
+
- save_cache:
|
36
|
+
paths:
|
37
|
+
- ./vendor/bundle
|
38
|
+
key: v1-dependencies-{{ checksum "Gemfile.lock" }}
|
39
|
+
|
40
|
+
# run tests!
|
41
|
+
- run:
|
42
|
+
name: run tests
|
43
|
+
command: |
|
44
|
+
mkdir /tmp/test-results
|
45
|
+
TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | \
|
46
|
+
circleci tests split --split-by=timings)"
|
47
|
+
|
48
|
+
bundle exec rspec \
|
49
|
+
--format progress \
|
50
|
+
--format RspecJunitFormatter \
|
51
|
+
--out /tmp/test-results/rspec.xml \
|
52
|
+
--format progress \
|
53
|
+
$TEST_FILES
|
54
|
+
|
55
|
+
# collect reports
|
56
|
+
- store_test_results:
|
57
|
+
path: /tmp/test-results
|
58
|
+
- store_artifacts:
|
59
|
+
path: /tmp/test-results
|
60
|
+
destination: test-results
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
gh-events (0.
|
4
|
+
gh-events (0.8.0)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
@@ -21,6 +21,8 @@ GEM
|
|
21
21
|
diff-lcs (>= 1.2.0, < 2.0)
|
22
22
|
rspec-support (~> 3.9.0)
|
23
23
|
rspec-support (3.9.0)
|
24
|
+
rspec_junit_formatter (0.4.1)
|
25
|
+
rspec-core (>= 2, < 4, != 2.12.0)
|
24
26
|
|
25
27
|
PLATFORMS
|
26
28
|
ruby
|
@@ -30,6 +32,7 @@ DEPENDENCIES
|
|
30
32
|
gh-events!
|
31
33
|
rake (~> 10.0)
|
32
34
|
rspec (~> 3.0)
|
35
|
+
rspec_junit_formatter (~> 0.4)
|
33
36
|
|
34
37
|
BUNDLED WITH
|
35
38
|
2.0.2
|
data/exe/gh-events
CHANGED
@@ -6,6 +6,10 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
6
6
|
require 'gh/events'
|
7
7
|
|
8
8
|
ARGV.each do |file|
|
9
|
-
|
9
|
+
begin
|
10
|
+
type = GH::Events.typeof(File.read(file))
|
11
|
+
rescue
|
12
|
+
type = 'error'
|
13
|
+
end
|
10
14
|
puts "#{file}: #{type}"
|
11
15
|
end
|
data/gh-events.gemspec
CHANGED
@@ -38,4 +38,5 @@ Gem::Specification.new do |spec|
|
|
38
38
|
spec.add_development_dependency "bundler", "~> 2.0"
|
39
39
|
spec.add_development_dependency "rake", "~> 10.0"
|
40
40
|
spec.add_development_dependency "rspec", "~> 3.0"
|
41
|
+
spec.add_development_dependency "rspec_junit_formatter", "~> 0.4"
|
41
42
|
end
|
@@ -3,7 +3,7 @@ require 'erb'
|
|
3
3
|
require 'ostruct'
|
4
4
|
require 'json'
|
5
5
|
|
6
|
-
module GH::Events::
|
6
|
+
module GH::Events::Text
|
7
7
|
|
8
8
|
extend self
|
9
9
|
|
@@ -11,7 +11,11 @@ module GH::Events::Slack
|
|
11
11
|
# be helpful when filtering events
|
12
12
|
ASPECTS = %i[type action state]
|
13
13
|
|
14
|
-
def translate(payload)
|
14
|
+
def translate(payload, dict)
|
15
|
+
dict ||= 'plain'
|
16
|
+
|
17
|
+
templates = YAML.load_file(templates_file(dict))
|
18
|
+
|
15
19
|
event = JSON.parse(payload, object_class: OpenStruct)
|
16
20
|
type = GH::Events.typeof(event).to_s
|
17
21
|
|
@@ -38,7 +42,7 @@ module GH::Events::Slack
|
|
38
42
|
template = _result[:ts].compact.last
|
39
43
|
|
40
44
|
# if the event was set to `false` abort
|
41
|
-
|
45
|
+
return nil if template === false
|
42
46
|
|
43
47
|
# if there is no template use a default
|
44
48
|
template ||= templates['no_template']
|
@@ -46,12 +50,14 @@ module GH::Events::Slack
|
|
46
50
|
render(template, event)
|
47
51
|
end
|
48
52
|
|
49
|
-
def templates_file
|
50
|
-
File.expand_path(File.join(%w(.. .. .. .. res
|
51
|
-
|
53
|
+
def templates_file(dict)
|
54
|
+
preset = File.expand_path(File.join(%w(.. .. .. .. res) << "#{dict}.yml"), __FILE__)
|
55
|
+
return preset if File.exists?(preset)
|
56
|
+
|
57
|
+
return dict if File.exists?(dict.to_s)
|
52
58
|
|
53
|
-
|
54
|
-
|
59
|
+
warn "Could not find dict file: #{dict}"
|
60
|
+
exit(1)
|
55
61
|
end
|
56
62
|
|
57
63
|
class ErbBinding < OpenStruct
|
data/lib/gh/events/version.rb
CHANGED
data/lib/gh/events.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require "gh/events/version"
|
2
|
-
require "gh/events/
|
2
|
+
require "gh/events/text"
|
3
|
+
require 'hash'
|
3
4
|
|
4
5
|
require 'yaml'
|
5
6
|
require 'ostruct'
|
@@ -16,7 +17,8 @@ module GH
|
|
16
17
|
def typeof(payload)
|
17
18
|
payload = JSON.parse(payload) if payload.is_a?(String)
|
18
19
|
payload = payload.marshal_dump if payload.is_a?(OpenStruct)
|
19
|
-
|
20
|
+
payload = payload.deep_stringify_keys
|
21
|
+
keys = payload.keys
|
20
22
|
HEURISTICS.each do |type, characteristics|
|
21
23
|
# puts ("-" * 30) + " #{type}"
|
22
24
|
|
data/lib/hash.rb
ADDED
data/res/events.yml
CHANGED
data/res/plain.yml
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
# All refs are unified. So all events have `ref` and `ref_type`.
|
2
|
+
# Additionally all events have `type` and `stype`.
|
3
|
+
|
4
|
+
push: >-
|
5
|
+
[<%= repository.full_name %>]
|
6
|
+
<%= sender.login %> <%= forced ? 'force-' : '' %>pushed
|
7
|
+
<% if ref_type == 'branch' %><%= num = size || commits.count %> commit<%= num > 1 ? 's' : '' %> to<% end %>
|
8
|
+
<%= ref_type %> `<%= ref %>`
|
9
|
+
|
10
|
+
commit_comment: >-
|
11
|
+
[<%= repository.full_name %>]
|
12
|
+
<%= sender.login %>
|
13
|
+
commented on
|
14
|
+
commit `<%= comment.commit_id %>`>: "<%= comment.body %>"
|
15
|
+
|
16
|
+
create: >-
|
17
|
+
[<%= repository.full_name %>]
|
18
|
+
<%= sender.login %>
|
19
|
+
created
|
20
|
+
<%= ref_type %> `<%= ref %>`
|
21
|
+
|
22
|
+
delete: >-
|
23
|
+
[<%= repository.full_name %>]
|
24
|
+
<%= sender.login %>
|
25
|
+
deleted
|
26
|
+
<%= ref_type %> `<%= ref %>`
|
27
|
+
|
28
|
+
issue_comment: >-
|
29
|
+
[<%= repository.full_name %>]
|
30
|
+
<%= sender.login %>
|
31
|
+
commented
|
32
|
+
on issue "<%= issue.title %>": <%= comment.body %>
|
33
|
+
|
34
|
+
issues: >-
|
35
|
+
[<%= repository.full_name %>]
|
36
|
+
<%= sender.login %>
|
37
|
+
<%= action %>
|
38
|
+
issue "<%= issue.title %>"
|
39
|
+
|
40
|
+
issues.opened: >-
|
41
|
+
[<%= repository.full_name %>]
|
42
|
+
<%= sender.login %>
|
43
|
+
create the issue
|
44
|
+
"<%= issue.title %>": <%= repository.html_url %>
|
45
|
+
|
46
|
+
issues.labeled: >-
|
47
|
+
[<%= repository.full_name %>]
|
48
|
+
<%= sender.login %>
|
49
|
+
labeled
|
50
|
+
issue "<%= issue.title %>"
|
51
|
+
as `<%= label.name %>`
|
52
|
+
|
53
|
+
pull_request: >-
|
54
|
+
[<%= repository.full_name %>]
|
55
|
+
<%= sender.login %>
|
56
|
+
<%= action %>
|
57
|
+
PR "<%= pull_request.title %>"
|
58
|
+
|
59
|
+
pull_request.opened: >-
|
60
|
+
[<%= repository.full_name %>]
|
61
|
+
<%= sender.login %>
|
62
|
+
opened
|
63
|
+
PR <%= pull_request.title %>: <%= pull_request.body %>
|
64
|
+
|
65
|
+
pull_request.labeled: >-
|
66
|
+
[<%= repository.full_name %>]
|
67
|
+
<%= sender.login %>
|
68
|
+
labeled
|
69
|
+
PR "<%= pull_request.title %>"
|
70
|
+
as `<%= label.name %>`
|
71
|
+
|
72
|
+
pull_request_review_comment: >-
|
73
|
+
[<%= repository.full_name %>]
|
74
|
+
<%= sender.login %>
|
75
|
+
reviewed: <%= comment.body %>
|
76
|
+
|
77
|
+
star: >-
|
78
|
+
[<%= repository.full_name %>]
|
79
|
+
<%= sender.login %>
|
80
|
+
<%= action == 'created' ? 'starred' : 'unstarred' %>
|
81
|
+
<%= repository.full_name %>
|
82
|
+
(<%= repository.stargazers_count %>)
|
83
|
+
|
84
|
+
# Ignore other status udpates than CircleCI failures for the moment
|
85
|
+
status: false
|
86
|
+
|
87
|
+
status.failure: >-
|
88
|
+
[<%= repository.full_name %>]
|
89
|
+
CircleCI build failed
|
90
|
+
for commit "<%= commit.commit.message %>"
|
91
|
+
by "<%= sender.login %>"
|
92
|
+
|
93
|
+
fork: >-
|
94
|
+
[<%= repository.full_name %>]
|
95
|
+
<%= sender.login %>
|
96
|
+
forked <%= repository.full_name %>
|
97
|
+
(<%= repository.forks_count %>)
|
98
|
+
|
99
|
+
deployment: An event of type `deployment` occurred.
|
100
|
+
deployment_status: An event of type `deployment_status` occurred.
|
101
|
+
gollum: An event of type `gollum` occurred.
|
102
|
+
member: An event of type `member` occurred.
|
103
|
+
membership: An event of type `membership` occurred.
|
104
|
+
page_build: An event of type `page_build` occurred.
|
105
|
+
public: An event of type `public` occurred.
|
106
|
+
release: An event of type `release` occurred.
|
107
|
+
repository: An event of type `repository` occurred.
|
108
|
+
team_add: An event of type `team_add` occurred.
|
109
|
+
|
110
|
+
# `false` will make it end with exit code 1
|
111
|
+
watch: false
|
112
|
+
|
113
|
+
# `no_template` will be used for recognized events which have no
|
114
|
+
# template assigned.
|
115
|
+
no_template: No template for event of type `<%= type %>` (`<%= stype %>`).
|
116
|
+
|
117
|
+
# `unknown` will be used for events that could not be recognized.
|
118
|
+
unknown: "An unknown event occurred (stype: `<%= stype %>`)"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gh-events
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Phil Hofmann
|
@@ -52,15 +52,30 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec_junit_formatter
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.4'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.4'
|
55
69
|
description: Determine Github event types by their payload.
|
56
70
|
email:
|
57
71
|
- phil@200ok.ch
|
58
72
|
executables:
|
59
|
-
- gh-
|
73
|
+
- gh-event2text
|
60
74
|
- gh-events
|
61
75
|
extensions: []
|
62
76
|
extra_rdoc_files: []
|
63
77
|
files:
|
78
|
+
- ".circleci/config.yml"
|
64
79
|
- ".gitignore"
|
65
80
|
- ".rspec"
|
66
81
|
- ".ruby-version"
|
@@ -70,14 +85,16 @@ files:
|
|
70
85
|
- Rakefile
|
71
86
|
- bin/console
|
72
87
|
- bin/setup
|
73
|
-
- exe/gh-
|
88
|
+
- exe/gh-event2text
|
74
89
|
- exe/gh-events
|
75
90
|
- gh-events.gemspec
|
76
91
|
- lib/gh-events.rb
|
77
92
|
- lib/gh/events.rb
|
78
|
-
- lib/gh/events/
|
93
|
+
- lib/gh/events/text.rb
|
79
94
|
- lib/gh/events/version.rb
|
95
|
+
- lib/hash.rb
|
80
96
|
- res/events.yml
|
97
|
+
- res/plain.yml
|
81
98
|
- res/slack.yml
|
82
99
|
homepage: https://github.com/200ok-ch/gh-events
|
83
100
|
licenses: []
|