Skip to content

Commit

Permalink
Merge pull request #265 from joshbuker/update/version-requirements
Browse files Browse the repository at this point in the history
Update Version Requirements to resolve CircleCI failures
  • Loading branch information
swarley authored Jun 23, 2024
2 parents 913710f + 0049d22 commit f2a313b
Show file tree
Hide file tree
Showing 17 changed files with 134 additions and 36 deletions.
22 changes: 11 additions & 11 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ commands:
steps:
- run:
name: Install OS packages
command: apk add git build-base ruby-dev ruby-etc ruby-json libsodium
command: apk add git build-base ruby-dev ruby-etc ruby-json libsodium-dev
- checkout
- run:
name: "Ruby version"
Expand All @@ -27,9 +27,9 @@ commands:
- ./vendor/bundle

jobs:
test_ruby_27:
test_ruby_31:
docker:
- image: ruby:2.7-alpine
- image: ruby:3.1-alpine
steps:
- setup-env
- run:
Expand All @@ -38,9 +38,9 @@ jobs:
- store_test_results:
path: ~/rspec

test_ruby_30:
test_ruby_32:
docker:
- image: ruby:3.0-alpine
- image: ruby:3.2-alpine
steps:
- setup-env
- run:
Expand All @@ -50,9 +50,9 @@ jobs:
path: ~/rspec


test_ruby_31:
test_ruby_33:
docker:
- image: ruby:3.1-alpine
- image: ruby:3.3-alpine
steps:
- setup-env
- run:
Expand All @@ -61,7 +61,7 @@ jobs:

rubocop:
docker:
- image: ruby:2.7-alpine
- image: ruby:3.3-alpine
steps:
- setup-env
- run:
Expand All @@ -70,7 +70,7 @@ jobs:

yard:
docker:
- image: ruby:2.7-alpine
- image: ruby:3.3-alpine
steps:
- setup-env
- attach_workspace:
Expand Down Expand Up @@ -125,9 +125,9 @@ jobs:
workflows:
test:
jobs:
- test_ruby_27
- test_ruby_30
- test_ruby_31
- test_ruby_32
- test_ruby_33
- rubocop
- yard
deploy:
Expand Down
13 changes: 13 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Which Ruby version to use. You may need to use a more restrictive version,
# e.g. `3.0`
ARG VARIANT=3.3

# Pull Microsoft's ruby devcontainer base image
FROM mcr.microsoft.com/devcontainers/ruby:${VARIANT}

# Install libsodium dependency for voice channel interactions
RUN apt update -yq && apt install -y libsodium-dev

# Ensure we're running the latest bundler, as what ships with the Ruby image may
# not be current, and bundler will auto-downgrade to match the Gemfile.lock
RUN gem install bundler
29 changes: 29 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "Ruby",
"build": {
"dockerfile": "Dockerfile"
},

// Configure tool-specific properties.
"customizations": {
// Configure properties specific to VS Code.
"vscode": {
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"shopify.ruby-lsp"
]
}
},

// Set the environment variables
// "runArgs": ["--env-file",".env"],

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "bash .devcontainer/postcreate.sh",

// Set `remoteUser` to `root` to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"
}
4 changes: 4 additions & 0 deletions .devcontainer/postcreate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

bundle config set path vendor/bundle
bundle install --jobs=1
52 changes: 51 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ inherit_mode:

AllCops:
NewCops: enable
TargetRubyVersion: 2.7
TargetRubyVersion: 3.3

# Disable line length checks
Layout/LineLength:
Expand Down Expand Up @@ -66,3 +66,53 @@ Style/SingleLineBlockParams:
Methods:
- reduce: [m, e]
- inject: [m, e]

###################################
## NEW COPS TO MAKE DECISIONS ON ##
###################################

# TODO: Decide how you want to handle this:
# https://rubydoc.info/gems/rubocop/RuboCop/Cop/Style/HashSyntax
Style/HashSyntax:
EnforcedShorthandSyntax: either

Style/ArgumentsForwarding:
Enabled: false

Performance/StringIdentifierArgument:
Enabled: false

Style/ComparableClamp:
Enabled: false

Style/SuperArguments:
Enabled: false

Naming/BlockForwarding:
Enabled: false

Style/RedundantSelfAssignmentBranch:
Enabled: false

Performance/MapCompact:
Enabled: false

Gemspec/RequiredRubyVersion:
Enabled: false

Gemspec/DevelopmentDependencies:
Enabled: false

Style/RedundantReturn:
Enabled: false

Style/RedundantParentheses:
Enabled: false

# This will probably be a breaking change, but should happen
Style/ReturnNilInPredicateMethodDefinition:
Enabled: false

# FIXME: Disabled due to breaking tests, should probably refactor the code instead
Style/SafeNavigation:
Enabled: false
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ If you enjoy using the library, consider getting involved with the community to

## Dependencies

* Ruby >= 2.7 supported
* Ruby >= 3.1 supported
* An installed build system for native extensions (on Windows, make sure you download the "Ruby+Devkit" version of [RubyInstaller](https://rubyinstaller.org/downloads/))

### Voice dependencies
Expand Down
2 changes: 1 addition & 1 deletion discordrb-webhooks.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Gem::Specification.new do |spec|

spec.add_dependency 'rest-client', '>= 2.0.0'

spec.required_ruby_version = '>= 2.7'
spec.required_ruby_version = '>= 3.1'
spec.metadata = {
'rubygems_mfa_required' => 'true'
}
Expand Down
21 changes: 12 additions & 9 deletions discordrb.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ Gem::Specification.new do |spec|
spec.bindir = 'exe'
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.metadata = {
'bug_tracker_uri' => 'https://github.com/shardlab/discordrb/issues',
'changelog_uri' => 'https://github.com/shardlab/discordrb/blob/main/CHANGELOG.md',
'documentation_uri' => 'https://github.com/shardlab/discordrb/wiki',
'source_code_uri' => 'https://github.com/shardlab/discordrb',
'rubygems_mfa_required' => 'true'
}
spec.require_paths = ['lib']
Expand All @@ -31,17 +34,17 @@ Gem::Specification.new do |spec|

spec.add_dependency 'discordrb-webhooks', '~> 3.5.0'

spec.required_ruby_version = '>= 2.7'
spec.required_ruby_version = '>= 3.1'

spec.add_development_dependency 'bundler', '>= 1.10', '< 3'
spec.add_development_dependency 'rake', '~> 13.0'
spec.add_development_dependency 'redcarpet', '~> 3.5.0' # YARD markdown formatting
spec.add_development_dependency 'rspec', '~> 3.11.0'
spec.add_development_dependency 'rspec_junit_formatter', '~> 0.5.1'
spec.add_development_dependency 'rspec-prof', '~> 0.0.7'
spec.add_development_dependency 'rubocop', '~> 1.36.0'
spec.add_development_dependency 'redcarpet', '~> 3.5' # YARD markdown formatting
spec.add_development_dependency 'rspec', '~> 3.0'
spec.add_development_dependency 'rspec_junit_formatter', '~> 0.5'
spec.add_development_dependency 'rspec-prof', '~> 0.0'
spec.add_development_dependency 'rubocop', '~> 1.0'
spec.add_development_dependency 'rubocop-performance', '~> 1.0'
spec.add_development_dependency 'rubocop-rake', '~> 0.6.0'
spec.add_development_dependency 'simplecov', '~> 0.21.0'
spec.add_development_dependency 'yard', '~> 0.9.9'
spec.add_development_dependency 'rubocop-rake', '~> 0.6'
spec.add_development_dependency 'simplecov', '~> 0.21'
spec.add_development_dependency 'yard', '~> 0.9'
end
3 changes: 1 addition & 2 deletions lib/discordrb/bot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

require 'rest-client'
require 'zlib'
require 'set'

require 'discordrb/events/message'
require 'discordrb/events/typing'
Expand Down Expand Up @@ -1700,7 +1699,7 @@ def call_event(handler, event)

def handle_awaits(event)
@awaits ||= {}
@awaits.each do |_, await|
@awaits.each_value do |await|
key, should_delete = await.match(event)
next unless key

Expand Down
2 changes: 1 addition & 1 deletion lib/discordrb/commands/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def execute_bare(event)
escaped = false
hacky_delim, hacky_space, hacky_prev, hacky_newline = [0xe001, 0xe002, 0xe003, 0xe004].pack('U*').chars

@chain.each_char.each_with_index do |char, index|
@chain.each_char.with_index do |char, index|
# Escape character
if char == '\\' && !escaped
escaped = true
Expand Down
2 changes: 1 addition & 1 deletion lib/discordrb/data/emoji.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def initialize(data, bot, server = nil)

@name = data['name']
@server = server
@id = data['id'].nil? ? nil : data['id'].to_i
@id = data['id']&.to_i
@animated = data['animated']

process_roles(data['roles']) if server
Expand Down
2 changes: 1 addition & 1 deletion lib/discordrb/data/member.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def initialize(data, server, bot)
@bot = bot

@user = bot.ensure_user(data['user'])
super @user # Initialize the delegate class
super(@user) # Initialize the delegate class

@server = server
@server_id = server&.id || data['guild_id'].to_i
Expand Down
2 changes: 1 addition & 1 deletion lib/discordrb/data/message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def respond(content, tts = false, embed = nil, attachments = nil, allowed_mentio
# @return [Message] the resulting message.
def edit(new_content, new_embeds = nil, new_components = nil)
new_embeds = (new_embeds.instance_of?(Array) ? new_embeds.map(&:to_hash) : [new_embeds&.to_hash]).compact
new_components = new_components&.to_a || []
new_components = new_components.to_a

response = API::Channel.edit_message(@bot.token, @channel.id, @id, new_content, [], new_embeds, new_components)
Message.new(JSON.parse(response), @bot)
Expand Down
2 changes: 1 addition & 1 deletion lib/discordrb/data/reaction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Reaction
def initialize(data)
@count = data['count']
@me = data['me']
@id = data['emoji']['id'].nil? ? nil : data['emoji']['id'].to_i
@id = data['emoji']['id']&.to_i
@name = data['emoji']['name']
end

Expand Down
2 changes: 1 addition & 1 deletion lib/discordrb/data/recipient.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def initialize(user, channel, bot)
raise ArgumentError, 'Tried to create a recipient for a public channel!' unless @channel.private?

@user = user
super @user
super(@user)

# Member attributes
@mute = @deaf = @self_mute = @self_deaf = false
Expand Down
8 changes: 4 additions & 4 deletions lib/discordrb/data/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ def add_role(role)
# @!visibility private
def delete_role(role_id)
@roles.reject! { |r| r.id == role_id }
@members.each do |_, member|
@members.each_value do |member|
new_roles = member.roles.reject { |r| r.id == role_id }
member.update_roles(new_roles)
end
Expand Down Expand Up @@ -830,11 +830,11 @@ def update_data(new_data = nil)
@afk_timeout = new_data[:afk_timeout] || new_data['afk_timeout'] || @afk_timeout

afk_channel_id = new_data[:afk_channel_id] || new_data['afk_channel_id'] || @afk_channel
@afk_channel_id = afk_channel_id.nil? ? nil : afk_channel_id.resolve_id
@afk_channel_id = afk_channel_id&.resolve_id
widget_channel_id = new_data[:widget_channel_id] || new_data['widget_channel_id'] || @widget_channel
@widget_channel_id = widget_channel_id.nil? ? nil : widget_channel_id.resolve_id
@widget_channel_id = widget_channel_id&.resolve_id
system_channel_id = new_data[:system_channel_id] || new_data['system_channel_id'] || @system_channel
@system_channel_id = system_channel_id.nil? ? nil : system_channel_id.resolve_id
@system_channel_id = system_channel_id&.resolve_id

@widget_enabled = new_data[:widget_enabled] || new_data['widget_enabled']
@splash = new_data[:splash_id] || new_data['splash_id'] || @splash_id
Expand Down
2 changes: 1 addition & 1 deletion spec/overwrite_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
end

it 'infers type from a User object' do
users.each do |_user_type, user|
users.each_value do |user|
expect(described_class.new(user).type).to eq :member
end
end
Expand Down

0 comments on commit f2a313b

Please sign in to comment.