Skip to content

Commit

Permalink
Remove nokogiri depencency and use ruby alpine base docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
tessereth committed Apr 27, 2018
1 parent 09114f4 commit 046ef39
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ruby:2.5.1
FROM ruby:2.5.1-alpine

# Fetch/install gems
RUN mkdir -p /opt/gems
Expand Down
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ git_source(:github) { |repo_name| "https:/#{repo_name}" }

gem 'bundler', '~> 1.16'
gem 'haml'
gem 'nokogiri'

group :development, :test do
gem 'rake', '~> 10.0'
Expand Down
4 changes: 0 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ GEM
temple (>= 0.8.0)
tilt
json (2.1.0)
mini_portile2 (2.3.0)
nokogiri (1.8.2)
mini_portile2 (~> 2.3.0)
parallel (1.12.1)
parser (2.5.1.0)
ast (~> 2.4.0)
Expand Down Expand Up @@ -53,7 +50,6 @@ PLATFORMS
DEPENDENCIES
bundler (~> 1.16)
haml
nokogiri
rake (~> 10.0)
rspec (~> 3.0)
rubocop
Expand Down
16 changes: 9 additions & 7 deletions lib/test_summary_buildkite_plugin/input.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# frozen_string_literal: true

require 'nokogiri'
# We don't use nokogiri because we use an alpine-based docker image
# And adding the required dependencies triples the size of the image
require 'rexml/document'

module TestSummaryBuildkitePlugin
module Input
Expand Down Expand Up @@ -72,20 +74,20 @@ def crop

class JUnit < Base
def failures_raw
files.map { |file| File.open(file) { |f| Nokogiri::XML(f, nil, encoding) } }
files.map { |file| REXML::Document.new(read(file)) }
.map { |xml| xml_to_failures(xml) }
.flatten
end

private

def xml_to_failures(xml)
xml.css('testcase').each_with_object([]) do |testcase, failures|
testcase.css('failure').each do |failure|
xml.elements.enum_for(:each, '*/testcase').each_with_object([]) do |testcase, failures|
testcase.elements.each('failure') do |failure|
failures << Failure::Structured.new(
file: testcase['file'],
name: testcase['name'],
details: failure.inner_html
file: testcase.attributes['file'].to_s,
name: testcase.attributes['name'].to_s,
details: failure.text
)
end
end
Expand Down
4 changes: 0 additions & 4 deletions spec/test_summary_buildkite_plugin/input_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,6 @@
expect(input.failures.first.details).to start_with('Failure/Error: ')
end

it 'details escape html' do
expect(input.failures.first.details).to include('&lt;')
end

it 'failures have file' do
expect(input.failures.first.file).to eq('./spec/lib/url_whitelist_spec.rb')
end
Expand Down

0 comments on commit 046ef39

Please sign in to comment.