Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Follow updating test script (#502) #505

Merged
merged 15 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -238,3 +238,12 @@
[submodule "gems/json-jwt/1.16/_src"]
path = gems/json-jwt/1.16/_src
url = https://github.com/nov/json-jwt.git
[submodule "gems/web-push/3.0/_src"]
path = gems/web-push/3.0/_src
url = https://github.com/pushpad/web-push.git
[submodule "gems/octokit/8.0/_src"]
path = gems/octokit/8.0/_src
url = https://github.com/octokit/octokit.rb.git
[submodule "gems/sidekiq/7.0/_src"]
path = gems/sidekiq/7.0/_src
url = https://github.com/sidekiq/sidekiq.git
4 changes: 4 additions & 0 deletions gems/actioncable/7.1/_test/test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Write Ruby code to test the RBS.
# It is type checked by `steep check` command.

require "actioncable"
11 changes: 11 additions & 0 deletions gems/actioncable/7.1/actioncable.rbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module ActionCable
module Connection
class Base
end
end

module Channel
class Base
end
end
end
1 change: 1 addition & 0 deletions gems/octokit/8.0/_src
Submodule _src added at aa5f9a
13 changes: 13 additions & 0 deletions gems/octokit/8.0/_test/test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Write Ruby code to test the RBS.
# It is type checked by `steep check` command.

require "octokit"

# Provide authentication credentials
client = Octokit::Client.new(:access_token => 'personal_access_token')

# You can still use the username/password syntax by replacing the password value with your PAT.
# client = Octokit::Client.new(:login => 'defunkt', :password => 'personal_access_token')

# Fetch the current user
client.user
27 changes: 27 additions & 0 deletions gems/octokit/8.0/octokit.rbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
module Octokit
class Client
module Apps
def create_app_installation_access_token: (Integer installation, **untyped) -> untyped
def find_organization_installation: (String organization, **untyped) -> untyped
end

module Organizations
def organization_member?: (String | Integer org, String user, **untyped options) -> bool
end

module Users
def user: (?(Integer | String) user, ?Hash[untyped, untyped] options) -> untyped
end

include Apps
include Organizations
include Users

def initialize: (?access_token: untyped, ?api_endpoint: untyped, ?auto_paginate: untyped, ?bearer_token: untyped, ?client_id: untyped, ?client_secret: untyped, ?connection_options: untyped, ?default_media_type: untyped, ?login: untyped, ?management_console_endpoint: untyped, ?management_console_password: untyped, ?middleware: untyped, ?netrc: untyped, ?netrc_file: untyped, ?per_page: untyped, ?password: untyped, ?proxy: untyped, ?ssl_verify_mode: untyped, ?user_agent: untyped, ?web_endpoint: untyped) -> void
end

class Error < StandardError
end

def self.user: (Integer) -> untyped
end
1 change: 1 addition & 0 deletions gems/sidekiq/7.0/_src
Submodule _src added at 7df284
21 changes: 21 additions & 0 deletions gems/sidekiq/7.0/_test/test_1.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Test fundamental APIs
# Taken from: https://github.com/mperham/sidekiq/wiki/Getting-Started
class HardWorker
include Sidekiq::Job

def perform(name, count)
puts "Performing #{name} #{count} times"
end
end
HardWorker.perform_async('bob', 5)
HardWorker.perform_at(Time.now + 5*60, 'bob', 5)

class HardJob
include Sidekiq::Job

def perform(name, count)
puts "Performing #{name} #{count} times"
end
end
HardJob.perform_async('bob', 5)
HardJob.perform_at(Time.now + 5*60, 'bob', 5)
15 changes: 15 additions & 0 deletions gems/sidekiq/7.0/_test/test_1_2.rbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class HardWorker
include Sidekiq::Job
extend Sidekiq::Job::ClassMethods
end

class HardJob
include Sidekiq::Job
extend Sidekiq::Job::ClassMethods
end

class Hook
end

class Middleware
end
70 changes: 70 additions & 0 deletions gems/sidekiq/7.0/_test/test_2.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
class HardWorker
include Sidekiq::Job
end

class HardJob
include Sidekiq::Job
end

class Hook
end

class Middleware
end

HardWorker.perform_async(1, 2, 3)
HardJob.perform_async(1, 2, 3)

# Test Sidekiq::Client
client = Sidekiq::Client.new
client.middleware do |chain|
chain.add Middleware
end
Sidekiq::Client.push('class' => HardWorker, 'args' => [1, 2, 3])
Sidekiq::Client.push_bulk('class' => HardWorker, 'args' => [[1, 2, 3], [4,5,6]])
Sidekiq::Client.enqueue(HardWorker, 'foo', 1, :bat => 'bar')
Sidekiq::Client.enqueue_to(:queue_name, HardWorker, 'foo', 1, :bat => 'bar')
Sidekiq::Client.enqueue_to_in(:queue_name, Time.now + 3 * 60, HardWorker, 'foo', 1, :bat => 'bar')
Sidekiq::Client.enqueue_in(Time.now + 3 * 60, HardWorker, 'foo', 1, :bat => 'bar')

Sidekiq::Client.push('class' => HardJob, 'args' => [1, 2, 3])
Sidekiq::Client.push_bulk('class' => HardJob, 'args' => [[1, 2, 3], [4,5,6]])
Sidekiq::Client.enqueue(HardJob, 'foo', 1, :bat => 'bar')
Sidekiq::Client.enqueue_to(:queue_name, HardJob, 'foo', 1, :bat => 'bar')
Sidekiq::Client.enqueue_to_in(:queue_name, Time.now + 3 * 60, HardJob, 'foo', 1, :bat => 'bar')
Sidekiq::Client.enqueue_in(Time.now + 3 * 60, HardJob, 'foo', 1, :bat => 'bar')

# Test configuration of middleware
Sidekiq.configure_server do |config|
config.redis = { namespace: 'rails', size: 2, url: 'redis://rails:6457/0' }
config.server_middleware do |chain|
chain.add Hook
end
config.client_middleware do |chain|
chain.add Hook
end
end

# Using Redis
# Taken from: https://github.com/mperham/sidekiq/wiki/Using-Redis
Sidekiq.configure_server do |config|
config.redis = { url: 'redis://redis.example.com:7372/0', network_timeout: 5 }
end

Sidekiq.configure_client do |config|
config.redis = { url: 'redis://redis.example.com:7372/0' }
end

Sidekiq.configure_client do |config|
config.redis = { url: 'redis://redis.example.com:7372/0', size: 5 }
end

Sidekiq.configure_server do |config|
config.redis = { url: 'redis://redis.example.com:7372/0', size: 25 }
end

Sidekiq.configure_server do |config|
config.on(:shutdown) do
puts "Shutting down!"
end
end
120 changes: 120 additions & 0 deletions gems/sidekiq/7.0/_test/test_3.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
# Test error handling
# Taken from: https://github.com/mperham/sidekiq/wiki/Error-Handling
Sidekiq.configure_server do |config|
config.error_handlers << proc { |ex,ctx_hash| puts "#{ex} exception: #{ctx_hash} context" }
end

class LessRetryableWorker
include Sidekiq::Job
sidekiq_options retry: 5 # Only five retries and then to the Dead Job Queue

def perform
end
end

class LessRetryableJob
include Sidekiq::Job
sidekiq_options retry: 5 # Only five retries and then to the Dead Job Queue

def perform
end
end

class NonRetryableWorker
include Sidekiq::Job
sidekiq_options retry: false # job will be discarded if it fails

def perform
end
end

class NonRetryableJob
include Sidekiq::Job
sidekiq_options retry: false # job will be discarded if it fails

def perform
end
end

class NoDeathWorker
include Sidekiq::Job
sidekiq_options retry: 5, dead: false # will retry 5 times and then disappear

def perform
end
end

class NoDeathJob
include Sidekiq::Job
sidekiq_options retry: 5, dead: false # will retry 5 times and then disappear

def perform
end
end

class WorkerWithCustomRetry
include Sidekiq::Job
sidekiq_options retry: 5

# The current retry count and exception is yielded. The return value of the
# block must be an integer. It is used as the delay, in seconds. A return value
# of nil will use the default.
sidekiq_retry_in do |count, exception|
case exception
when Object
10 * (count + 1) # (i.e. 10, 20, 30, 40, 50)
end
end

def perform
end
end

class JobWithCustomRetry
include Sidekiq::Job
sidekiq_options retry: 5

# The current retry count and exception is yielded. The return value of the
# block must be an integer. It is used as the delay, in seconds. A return value
# of nil will use the default.
sidekiq_retry_in do |count, exception|
case exception
when Object
10 * (count + 1) # (i.e. 10, 20, 30, 40, 50)
end
end

def perform
end
end

class FailingWorker
include Sidekiq::Job

sidekiq_retries_exhausted do |msg, ex|
Sidekiq.logger.warn "Failed #{msg['class']} with #{msg['args']}: #{msg['error_message']}"
end

def perform
raise "or I don't work"
end
end

class FailingJob
include Sidekiq::Job

sidekiq_retries_exhausted do |msg, ex|
Sidekiq.logger.warn "Failed #{msg['class']} with #{msg['args']}: #{msg['error_message']}"
end

def perform
raise "or I don't work"
end
end

# this goes in your initializer
Sidekiq.configure_server do |config|
config.death_handlers << -> (job, ex) do
puts "Error!"
end
end
87 changes: 87 additions & 0 deletions gems/sidekiq/7.0/_test/test_3_4_5.rbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
class LessRetryableWorker
include Sidekiq::Job
extend Sidekiq::Job::ClassMethods
def perform: () -> void
end

class LessRetryableJob
include Sidekiq::Job
extend Sidekiq::Job::ClassMethods
def perform: () -> void
end

class NonRetryableWorker
include Sidekiq::Job
extend Sidekiq::Job::ClassMethods
def perform: () -> void
end

class NonRetryableJob
include Sidekiq::Job
extend Sidekiq::Job::ClassMethods
def perform: () -> void
end

class NoDeathWorker
include Sidekiq::Job
extend Sidekiq::Job::ClassMethods
def perform: () -> void
end

class NoDeathJob
include Sidekiq::Job
extend Sidekiq::Job::ClassMethods
def perform: () -> void
end

class WorkerWithCustomRetry
include Sidekiq::Job
extend Sidekiq::Job::ClassMethods
extend Sidekiq::Job::Options::ClassMethods
def perform: () -> void
end

class JobWithCustomRetry
include Sidekiq::Job
extend Sidekiq::Job::ClassMethods
extend Sidekiq::Job::Options::ClassMethods
def perform: () -> void
end

class FailingWorker
include Sidekiq::Job
extend Sidekiq::Job::ClassMethods
extend Sidekiq::Job::Options::ClassMethods
def perform: () -> void
end

class FailingJob
include Sidekiq::Job
extend Sidekiq::Job::ClassMethods
extend Sidekiq::Job::Options::ClassMethods
def perform: () -> void
end

class ImportantWorker
include Sidekiq::Job
extend Sidekiq::Job::ClassMethods
def perform: () -> void
end

class ImportantJob
include Sidekiq::Job
extend Sidekiq::Job::ClassMethods
def perform: () -> void
end

class YourWorker
include Sidekiq::Job
extend Sidekiq::Job::ClassMethods
def perform: () -> void
end

class YourJob
include Sidekiq::Job
extend Sidekiq::Job::ClassMethods
def perform: () -> void
end
Loading