Repository: GoogleChrome/lighthouse (js)

Issue:
The CLI --output csv option should include the requestedUrl in the output.

[batch.txt](https://github.com/GoogleChrome/lighthouse/files/4547869/batch.txt)

[reports.zip](https://github.com/GoogleChrome/lighthouse/files/4547874/reports.zip)

I frequently batch up a number of pages using the CLI, using a command such as:

`lighthouse $page --quiet --output html --output csv --output json --only-categories performance --chrome-flags="--headless"`

This will produce a results with filenames such as www.example.com_2020-04-27_18-34-16.report,csv .json and .html

The reports all just have the domain as the filename. Within the html and json files, I can see what the page I tested was. However with the CSV file the total fields outputted for performance are related to the weightings and don't include the page tested.

There you can see from the attached that the page that was tested is not listed in the CSV, and as the filename doesn't include the page - only the domain - I have to jump through further hoops to compile the data together.

The json output includes, (like the HTML), the actual values rather than a weighting. If all of that could be included in the csv output it would be wonderful - but the page tested fields ("requestedUrl" and "finalUrl") would make the csv much easier to work with at a stroke.



Pull request:
core(report-generator): add url to CSV output
**Summary**
Pushing back against CSV as a thing is more work than making it better :)

**Related Issues/PRs**
closes #10654


Patch:
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 2b5abbc15..5d802ab73 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -4,7 +4,7 @@
 
 name: 💡🏠
 
-on: [push, pull_request]
+on: [pull_request]
 
 jobs:
   ci:
@@ -24,9 +24,10 @@ jobs:
         node-version: 10.x
 
     - name: Setup protoc
-      uses: arduino/setup-protoc@master
+      uses: arduino/setup-protoc@7ad700d
       with:
         version: '3.7.1'
+        repo-token: ${{ secrets.GITHUB_TOKEN }}
 
     - name: Set up Python
       uses: actions/setup-python@v1
diff --git a/lighthouse-core/report/report-generator.js b/lighthouse-core/report/report-generator.js
index 819a6624f..8127686aa 100644
--- a/lighthouse-core/report/report-generator.js
+++ b/lighthouse-core/report/report-generator.js
@@ -68,13 +68,14 @@ class ReportGenerator {
     const escape = value => `"${value.replace(/"/g, '""')}"`;
 
     // Possible TODO: tightly couple headers and row values
-    const header = ['category', 'name', 'title', 'type', 'score'];
+    const header = ['requestedUrl', 'finalUrl', 'category', 'name', 'title', 'type', 'score'];
     const table = Object.values(lhr.categories).map(category => {
       return category.auditRefs.map(auditRef => {
         const audit = lhr.audits[auditRef.id];
         // CSV validator wants all scores to be numeric, use -1 for now
         const numericScore = audit.score === null ? -1 : audit.score;
-        return [category.title, audit.id, audit.title, audit.scoreDisplayMode, numericScore]
+        return [lhr.requestedUrl, lhr.finalUrl, category.title, audit.id, audit.title,
+          audit.scoreDisplayMode, numericScore]
           .map(value => value.toString())
           .map(escape);
       });


Test patch:
diff --git a/lighthouse-core/test/report/report-generator-test.js b/lighthouse-core/test/report/report-generator-test.js
index d10ca8420..997ac9873 100644
--- a/lighthouse-core/test/report/report-generator-test.js
+++ b/lighthouse-core/test/report/report-generator-test.js
@@ -100,6 +100,14 @@ describe('ReportGenerator', () => {
       const csvOutput = ReportGenerator.generateReport(sampleResults, 'csv');
       fs.writeFileSync(path, csvOutput);
 
+      const lines = csvOutput.split('\n');
+      expect(lines).toHaveLength(145);
+      expect(lines.slice(0, 2).join('\n')).toMatchInlineSnapshot(`
+        "requestedUrl,finalUrl,category,name,title,type,score
+        \\"http://localhost:10200/dobetterweb/dbw_tester.html\\",\\"http://localhost:10200/dobetterweb/dbw_tester.html\\",\\"Performance\\",\\"first-contentful-paint\\",\\"First Contentful Paint\\",\\"numeric\\",\\"0.51\\"
+        "
+      `);
+
       try {
         await csvValidator(path, headers);
       } catch (err) {