generated from ita-social-projects/DevTemplate
-
Notifications
You must be signed in to change notification settings - Fork 11
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
Open
NVMakarenko
wants to merge
6
commits into
develop
Choose a base branch
from
991-add-unlighthouse-scan
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+137
−0
Open
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b4bdc86
add unlighthouse scan after staging
NVMakarenko 4950070
add tests
NVMakarenko 642f370
add custom csript
NVMakarenko 51a5f49
add ConvertJsonToCsv service
NVMakarenko 6942ec5
remove redindant code
NVMakarenko c0db21d
fix small issue
NVMakarenko File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: Unlighthouse reports | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
generate-unlighthouse-report: | ||
runs-on: ubuntu-latest | ||
if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Set up Ruby | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: 3.3.5 | ||
bundler-cache: true | ||
|
||
- name: Set up Unlighthouse Scan | ||
run: npm install -g @unlighthouse/cli puppeteer | ||
|
||
- name: Unlighthouse Assertions and Client | ||
run: unlighthouse-ci --site http://51.44.25.104/en --build-static --output-path .unlighthouse/dist | ||
|
||
- name: Convert JSON to CSV | ||
run: | | ||
ruby -e "require './lib/convert_json_to_csv_service'; ConvertJsonToCsvService.call('.unlighthouse/dist/ci-result.json', '.unlighthouse/ci-result.csv')" | ||
|
||
- name: Upload Unlighthouse Report | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: unlighthouse-report | ||
path: .unlighthouse/dist/** | ||
|
||
- name: Upload CSV Report | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: csv-report | ||
path: .unlighthouse/ci-result.csv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
class ConvertJsonToCsvService | ||
def self.call(input_file, output_file) | ||
new(input_file, output_file).call | ||
end | ||
|
||
def initialize(input_file, output_file) | ||
@input_file = input_file | ||
@output_file = output_file | ||
end | ||
|
||
def call | ||
json_data = JSON.parse(File.read(@input_file)) | ||
|
||
CSV.open(@output_file, "w", write_headers: true, headers: json_data.first.keys) do |csv| | ||
json_data.each { |row| csv << row.values } | ||
end | ||
@output_file | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
path,score,performance,accessibility,best-practices,seo | ||
/en,0.78,0.64,0.86,0.79,0.83 | ||
/en/about-us,0.78,0.63,0.77,0.79,0.92 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe ConvertJsonToCsvService do | ||
let(:input_file) { "spec/fixtures/files/unlighthouse_report.json" } | ||
let(:output_file) { "spec/fixtures/files/output.csv" } | ||
let(:csv_content) { CSV.read(output_file, headers: true) } | ||
|
||
describe ".call" do | ||
context "when initializing and calling an instance" do | ||
let(:service_instance) { instance_double(ConvertJsonToCsvService) } | ||
|
||
before do | ||
allow(ConvertJsonToCsvService).to receive(:new).with(input_file, output_file).and_return(service_instance) | ||
allow(service_instance).to receive(:call).and_return(output_file) | ||
end | ||
|
||
it "initializes and calls the instance with the provided arguments" do | ||
result = ConvertJsonToCsvService.call(input_file, output_file) | ||
|
||
expect(ConvertJsonToCsvService).to have_received(:new).with(input_file, output_file) | ||
expect(service_instance).to have_received(:call) | ||
expect(result).to eq(output_file) | ||
end | ||
end | ||
|
||
context "when creating a CSV file" do | ||
it "creates a csv file with correct data" do | ||
result = ConvertJsonToCsvService.call(input_file, output_file) | ||
|
||
expect(result).to eq(output_file) | ||
expect(File.exist?(output_file)).to be_truthy | ||
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 | ||
end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
should be changed on:
after all checks