Skip to content

Commit

Permalink
Merge pull request #25 from opensourcerouting/main
Browse files Browse the repository at this point in the history
Release 1.1.0
  • Loading branch information
RodrigoMNardi authored Oct 25, 2024
2 parents 355ff0e + 801d1d3 commit 8ec68e0
Show file tree
Hide file tree
Showing 9 changed files with 134 additions and 105 deletions.
29 changes: 9 additions & 20 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,19 @@
source 'https://rubygems.org'

gem 'activerecord', require: 'active_record'

gem 'base64', '0.1.1'

gem 'certified'
gem 'dotenv'

gem 'nio4r', '2.5.8'

gem 'otr-activerecord', '2.0.3'

gem 'pagy'
gem 'otr-activerecord'
gem 'pagy_cursor'
gem 'parser', '3.0.2.0'
gem 'pg', '1.2.3'
gem 'puma', '5.5.2'

gem 'racc', '1.5.1'
gem 'rack', '2.2.3.1'
gem 'pg'
gem 'puma'
gem 'rack'
gem 'rackup'
gem 'rubocop', '0.89.1', group: %i[development test], require: false
gem 'rubocop-ast', '0.6.0', group: %i[development test], require: false
gem 'rubocop-performance', '1.7.1', group: %i[development test], require: false

gem 'sinatra', '2.0.8.1'
gem 'slack-ruby-bot-server', '2.1.1'
gem 'slack-ruby-bot-server-events', '0.3.2'
gem 'sinatra'
gem 'slack-ruby-bot-server'
gem 'slack-ruby-bot-server-events'
gem 'slack-ruby-client'

gem 'unicode-display_width', '1.6.1'
170 changes: 96 additions & 74 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,119 +1,136 @@
GEM
remote: https://rubygems.org/
specs:
activemodel (7.0.8)
activesupport (= 7.0.8)
activerecord (7.0.8)
activemodel (= 7.0.8)
activesupport (= 7.0.8)
activesupport (7.0.8)
activemodel (7.0.8.4)
activesupport (= 7.0.8.4)
activerecord (7.0.8.4)
activemodel (= 7.0.8.4)
activesupport (= 7.0.8.4)
activesupport (7.0.8.4)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
ast (2.4.2)
async (1.31.0)
console (~> 1.10)
nio4r (~> 2.3)
timers (~> 4.1)
base64 (0.1.1)
builder (3.2.4)
concurrent-ruby (1.2.2)
console (1.23.2)
async (2.17.0)
console (~> 1.26)
fiber-annotation
fiber-local
io-event (~> 1.6, >= 1.6.5)
base64 (0.2.0)
bigdecimal (3.1.8)
certified (1.0.0)
concurrent-ruby (1.3.4)
console (1.27.0)
fiber-annotation
fiber-local (~> 1.1)
json
declarative (0.0.20)
dotenv (2.8.1)
dotenv (3.1.4)
dry-core (1.0.1)
concurrent-ruby (~> 1.0)
zeitwerk (~> 2.6)
dry-inflector (1.0.0)
dry-inflector (1.1.0)
dry-logic (1.5.0)
concurrent-ruby (~> 1.0)
dry-core (~> 1.0, < 2)
zeitwerk (~> 2.6)
dry-types (1.7.1)
dry-types (1.7.2)
bigdecimal (~> 3.0)
concurrent-ruby (~> 1.0)
dry-core (~> 1.0)
dry-inflector (~> 1.0)
dry-logic (~> 1.4)
zeitwerk (~> 2.6)
faraday (2.7.11)
base64
faraday-net_http (>= 2.0, < 3.1)
ruby2_keywords (>= 0.0.4)
faraday (2.12.0)
faraday-net_http (>= 2.0, < 3.4)
json
logger
faraday-mashify (0.1.1)
faraday (~> 2.0)
hashie
faraday-multipart (1.0.4)
multipart-post (~> 2)
faraday-net_http (3.0.2)
faraday-net_http (3.3.0)
net-http
fiber-annotation (0.2.0)
fiber-local (1.0.0)
foreman (0.87.2)
gli (2.21.1)
grape (1.8.0)
activesupport (>= 5)
builder
fiber-local (1.1.0)
fiber-storage
fiber-storage (1.0.0)
foreman (0.88.1)
gli (2.21.5)
grape (2.2.0)
activesupport (>= 6)
dry-types (>= 1.1)
mustermann-grape (~> 1.0.0)
rack (>= 1.3.0)
rack-accept
mustermann-grape (~> 1.1.0)
rack (>= 2)
zeitwerk
grape-roar (0.4.1)
grape
multi_json
roar (~> 1.1.0)
grape-swagger (1.6.1)
grape (~> 1.3)
grape-swagger (2.1.1)
grape (>= 1.7, < 3.0)
rack-test (~> 2)
hashie (5.0.0)
hashie-forbidden_attributes (0.1.1)
hashie (>= 3.0)
i18n (1.14.1)
i18n (1.14.6)
concurrent-ruby (~> 1.0)
io-event (1.7.1)
json (2.7.2)
kaminari-core (1.2.2)
kaminari-grape (1.0.1)
grape
kaminari-core (~> 1.0)
minitest (5.20.0)
logger (1.6.1)
minitest (5.25.1)
multi_json (1.15.0)
multipart-post (2.3.0)
mustermann (1.1.2)
multipart-post (2.4.1)
mustermann (3.0.3)
ruby2_keywords (~> 0.0.1)
mustermann-grape (1.0.2)
mustermann-grape (1.1.0)
mustermann (>= 1.0.0)
net-http (0.4.1)
uri
nio4r (2.5.8)
otr-activerecord (2.0.3)
activerecord (>= 4.0, < 7.1)
otr-activerecord (2.4.0)
activerecord (>= 6.0, < 7.3)
hashie-forbidden_attributes (~> 0.1)
pagy (6.2.0)
pagy_cursor (0.6.1)
pagy (8.6.3)
pagy_cursor (0.8.0)
activerecord (>= 5)
pagy (>= 6, < 7)
parallel (1.23.0)
parser (3.0.2.0)
pagy (>= 6, < 9)
parallel (1.26.3)
parser (3.3.5.0)
ast (~> 2.4.1)
racc
pg (1.2.3)
pg (1.5.8)
puma (5.5.2)
nio4r (~> 2.0)
racc (1.5.1)
rack (2.2.3.1)
rack-accept (0.4.5)
rack (>= 0.4)
rack-cors (2.0.1)
racc (1.7.3)
rack (3.1.7)
rack-cors (2.0.2)
rack (>= 2.0.0)
rack-protection (2.0.8.1)
rack
rack-protection (4.0.0)
base64 (>= 0.1.0)
rack (>= 3.0.0, < 4)
rack-rewrite (1.5.1)
rack-server-pages (0.1.0)
rack
rack-session (2.0.0)
rack (>= 3.0.0)
rack-test (2.1.0)
rack (>= 1.3)
rackup (2.1.0)
rack (>= 3)
webrick (~> 1.8)
rainbow (3.1.1)
regexp_parser (2.8.2)
regexp_parser (2.9.2)
representable (3.2.0)
declarative (< 0.1.0)
trailblazer-option (>= 0.1.1, < 0.2.0)
uber (< 0.2.0)
rexml (3.2.6)
rexml (3.3.8)
roar (1.1.1)
representable (~> 3.0)
rubocop (0.89.1)
Expand All @@ -131,10 +148,11 @@ GEM
rubocop (>= 0.82.0)
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
sinatra (2.0.8.1)
mustermann (~> 1.0)
rack (~> 2.0)
rack-protection (= 2.0.8.1)
sinatra (4.0.0)
mustermann (~> 3.0)
rack (>= 3.0.0, < 4)
rack-protection (= 4.0.0)
rack-session (>= 2.0.0, < 3)
tilt (~> 2.0)
slack-ruby-bot-server (2.1.1)
async
Expand All @@ -149,40 +167,44 @@ GEM
slack-ruby-client
slack-ruby-bot-server-events (0.3.2)
slack-ruby-bot-server (>= 0.12.0)
slack-ruby-client (2.2.0)
slack-ruby-client (2.4.0)
faraday (>= 2.0)
faraday-mashify
faraday-multipart
gli
hashie
tilt (2.3.0)
timers (4.3.5)
tilt (2.4.0)
trailblazer-option (0.1.2)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
uber (0.1.0)
unicode-display_width (1.6.1)
zeitwerk (2.6.12)
uri (0.13.1)
webrick (1.8.2)
zeitwerk (2.7.0)

PLATFORMS
ruby
x86_64-linux

DEPENDENCIES
activerecord
certified
dotenv
nio4r (= 2.5.8)
otr-activerecord (= 2.0.3)
pagy
otr-activerecord
pagy_cursor
pg (= 1.2.3)
puma (= 5.5.2)
rack (= 2.2.3.1)
pg
puma
rack
rackup
rubocop (= 0.89.1)
rubocop-ast (= 0.6.0)
rubocop-performance (= 1.7.1)
sinatra (= 2.0.8.1)
slack-ruby-bot-server (= 2.1.1)
slack-ruby-bot-server-events (= 0.3.2)
sinatra
slack-ruby-bot-server
slack-ruby-bot-server-events
slack-ruby-client
unicode-display_width (= 1.6.1)

BUNDLED WITH
2.2.22
2.5.9
2 changes: 2 additions & 0 deletions config.ru
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ require 'puma'
require './lib/slack_bot_app'
require_relative 'config/initializers/active_record_established'

use Rack::RewindableInput::Middleware

run Rack::URLMap.new('/' => SlackRubyBotServer::Api::Middleware.instance, '/github' => Server)
8 changes: 8 additions & 0 deletions lib/github_app/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ class Server < Sinatra::Base
halt 200
end

get '/translate/:name' do
user_info = Client.new.find_user_id_by_name(params[:name])

halt 404, 'User not found' unless user_info

halt 200, user_info
end

post '/comment' do
halt 401, 'Invalid user / password' unless authentication
Client.new.chat(request.body.read)
Expand Down
8 changes: 8 additions & 0 deletions lib/slack/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ def initialize
@client = Slack::Web::Client.new
end

def find_user_id_by_name(username)
user = @client.users_list.members.find { |u| u.name == username || u.display_name == username }

puts user.inspect

user ? user.id : nil
end

def chat(message, channel: fetch_channel)
@client.chat_postMessage(channel: channel,
text: message,
Expand Down
2 changes: 1 addition & 1 deletion lib/slack/slash_commands/bamboo_ci/command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module Slack
module BambooCi
class Command
COMMANDS = %w[notify subscribe settings].freeze
NOTIFY_OPTS = %w[all errors pass off].freeze
NOTIFY_OPTS = %w[all errors pass stages off].freeze

include SlackBot::Request
include Singleton
Expand Down
6 changes: 4 additions & 2 deletions lib/slack/slash_commands/bamboo_ci/help.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ module Slack
module BambooCi
class Help
TEXT = '
/ci notify <pr> [all | errors | pass | off]
/ci notify <pr> [all | errors | pass | stages | off]
<pr> is the PR number (or * for the off option)
all: All finished runs
errors: Just failed runs
pass: Just successful runs
stages: Just stages updates
off: Disable notifications
Notify on all CI runs (all) or just the CI runs with errors (errors) or only for
successful CI runs (pass)
Expand All @@ -26,11 +27,12 @@ class Help
/ci notify 6 pass
Returns a slack notification whenever the PR6 finishes running and passes all CI tests
/ci subscribe <github_name> [all | errors | pass | off]
/ci subscribe <github_name> [all | errors | pass | stages | off]
github_name is the Github Username
all: All finished runs
errors: Just failed runs
pass: Just successful runs
stages: Just stages updates
off: Disable notifications
Similar to notify, but for all CI runs for that specific Github User
Expand Down
7 changes: 3 additions & 4 deletions service/devel/server_devel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@
# frozen_string_literal: true
#

#
# SPDX-License-Identifier: BSD-2-Clause
#
# Startup script for CI Slack Bot
source "$HOME/.rvm/scripts/rvm"
rvm use 3.3.1
bundle install

echo ">> Running server"
rackup -o 0.0.0.0 -p 4681 config.ru
Loading

0 comments on commit 8ec68e0

Please sign in to comment.