waylon 0.2.0 → 0.2.2
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/Gemfile.lock +64 -27
- data/README.md +110 -7
- data/examples/deploying/helm/waylon/.helmignore +16 -0
- data/examples/deploying/helm/waylon/Chart.yaml +5 -0
- data/examples/deploying/helm/waylon/README.md +71 -0
- data/examples/deploying/helm/waylon/templates/_helpers.tpl +7 -0
- data/examples/deploying/helm/waylon/templates/redis-pv.yaml +19 -0
- data/examples/deploying/helm/waylon/templates/redis-pvc.yaml +18 -0
- data/examples/deploying/helm/waylon/templates/redis-statefulset.yaml +107 -0
- data/examples/deploying/helm/waylon/templates/web-deployment.yaml +99 -0
- data/examples/deploying/helm/waylon/templates/web-ingress.yaml +48 -0
- data/examples/deploying/helm/waylon/templates/web-service.yaml +26 -0
- data/examples/deploying/helm/waylon/templates/worker-deployment.yaml +101 -0
- data/examples/deploying/helm/waylon/values.yaml +50 -0
- data/examples/deploying/k8s/README.md +11 -0
- data/examples/deploying/k8s/redis-statefulset.yaml +86 -0
- data/examples/deploying/k8s/web-deployment.yaml +85 -0
- data/examples/deploying/k8s/web-ingress.yaml +32 -0
- data/examples/deploying/k8s/web-service.yaml +18 -0
- data/examples/deploying/k8s/worker-deployment.yaml +87 -0
- data/exe/waylon +283 -0
- data/scripts/test.sh +2 -0
- data/waylon.gemspec +2 -1
- metadata +34 -2
data/exe/waylon
CHANGED
@@ -7,7 +7,290 @@ logger = Logger.new($stdout)
|
|
7
7
|
logger.level = Logger::INFO
|
8
8
|
action = ARGV[0]
|
9
9
|
|
10
|
+
def validate_project_name(name)
|
11
|
+
name.downcase =~ /^[a-z][a-z0-9_-]+$/
|
12
|
+
end
|
13
|
+
|
14
|
+
def rubocop_template
|
15
|
+
<<~TEMPLATE
|
16
|
+
AllCops:
|
17
|
+
TargetRubyVersion: 3.1
|
18
|
+
NewCops: enable
|
19
|
+
|
20
|
+
Style/StringLiterals:
|
21
|
+
Enabled: true
|
22
|
+
EnforcedStyle: double_quotes
|
23
|
+
|
24
|
+
Style/StringLiteralsInInterpolation:
|
25
|
+
Enabled: true
|
26
|
+
EnforcedStyle: double_quotes
|
27
|
+
|
28
|
+
Layout/LineLength:
|
29
|
+
Max: 120
|
30
|
+
TEMPLATE
|
31
|
+
end
|
32
|
+
|
33
|
+
def ruby_version_template
|
34
|
+
"3.1.2\n"
|
35
|
+
end
|
36
|
+
|
37
|
+
def dockerfile_template
|
38
|
+
<<~TEMPLATE
|
39
|
+
FROM ruby:3.1
|
40
|
+
|
41
|
+
RUN mkdir -p /app
|
42
|
+
|
43
|
+
COPY config.ru /app/
|
44
|
+
COPY Gemfile.lock /app/
|
45
|
+
COPY plugins.rb /app/
|
46
|
+
|
47
|
+
RUN apt update && apt upgrade -y && apt install -y curl libsodium-dev
|
48
|
+
RUN useradd waylon -d /app -M -c "Waylon Bot User"
|
49
|
+
|
50
|
+
USER waylon
|
51
|
+
WORKDIR /app
|
52
|
+
RUN gem install waylon
|
53
|
+
|
54
|
+
ENTRYPOINT ["waylon"]
|
55
|
+
TEMPLATE
|
56
|
+
end
|
57
|
+
|
58
|
+
def bot_gemfile_template
|
59
|
+
<<~TEMPLATE
|
60
|
+
# frozen_string_literal: true
|
61
|
+
|
62
|
+
source "https://rubygems.org"
|
63
|
+
|
64
|
+
require_relative "plugins"
|
65
|
+
gem "waylon"
|
66
|
+
|
67
|
+
Plugins.plugins.each_key do |gem_name|
|
68
|
+
gem gem_name
|
69
|
+
end
|
70
|
+
TEMPLATE
|
71
|
+
end
|
72
|
+
|
73
|
+
def bot_rakefile_template
|
74
|
+
<<~TEMPLATE
|
75
|
+
# frozen_string_literal: true
|
76
|
+
|
77
|
+
require "resque/tasks"
|
78
|
+
require "waylon"
|
79
|
+
|
80
|
+
task "resque:setup" do
|
81
|
+
require_relative "plugins"
|
82
|
+
|
83
|
+
Waylon::Config.instance.load_env
|
84
|
+
|
85
|
+
Plugins.plugins.each_value do |plugin|
|
86
|
+
require plugin
|
87
|
+
end
|
88
|
+
Resque.redis = ENV.fetch("REDIS", "localhost:6379")
|
89
|
+
Resque.logger = Waylon::Logger.logger
|
90
|
+
end
|
91
|
+
TEMPLATE
|
92
|
+
end
|
93
|
+
|
94
|
+
def skill_rakefile_template
|
95
|
+
<<~TEMPLATE
|
96
|
+
# frozen_string_literal: true
|
97
|
+
|
98
|
+
require "bundler/gem_tasks"
|
99
|
+
require "rspec/core/rake_task"
|
100
|
+
require "rubocop/rake_task"
|
101
|
+
require "redis/errors"
|
102
|
+
require "resque/tasks"
|
103
|
+
require "yard"
|
104
|
+
require "waylon/core"
|
105
|
+
|
106
|
+
RSpec::Core::RakeTask.new(:spec)
|
107
|
+
RuboCop::RakeTask.new
|
108
|
+
YARD::Rake::YardocTask.new do |y|
|
109
|
+
y.options = [
|
110
|
+
"--markup", "markdown"
|
111
|
+
]
|
112
|
+
end
|
113
|
+
|
114
|
+
task default: %i[spec rubocop yard]
|
115
|
+
|
116
|
+
task :demo do
|
117
|
+
require_relative "lib/waylon/skills/#{@project_name}"
|
118
|
+
Waylon::Logger.logger = ::Logger.new("/dev/null")
|
119
|
+
Waylon::Cache.storage = Moneta.new(:Cookie)
|
120
|
+
Waylon::Storage.storage = Moneta.new(:Cookie)
|
121
|
+
require "waylon/rspec/test_server"
|
122
|
+
end
|
123
|
+
TEMPLATE
|
124
|
+
end
|
125
|
+
|
126
|
+
def skill_skeleton_template
|
127
|
+
<<~TEMPLATE
|
128
|
+
# frozen_string_literal: true
|
129
|
+
|
130
|
+
module Waylon
|
131
|
+
module Skills
|
132
|
+
# A Waylon Skill
|
133
|
+
class #{@project_name.capitalize} < Waylon::Skill
|
134
|
+
route(
|
135
|
+
/#{@project_name}/i,
|
136
|
+
:do_the_thing,
|
137
|
+
help: {
|
138
|
+
usage: "FILL IN HOW TO USE THIS",
|
139
|
+
description: "EXPLAIN WHAT THIS DOES"
|
140
|
+
},
|
141
|
+
mention_only: true # this means your message must mention Waylon
|
142
|
+
)
|
143
|
+
|
144
|
+
def do_the_thing
|
145
|
+
# TODO: Fill this in...
|
146
|
+
|
147
|
+
# Some example capabilities:
|
148
|
+
#
|
149
|
+
# react :wave
|
150
|
+
#
|
151
|
+
# That will react to a chat message, assuming the Sense supports reactions
|
152
|
+
|
153
|
+
# If you need access to the message, use this:
|
154
|
+
#
|
155
|
+
# tokens
|
156
|
+
#
|
157
|
+
# It provides an Array, with `tokens[0]` being the entire message
|
158
|
+
|
159
|
+
# To send a message back, use:
|
160
|
+
#
|
161
|
+
# reply "some message"
|
162
|
+
#
|
163
|
+
# You could also reply in a thread:
|
164
|
+
#
|
165
|
+
# threaded_reply "this is a response in a thread!"
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
170
|
+
TEMPLATE
|
171
|
+
end
|
172
|
+
|
173
|
+
def config_ru_template
|
174
|
+
<<~TEMPLATE
|
175
|
+
# frozen_string_literal: true
|
176
|
+
|
177
|
+
require_relative "plugins"
|
178
|
+
|
179
|
+
require "waylon"
|
180
|
+
require "waylon/services/ping"
|
181
|
+
|
182
|
+
Plugins.plugins.each_value do |plugin|
|
183
|
+
require plugin
|
184
|
+
end
|
185
|
+
|
186
|
+
use Rack::ShowExceptions
|
187
|
+
|
188
|
+
Waylon::Config.instance.load_env
|
189
|
+
|
190
|
+
services = {
|
191
|
+
"/ping" => Waylon::Services::Ping.new
|
192
|
+
}
|
193
|
+
run Rack::URLMap.new(
|
194
|
+
services.merge(Waylon::WebhookRegistry.instance.to_hash)
|
195
|
+
)
|
196
|
+
TEMPLATE
|
197
|
+
end
|
198
|
+
|
199
|
+
def plugins_rb_template
|
200
|
+
<<~TEMPLATE
|
201
|
+
# frozen_string_literal: true
|
202
|
+
|
203
|
+
# Used to help package up the plugins you'd like to load for Waylon
|
204
|
+
module Plugins
|
205
|
+
# Should return a Hash like:
|
206
|
+
# { "waylon-plugin-gem" => "waylon/plugin/gem" }
|
207
|
+
#
|
208
|
+
# Where "waylon-plugin-gem" is the name of the gem to install and
|
209
|
+
# "waylon/plugin/gem" is what you `require` to use it
|
210
|
+
|
211
|
+
def self.plugins
|
212
|
+
{
|
213
|
+
# Choose a Sense plugin to send messages to your bot
|
214
|
+
# Read more about this plugin here: https://github.com/jgnagy/waylon-slack
|
215
|
+
"waylon-slack" => "waylon/slack",
|
216
|
+
|
217
|
+
# Add some Skill plugins to let your bot do things
|
218
|
+
# Read more about this plugin here: https://github.com/jgnagy/waylon-dice
|
219
|
+
"waylon-dice" => "waylon/dice"
|
220
|
+
}
|
221
|
+
end
|
222
|
+
end
|
223
|
+
TEMPLATE
|
224
|
+
end
|
225
|
+
|
226
|
+
def bot_template_mapping
|
227
|
+
{
|
228
|
+
config_ru_template: "config.ru",
|
229
|
+
dockerfile_template: "Dockerfile",
|
230
|
+
gemfile_template: "Gemfile",
|
231
|
+
plugins_rb_template: "plugins.rb",
|
232
|
+
bot_rakefile_template: "Rakefile",
|
233
|
+
rubocop_template: ".rubocop.yml",
|
234
|
+
ruby_version_template: ".ruby-version"
|
235
|
+
}
|
236
|
+
end
|
237
|
+
|
238
|
+
def skill_template_mapping(project_name)
|
239
|
+
{
|
240
|
+
skill_rakefile_template: "Rakefile",
|
241
|
+
rubocop_template: ".rubocop.yml",
|
242
|
+
ruby_version_template: ".ruby-version",
|
243
|
+
skill_skeleton_template: "lib/waylon/skills/#{project_name}.rb"
|
244
|
+
}
|
245
|
+
end
|
246
|
+
|
10
247
|
case action
|
248
|
+
when "init"
|
249
|
+
project_name = ARGV[1]
|
250
|
+
unless project_name
|
251
|
+
logger.fatal "Missing Project Name for new bot!"
|
252
|
+
exit 1
|
253
|
+
end
|
254
|
+
|
255
|
+
unless validate_project_name(project_name)
|
256
|
+
logger.fatal "Invalid Project Name: #{project_name}"
|
257
|
+
exit 2
|
258
|
+
end
|
259
|
+
|
260
|
+
logger.info "Initializing new Waylon bot project '#{project_name}'..."
|
261
|
+
system("git init #{project_name}")
|
262
|
+
Dir.chdir(project_name) do
|
263
|
+
bot_template_mapping.each do |func, file|
|
264
|
+
logger.info "Rendering #{File.expand_path(File.join(project_name, file))}"
|
265
|
+
File.write(file, send(func))
|
266
|
+
end
|
267
|
+
end
|
268
|
+
logger.info "Done!"
|
269
|
+
when "skill"
|
270
|
+
project_name = ARGV[1]
|
271
|
+
unless project_name
|
272
|
+
logger.fatal "Missing Project Name for new Skill plugin!"
|
273
|
+
exit 1
|
274
|
+
end
|
275
|
+
|
276
|
+
unless validate_project_name(project_name)
|
277
|
+
logger.fatal "Invalid Skill Name: #{project_name}"
|
278
|
+
exit 2
|
279
|
+
end
|
280
|
+
|
281
|
+
gem_name = project_name.start_with?("waylon-") ? project_name : "waylon-#{project_name}"
|
282
|
+
@project_name = project_name # for rendering templates
|
283
|
+
|
284
|
+
logger.info "Initializing new Waylon Skill plugin '#{gem_name}'..."
|
285
|
+
system("bundle gem --test=rspec --no-exe #{gem_name}")
|
286
|
+
Dir.chdir(gem_name) do
|
287
|
+
FileUtils.mkdir_p("lib/waylon/skills")
|
288
|
+
skill_template_mapping(project_name).each do |func, file|
|
289
|
+
logger.info "Rendering #{File.expand_path(File.join(gem_name, file))}"
|
290
|
+
File.write(file, send(func))
|
291
|
+
end
|
292
|
+
end
|
293
|
+
logger.info "Done!"
|
11
294
|
when "worker"
|
12
295
|
logger.info "Starting Worker..."
|
13
296
|
ENV["INTERVAL"] ||= "0.5"
|
data/scripts/test.sh
CHANGED
data/waylon.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module Waylon
|
4
4
|
# Update this to match the desired Waylon::Core::VERSION to release
|
5
|
-
VERSION = "0.2.
|
5
|
+
VERSION = "0.2.2"
|
6
6
|
end
|
7
7
|
|
8
8
|
Gem::Specification.new do |spec|
|
@@ -39,5 +39,6 @@ Gem::Specification.new do |spec|
|
|
39
39
|
spec.add_development_dependency "rubocop-rake", "~> 0.6"
|
40
40
|
spec.add_development_dependency "rubocop-rspec", "~> 2.6"
|
41
41
|
spec.add_development_dependency "simplecov", "~> 0.21"
|
42
|
+
spec.add_development_dependency "solargraph", "~> 0.45"
|
42
43
|
spec.add_development_dependency "yard", "~> 0.9", ">= 0.9.27"
|
43
44
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: waylon
|
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
|
- Jonathan Gnagy
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-08-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -122,6 +122,20 @@ dependencies:
|
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0.21'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: solargraph
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0.45'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0.45'
|
125
139
|
- !ruby/object:Gem::Dependency
|
126
140
|
name: yard
|
127
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -162,6 +176,24 @@ files:
|
|
162
176
|
- README.md
|
163
177
|
- Rakefile
|
164
178
|
- bin/setup
|
179
|
+
- examples/deploying/helm/waylon/.helmignore
|
180
|
+
- examples/deploying/helm/waylon/Chart.yaml
|
181
|
+
- examples/deploying/helm/waylon/README.md
|
182
|
+
- examples/deploying/helm/waylon/templates/_helpers.tpl
|
183
|
+
- examples/deploying/helm/waylon/templates/redis-pv.yaml
|
184
|
+
- examples/deploying/helm/waylon/templates/redis-pvc.yaml
|
185
|
+
- examples/deploying/helm/waylon/templates/redis-statefulset.yaml
|
186
|
+
- examples/deploying/helm/waylon/templates/web-deployment.yaml
|
187
|
+
- examples/deploying/helm/waylon/templates/web-ingress.yaml
|
188
|
+
- examples/deploying/helm/waylon/templates/web-service.yaml
|
189
|
+
- examples/deploying/helm/waylon/templates/worker-deployment.yaml
|
190
|
+
- examples/deploying/helm/waylon/values.yaml
|
191
|
+
- examples/deploying/k8s/README.md
|
192
|
+
- examples/deploying/k8s/redis-statefulset.yaml
|
193
|
+
- examples/deploying/k8s/web-deployment.yaml
|
194
|
+
- examples/deploying/k8s/web-ingress.yaml
|
195
|
+
- examples/deploying/k8s/web-service.yaml
|
196
|
+
- examples/deploying/k8s/worker-deployment.yaml
|
165
197
|
- exe/waylon
|
166
198
|
- lib/waylon.rb
|
167
199
|
- scripts/release.sh
|