Skip to content

Commit

Permalink
Merge pull request #2 from euglena1215/fix-ci
Browse files Browse the repository at this point in the history
Fix CI
  • Loading branch information
euglena1215 authored Jan 5, 2024
2 parents ac68e1d + 3ff5119 commit abd5e36
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 26 deletions.
7 changes: 7 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
inherit_gem:
rubocop-shopify: rubocop.yml

require:
- rubocop-performance
- rubocop-sorbet

AllCops:
TargetRubyVersion: 2.6
SuggestExtensions: false
Expand Down
11 changes: 6 additions & 5 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ gemspec
# TODO: Move to gemspec after merged https://github.com/Shopify/packwerk/pull/375
gem "packwerk", git: "https://github.com/richardmarbach/packwerk", branch: "configurable_parser_interface"

gem "rake", "~> 13.0"

gem "minitest", "~> 5.16"

gem "rubocop", "~> 1.21"
gem "minitest"
gem "rake"
gem "rubocop", require: false
gem "rubocop-performance", require: false
gem "rubocop-sorbet", require: false
gem "rubocop-shopify", require: false
19 changes: 16 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ GEM
mutex_m (0.2.0)
nokogiri (1.16.0-arm64-darwin)
racc (~> 1.4)
nokogiri (1.16.0-x86_64-linux)
racc (~> 1.4)
parallel (1.24.0)
parser (3.2.2.4)
ast (~> 2.4.1)
Expand Down Expand Up @@ -98,6 +100,13 @@ GEM
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.30.0)
parser (>= 3.2.1.0)
rubocop-performance (1.20.1)
rubocop (>= 1.48.1, < 2.0)
rubocop-ast (>= 1.30.0, < 2.0)
rubocop-shopify (2.14.0)
rubocop (~> 1.51)
rubocop-sorbet (0.7.6)
rubocop (>= 0.90.0)
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
smart_properties (1.17.0)
Expand All @@ -110,13 +119,17 @@ GEM

PLATFORMS
arm64-darwin-21
x86_64-linux

DEPENDENCIES
minitest (~> 5.16)
minitest
packwerk!
packwerk_yard!
rake (~> 13.0)
rubocop (~> 1.21)
rake
rubocop
rubocop-performance
rubocop-shopify
rubocop-sorbet

BUNDLED WITH
2.4.18
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ require "rubocop/rake_task"

RuboCop::RakeTask.new

task default: %i[test rubocop]
task default: [:test, :rubocop]
3 changes: 2 additions & 1 deletion lib/packwerk_yard.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# typed: false
# frozen_string_literal: true

require "packwerk"
Expand All @@ -6,5 +7,5 @@
require_relative "packwerk_yard/version"
require_relative "packwerk_yard/parser"

module PackwerkYard # rubocop:disable Style/Documentation
module PackwerkYard
end
11 changes: 6 additions & 5 deletions lib/packwerk_yard/parser.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# typed: false
# frozen_string_literal: true

module PackwerkYard
class Parser # rubocop:disable Style/Documentation
class Parser
include Packwerk::FileParser

# Array Syntax e.g. Array<String>
Expand All @@ -21,8 +22,8 @@ def call(io:, file_path: "<unknown>")
to_ruby_ast(
types.map { |type| to_evaluable_type(type) }
.reject { |type| to_constant(type).nil? }
.inspect.gsub('"', ""),
file_path
.inspect.delete('"'),
file_path,
)
end

Expand Down Expand Up @@ -58,15 +59,15 @@ def to_evaluable_type(type)
end

def to_constant(name)
Object.const_get(name)
Object.const_get(name) # rubocop:disable Sorbet/ConstantsFromStrings
rescue NameError
nil
end

def to_ruby_ast(code, file_path)
@ruby_parser.call(
io: StringIO.new(code),
file_path: file_path
file_path: file_path,
)
end
end
Expand Down
1 change: 1 addition & 0 deletions lib/packwerk_yard/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# typed: false
# frozen_string_literal: true

module PackwerkYard
Expand Down
8 changes: 4 additions & 4 deletions packwerk_yard.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ Gem::Specification.new do |spec|
# Specify which files should be added to the gem when it is released.
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
spec.files = Dir.chdir(__dir__) do
`git ls-files -z`.split("\x0").reject do |f|
%x(git ls-files -z).split("\x0").reject do |f|
(File.expand_path(f) == __FILE__) ||
f.start_with?(*%w[bin/ test/ spec/ features/ .git .github appveyor Gemfile])
f.start_with?("bin/", "test/", "spec/", "features/", ".git", ".github", "appveyor", "Gemfile")
end
end
spec.bindir = "exe"
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]

spec.add_dependency "parser"
spec.add_dependency "yard"
spec.add_dependency("parser")
spec.add_dependency("yard")
end
3 changes: 2 additions & 1 deletion test/test_helper.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# typed: false
# frozen_string_literal: true

$LOAD_PATH.unshift File.expand_path("../lib", __dir__)
$LOAD_PATH.unshift(File.expand_path("../lib", __dir__))
require "packwerk_yard"

require "minitest/autorun"
13 changes: 7 additions & 6 deletions test/unit/packwerk_yard/parser_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# typed: false
# frozen_string_literal: true

require "test_helper"
Expand All @@ -9,19 +10,19 @@ def test_call_returns_node_with_valid_file
io = StringIO.new(File.read("test/fixtures/yard/valid.rb"))
node = parser.call(io: io, file_path: "test/fixtures/yard/valid.rb")

assert_instance_of Parser::AST::Node, node
assert node.type, :array
assert node.children[0].children[1], :String
assert_instance_of(::Parser::AST::Node, node)
assert(node.type, :array)
assert(node.children[0].children[1], :String)
end

def test_call_return_node_with_not_exists_class_args_file
parser = ::PackwerkYard::Parser.new
io = StringIO.new(File.read("test/fixtures/yard/not_exists_class_args.rb"))
node = parser.call(io: io, file_path: "test/fixtures/yard/not_exists_class_args.rb")

assert_instance_of Parser::AST::Node, node
assert node.type, :array
assert node.children.size, 0
assert_instance_of(::Parser::AST::Node, node)
assert(node.type, :array)
assert(node.children.size, 0)
end
end
end

0 comments on commit abd5e36

Please sign in to comment.