Skip to content

Commit

Permalink
Merge pull request #169 from fartem/ci-27
Browse files Browse the repository at this point in the history
2023-01-15 v. 1.2.0: updated CI setup
  • Loading branch information
fartem authored Jul 15, 2023
2 parents 7972364 + 894df1f commit 5f0cca1
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 17 deletions.
7 changes: 7 additions & 0 deletions ci/ci_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ def run
puts("#{self.class.name} ended without errors!")
end

# Use this method in your realization when task completed with error.
def end_with_error(details)
details.call
puts("#{self.class.name} ended with an error.")
exit(1)
end

# Job realization.
# You should override this method in your realization.
def process
Expand Down
3 changes: 1 addition & 2 deletions ci/last_reachable_checker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ def check

return if res.code == '200'

puts("LastReachableChecker ends with an error from #{parsed_uri}.")
exit(1)
end_with_error(-> { puts("LastReachableChecker ends with an error from #{parsed_uri} (#{res.code}).") })
end
end
end
5 changes: 1 addition & 4 deletions ci/links_checker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ def check(difficulty)
end
end

unless has_comment
puts("LinksChecker ends with an error from #{file_name}.")
exit(1)
end
end_with_error(-> { puts("LinksChecker ends with an error from #{file_name}.") }) unless has_comment
end
end
end
Expand Down
5 changes: 1 addition & 4 deletions ci/readme_checker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ def check(difficulty)
links_count += 1 if line.include?(file_name)
end

if links_count != 1
puts("ReadmeChecker ends with an error from #{file_name}.")
exit(1)
end
end_with_error(-> { puts("ReadmeChecker ends with an error from #{file_name}.") }) if links_count != 1
end
end
end
Expand Down
7 changes: 3 additions & 4 deletions ci/tests_checker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ def check(difficulty)
path = "./lib/#{difficulty}"
solutions = ::Dir.entries(path).reject { |file_name| file_name.start_with?('.') }
solutions.each do |file_name|
unless ::File.exist?("./test/#{difficulty}/test_#{file_name}")
puts("TestsChecker ends with an error from #{file_name}.")
exit(1)
end
next if ::File.exist?("./test/#{difficulty}/test_#{file_name}")

end_with_error(-> { puts("TestsChecker ends with an error from #{file_name}.") })
end
end
end
Expand Down
3 changes: 1 addition & 2 deletions ci/version_checker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ def check

return if local_spec.version > remote_spec.version

puts('VersionChecker ends with an error.')
exit(1)
end_with_error(-> { puts('VersionChecker ends with an error.') })
end
end
end
2 changes: 1 addition & 1 deletion leetcode-ruby.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ require 'English'
::Gem::Specification.new do |s|
s.required_ruby_version = '>= 3.0'
s.name = 'leetcode-ruby'
s.version = '1.1.9'
s.version = '1.2.0'
s.license = 'MIT'
s.files = ::Dir['lib/**/*.rb'] + %w[bin/leetcode-ruby README.md LICENSE]
s.executable = 'leetcode-ruby'
Expand Down

0 comments on commit 5f0cca1

Please sign in to comment.