-
Notifications
You must be signed in to change notification settings - Fork 10
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
add unlighthouse scan after staging #996
base: develop
Are you sure you want to change the base?
Changes from 3 commits
b4bdc86
4950070
642f370
51a5f49
6942ec5
c0db21d
92186aa
911ee32
07b551e
b599284
99cc64c
0d2b85d
7dccaff
94c68ea
534f0f5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,11 @@ | ||||||||
require "json" | ||||||||
require "csv" | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that should already present |
||||||||
|
||||||||
class ConvertJsonToCsv | ||||||||
def self.perform(input_file, output_file) | ||||||||
json_data = JSON.parse(File.read(input_file)) | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. write it as service object |
||||||||
CSV.open(output_file, "w", write_headers: true, headers: json_data.first.keys) do |csv| | ||||||||
json_data.each { |row| csv << row.values } | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that would be fine to make link available to open There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if it's possible |
||||||||
end | ||||||||
end | ||||||||
end |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use rake task for this |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env ruby | ||
require_relative "../lib/convert_json_to_csv" | ||
|
||
input_file = ARGV[0] | ||
output_file = ARGV[1] | ||
ConvertJsonToCsv.perform(input_file, output_file) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
[ | ||
{ | ||
"path": "/en", | ||
"score": 0.78, | ||
"performance": 0.64, | ||
"accessibility": 0.86, | ||
"best-practices": 0.79, | ||
"seo": 0.83 | ||
}, | ||
{ | ||
"path": "/en/about-us", | ||
"score": 0.78, | ||
"performance": 0.63, | ||
"accessibility": 0.77, | ||
"best-practices": 0.79, | ||
"seo": 0.92 | ||
} | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe ConvertJsonToCsv do | ||
let(:input_file) { "spec/fixtures/files/unlighthouse_report.json" } | ||
let(:output_file) { "spec/fixtures/files/output.csv" } | ||
|
||
after do | ||
File.delete(output_file) if File.exist?(output_file) | ||
end | ||
|
||
describe ".perform" do | ||
it "converts JSON to CSV" do | ||
ConvertJsonToCsv.perform(input_file, output_file) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. before hook |
||
csv_content = CSV.read(output_file, headers: true) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use let |
||
|
||
expect(csv_content.headers).to eq(["path", "score", "performance", "accessibility", "best-practices", "seo"]) | ||
|
||
expect(csv_content[0]["path"]).to eq("/en") | ||
expect(csv_content[0]["score"]).to eq("0.78") | ||
expect(csv_content[0]["performance"]).to eq("0.64") | ||
expect(csv_content[0]["accessibility"]).to eq("0.86") | ||
expect(csv_content[0]["best-practices"]).to eq("0.79") | ||
expect(csv_content[0]["seo"]).to eq("0.83") | ||
end | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this report generation should be outside deploy action, with the same conditions, but that's another thing tather deploy