From b4bdc86101016034d4ffd82034f4d72b0a5edb20 Mon Sep 17 00:00:00 2001 From: NVMakarenko Date: Sat, 30 Nov 2024 21:01:39 +0200 Subject: [PATCH 01/13] add unlighthouse scan after staging --- .github/workflows/cd.yml | 15 +++++++++++++++ app/lib/convert_json_to_csv.rb | 17 +++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 app/lib/convert_json_to_csv.rb diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 3a56760af..d56505522 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -31,12 +31,27 @@ jobs: ruby-version: 3.3.5 bundler-cache: true + - name: Set up Unlighthouse Scan + run: npm install -g @unlighthouse/cli puppeteer + - uses: miloserdow/capistrano-deploy@v3 with: target: staging deploy_key: ${{ secrets.STAGING_KEY_PASSWORD }} enc_rsa_key_pth: config/credentials/staging_deploy_id_ed25519_enc + - 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 lib/convert_json_to_csv.rb .unlighthouse/dist/ci-result.json .unlighthouse/dist/ci-result.csv + + - name: Upload Unlighthouse Report + uses: actions/upload-artifact@v4 + with: + name: unlighthouse-report + path: .unlighthouse/dist/** + deploy-to-production: runs-on: ubuntu-latest if: github.event_name == 'release' && github.event.action == 'published' diff --git a/app/lib/convert_json_to_csv.rb b/app/lib/convert_json_to_csv.rb new file mode 100644 index 000000000..7fae445aa --- /dev/null +++ b/app/lib/convert_json_to_csv.rb @@ -0,0 +1,17 @@ +require "json" +require "csv" + +class ConvertJsonToCsv + def self.perform(input_file, output_file) + 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 + end +end + +if __FILE__ == $0 + input_file = ARGV[0] + output_file = ARGV[1] + ConvertJsonToCsv.perform(input_file, output_file) +end From 4950070b813037455c9fb3db49858f5e1f35ae2a Mon Sep 17 00:00:00 2001 From: NVMakarenko Date: Sat, 30 Nov 2024 21:57:05 +0200 Subject: [PATCH 02/13] add tests --- spec/fixtures/files/unlighthouse_report.json | 18 ++++++++++++++ spec/lib/convert_json_to_csv_spec.rb | 26 ++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 spec/fixtures/files/unlighthouse_report.json create mode 100644 spec/lib/convert_json_to_csv_spec.rb diff --git a/spec/fixtures/files/unlighthouse_report.json b/spec/fixtures/files/unlighthouse_report.json new file mode 100644 index 000000000..2984245d6 --- /dev/null +++ b/spec/fixtures/files/unlighthouse_report.json @@ -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 + } +] diff --git a/spec/lib/convert_json_to_csv_spec.rb b/spec/lib/convert_json_to_csv_spec.rb new file mode 100644 index 000000000..9e98a9420 --- /dev/null +++ b/spec/lib/convert_json_to_csv_spec.rb @@ -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) + csv_content = CSV.read(output_file, headers: true) + + 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 From 642f3700c6f6d47bd3bad16b5c7ed47ef92a8e42 Mon Sep 17 00:00:00 2001 From: NVMakarenko Date: Sun, 1 Dec 2024 07:58:59 +0200 Subject: [PATCH 03/13] add custom csript --- .github/workflows/cd.yml | 5 ++++- app/lib/convert_json_to_csv.rb | 6 ------ bin/convert_json_to_csv.rb | 6 ++++++ 3 files changed, 10 insertions(+), 7 deletions(-) create mode 100644 bin/convert_json_to_csv.rb diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index d56505522..9b6c65de2 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -43,8 +43,11 @@ jobs: - name: Unlighthouse Assertions and Client run: unlighthouse-ci --site http://51.44.25.104/en --build-static --output-path .unlighthouse/dist + - name: Make convert_json_to_csv executable + run: chmod +x bin/convert_json_to_csv.rb + - name: Convert JSON to CSV - run: ruby lib/convert_json_to_csv.rb .unlighthouse/dist/ci-result.json .unlighthouse/dist/ci-result.csv + run: bin/convert_json_to_csv.rb .unlighthouse/dist/ci-result.json .unlighthouse/dist/ci-result.csv - name: Upload Unlighthouse Report uses: actions/upload-artifact@v4 diff --git a/app/lib/convert_json_to_csv.rb b/app/lib/convert_json_to_csv.rb index 7fae445aa..56cd32340 100644 --- a/app/lib/convert_json_to_csv.rb +++ b/app/lib/convert_json_to_csv.rb @@ -9,9 +9,3 @@ def self.perform(input_file, output_file) end end end - -if __FILE__ == $0 - input_file = ARGV[0] - output_file = ARGV[1] - ConvertJsonToCsv.perform(input_file, output_file) -end diff --git a/bin/convert_json_to_csv.rb b/bin/convert_json_to_csv.rb new file mode 100644 index 000000000..e244899ce --- /dev/null +++ b/bin/convert_json_to_csv.rb @@ -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) From 51a5f497e714ddc67059cae0e522f63e9d2c27c8 Mon Sep 17 00:00:00 2001 From: NVMakarenko Date: Sun, 1 Dec 2024 21:33:08 +0200 Subject: [PATCH 04/13] add ConvertJsonToCsv service --- .github/workflows/cd.yml | 18 -------- .github/workflows/scan_unlighthouse.yml | 39 +++++++++++++++++ app/lib/convert_json_to_csv.rb | 11 ----- app/services/convert_json_to_csv_service.rb | 19 +++++++++ spec/fixtures/files/output.csv | 3 ++ spec/lib/convert_json_to_csv_spec.rb | 26 ------------ .../convert_json_to_csv_service_spec.rb | 42 +++++++++++++++++++ 7 files changed, 103 insertions(+), 55 deletions(-) create mode 100644 .github/workflows/scan_unlighthouse.yml delete mode 100644 app/lib/convert_json_to_csv.rb create mode 100644 app/services/convert_json_to_csv_service.rb create mode 100644 spec/fixtures/files/output.csv delete mode 100644 spec/lib/convert_json_to_csv_spec.rb create mode 100644 spec/services/convert_json_to_csv_service_spec.rb diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 9b6c65de2..3a56760af 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -31,30 +31,12 @@ jobs: ruby-version: 3.3.5 bundler-cache: true - - name: Set up Unlighthouse Scan - run: npm install -g @unlighthouse/cli puppeteer - - uses: miloserdow/capistrano-deploy@v3 with: target: staging deploy_key: ${{ secrets.STAGING_KEY_PASSWORD }} enc_rsa_key_pth: config/credentials/staging_deploy_id_ed25519_enc - - name: Unlighthouse Assertions and Client - run: unlighthouse-ci --site http://51.44.25.104/en --build-static --output-path .unlighthouse/dist - - - name: Make convert_json_to_csv executable - run: chmod +x bin/convert_json_to_csv.rb - - - name: Convert JSON to CSV - run: bin/convert_json_to_csv.rb .unlighthouse/dist/ci-result.json .unlighthouse/dist/ci-result.csv - - - name: Upload Unlighthouse Report - uses: actions/upload-artifact@v4 - with: - name: unlighthouse-report - path: .unlighthouse/dist/** - deploy-to-production: runs-on: ubuntu-latest if: github.event_name == 'release' && github.event.action == 'published' diff --git a/.github/workflows/scan_unlighthouse.yml b/.github/workflows/scan_unlighthouse.yml new file mode 100644 index 000000000..963df8e4c --- /dev/null +++ b/.github/workflows/scan_unlighthouse.yml @@ -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/dist/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/dist/ci-result.csv diff --git a/app/lib/convert_json_to_csv.rb b/app/lib/convert_json_to_csv.rb deleted file mode 100644 index 56cd32340..000000000 --- a/app/lib/convert_json_to_csv.rb +++ /dev/null @@ -1,11 +0,0 @@ -require "json" -require "csv" - -class ConvertJsonToCsv - def self.perform(input_file, output_file) - 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 - end -end diff --git a/app/services/convert_json_to_csv_service.rb b/app/services/convert_json_to_csv_service.rb new file mode 100644 index 000000000..50fdd2d3c --- /dev/null +++ b/app/services/convert_json_to_csv_service.rb @@ -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 diff --git a/spec/fixtures/files/output.csv b/spec/fixtures/files/output.csv new file mode 100644 index 000000000..a51461ff4 --- /dev/null +++ b/spec/fixtures/files/output.csv @@ -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 diff --git a/spec/lib/convert_json_to_csv_spec.rb b/spec/lib/convert_json_to_csv_spec.rb deleted file mode 100644 index 9e98a9420..000000000 --- a/spec/lib/convert_json_to_csv_spec.rb +++ /dev/null @@ -1,26 +0,0 @@ -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) - csv_content = CSV.read(output_file, headers: true) - - 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 diff --git a/spec/services/convert_json_to_csv_service_spec.rb b/spec/services/convert_json_to_csv_service_spec.rb new file mode 100644 index 000000000..6e2cae856 --- /dev/null +++ b/spec/services/convert_json_to_csv_service_spec.rb @@ -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 From 6942ec517665df23394fceb64d4fc736a1bdc76c Mon Sep 17 00:00:00 2001 From: NVMakarenko Date: Sun, 1 Dec 2024 21:58:02 +0200 Subject: [PATCH 05/13] remove redindant code --- .github/workflows/scan_unlighthouse.yml | 6 +++--- bin/convert_json_to_csv.rb | 6 ------ 2 files changed, 3 insertions(+), 9 deletions(-) delete mode 100644 bin/convert_json_to_csv.rb diff --git a/.github/workflows/scan_unlighthouse.yml b/.github/workflows/scan_unlighthouse.yml index 963df8e4c..52166564f 100644 --- a/.github/workflows/scan_unlighthouse.yml +++ b/.github/workflows/scan_unlighthouse.yml @@ -24,7 +24,7 @@ jobs: - name: Convert JSON to CSV run: | - ruby -e "require './lib/convert_json_to_csv_service'; ConvertJsonToCsvService.call('.unlighthouse/dist/ci-result.json', '.unlighthouse/dist/ci-result.csv')" + 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 @@ -32,8 +32,8 @@ jobs: name: unlighthouse-report path: .unlighthouse/dist/** - - name: Upload СCSV Report + - name: Upload CSV Report uses: actions/upload-artifact@v4 with: name: csv-report - path: .unlighthouse/dist/ci-result.csv + path: .unlighthouse/ci-result.csv diff --git a/bin/convert_json_to_csv.rb b/bin/convert_json_to_csv.rb deleted file mode 100644 index e244899ce..000000000 --- a/bin/convert_json_to_csv.rb +++ /dev/null @@ -1,6 +0,0 @@ -#!/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) From c0db21dfca1a53f1528fc35ea42dc51a98697416 Mon Sep 17 00:00:00 2001 From: NVMakarenko Date: Sun, 1 Dec 2024 23:24:13 +0200 Subject: [PATCH 06/13] fix small issue --- .github/workflows/scan_unlighthouse.yml | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/.github/workflows/scan_unlighthouse.yml b/.github/workflows/scan_unlighthouse.yml index 52166564f..98fee5b53 100644 --- a/.github/workflows/scan_unlighthouse.yml +++ b/.github/workflows/scan_unlighthouse.yml @@ -2,11 +2,27 @@ name: Unlighthouse reports on: workflow_dispatch: - -jobs: + # workflow_run: + # workflows: + # - CD + # types: + # - completed + + # pull_request: + # branches: + # - develop + # - master + # types: + # - closed + + # release: + # types: + # - published + + jobs: generate-unlighthouse-report: runs-on: ubuntu-latest - if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true + # if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true steps: - uses: actions/checkout@v2 @@ -24,7 +40,7 @@ jobs: - 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')" + ruby -e "require './services/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 From 92186aaceefe81a0640212313d13f5f1838abb0f Mon Sep 17 00:00:00 2001 From: NVMakarenko Date: Mon, 2 Dec 2024 08:34:29 +0200 Subject: [PATCH 07/13] small fixes --- .github/workflows/scan_unlighthouse.yml | 38 ++++++++++----------- app/services/convert_json_to_csv_service.rb | 3 ++ 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/.github/workflows/scan_unlighthouse.yml b/.github/workflows/scan_unlighthouse.yml index 98fee5b53..dcf71a679 100644 --- a/.github/workflows/scan_unlighthouse.yml +++ b/.github/workflows/scan_unlighthouse.yml @@ -1,28 +1,27 @@ name: Unlighthouse reports on: - workflow_dispatch: - # workflow_run: - # workflows: - # - CD - # types: - # - completed - - # pull_request: - # branches: - # - develop - # - master - # types: - # - closed - - # release: - # types: - # - published + workflow_run: + workflows: + - CD + types: + - completed + + pull_request: + branches: + - develop + - master + types: + - closed + + release: + types: + - published jobs: generate-unlighthouse-report: runs-on: ubuntu-latest - # if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true + if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true steps: - uses: actions/checkout@v2 @@ -39,8 +38,7 @@ on: 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 './services/convert_json_to_csv_service'; ConvertJsonToCsvService.call('.unlighthouse/dist/ci-result.json', '.unlighthouse/ci-result.csv')" + run: ruby -e '$LOAD_PATH.unshift("./app/services"); require "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 diff --git a/app/services/convert_json_to_csv_service.rb b/app/services/convert_json_to_csv_service.rb index 50fdd2d3c..80db6259f 100644 --- a/app/services/convert_json_to_csv_service.rb +++ b/app/services/convert_json_to_csv_service.rb @@ -1,3 +1,6 @@ +require "json" +require "csv" + class ConvertJsonToCsvService def self.call(input_file, output_file) new(input_file, output_file).call From 911ee3242f27a5b164b05b3f1372d4952e48f384 Mon Sep 17 00:00:00 2001 From: NVMakarenko Date: Mon, 2 Dec 2024 09:11:06 +0200 Subject: [PATCH 08/13] fix extension --- .github/workflows/scan_unlighthouse.yml | 64 ++++++++++++------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/.github/workflows/scan_unlighthouse.yml b/.github/workflows/scan_unlighthouse.yml index dcf71a679..25f840481 100644 --- a/.github/workflows/scan_unlighthouse.yml +++ b/.github/workflows/scan_unlighthouse.yml @@ -19,35 +19,35 @@ on: - published 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 '$LOAD_PATH.unshift("./app/services"); require "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 + 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 '$LOAD_PATH.unshift("./app/services"); require "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 From 07b551eb4da273d2e7aa827947407556c62e1287 Mon Sep 17 00:00:00 2001 From: NVMakarenko Date: Mon, 2 Dec 2024 09:12:36 +0200 Subject: [PATCH 09/13] small fixes --- .github/workflows/scan_unlighthouse.yml | 66 ++++++++++++------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/.github/workflows/scan_unlighthouse.yml b/.github/workflows/scan_unlighthouse.yml index 25f840481..99416649a 100644 --- a/.github/workflows/scan_unlighthouse.yml +++ b/.github/workflows/scan_unlighthouse.yml @@ -18,36 +18,36 @@ on: types: - published - 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 '$LOAD_PATH.unshift("./app/services"); require "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 +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 '$LOAD_PATH.unshift("./app/services"); require "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 From b599284cb63a7f668b10bba00342d51708b9d5be Mon Sep 17 00:00:00 2001 From: NVMakarenko Date: Mon, 2 Dec 2024 09:32:28 +0200 Subject: [PATCH 10/13] fix workflow trigger --- .github/workflows/scan_unlighthouse.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/scan_unlighthouse.yml b/.github/workflows/scan_unlighthouse.yml index 99416649a..1e54ed31e 100644 --- a/.github/workflows/scan_unlighthouse.yml +++ b/.github/workflows/scan_unlighthouse.yml @@ -1,11 +1,7 @@ name: Unlighthouse reports on: - workflow_run: - workflows: - - CD - types: - - completed + workflow_dispatch: pull_request: branches: @@ -21,7 +17,7 @@ on: jobs: generate-unlighthouse-report: runs-on: ubuntu-latest - if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true + if: ${{ github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged }} steps: - uses: actions/checkout@v2 From 99cc64ca996c7a06ea3ad7dbaeecaa1371b6564b Mon Sep 17 00:00:00 2001 From: NVMakarenko Date: Mon, 2 Dec 2024 09:50:54 +0200 Subject: [PATCH 11/13] remove if --- .github/workflows/scan_unlighthouse.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/scan_unlighthouse.yml b/.github/workflows/scan_unlighthouse.yml index 1e54ed31e..420d77179 100644 --- a/.github/workflows/scan_unlighthouse.yml +++ b/.github/workflows/scan_unlighthouse.yml @@ -17,7 +17,6 @@ on: jobs: generate-unlighthouse-report: runs-on: ubuntu-latest - if: ${{ github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged }} steps: - uses: actions/checkout@v2 From 0d2b85dc4e03837722c4139da96cccad097ca57a Mon Sep 17 00:00:00 2001 From: NVMakarenko Date: Mon, 2 Dec 2024 09:56:40 +0200 Subject: [PATCH 12/13] try to check on push --- .github/workflows/scan_unlighthouse.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/scan_unlighthouse.yml b/.github/workflows/scan_unlighthouse.yml index 420d77179..621109fb0 100644 --- a/.github/workflows/scan_unlighthouse.yml +++ b/.github/workflows/scan_unlighthouse.yml @@ -1,7 +1,7 @@ name: Unlighthouse reports on: - workflow_dispatch: + push: pull_request: branches: From 7dccaffd1ca5be6a20a5041bf282f3db60da252f Mon Sep 17 00:00:00 2001 From: NVMakarenko Date: Mon, 2 Dec 2024 10:03:17 +0200 Subject: [PATCH 13/13] add workflow_dispatch --- .github/workflows/scan_unlighthouse.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/scan_unlighthouse.yml b/.github/workflows/scan_unlighthouse.yml index 621109fb0..420d77179 100644 --- a/.github/workflows/scan_unlighthouse.yml +++ b/.github/workflows/scan_unlighthouse.yml @@ -1,7 +1,7 @@ name: Unlighthouse reports on: - push: + workflow_dispatch: pull_request: branches: