Skip to content
This repository has been archived by the owner on Jul 8, 2020. It is now read-only.

Add link to LH report #12

Closed
wants to merge 3 commits into from
Closed

Add link to LH report #12

wants to merge 3 commits into from

Conversation

abdonrd
Copy link

@abdonrd abdonrd commented Oct 28, 2017

Fixes #11.

@abdonrd
Copy link
Author

abdonrd commented Oct 28, 2017

Ops! I just see the lhResults.url is the URL given by the user, not the report url. 🤦‍♂️

How can we get the report url?

@ebidel
Copy link
Contributor

ebidel commented Oct 28, 2017

The build server returns the report results here: https://github.com/ebidel/lighthouse-ci/blob/6303c79cfed38e64cd68b9e472bfedfbba3960cf/builder/server.js#L24

You'd probabably have to change the response of https://github.com/ebidel/lighthouse-ci/blob/e7772404d23d25482379fe3f21dee54f599350d8/frontend/server.js#L170 to return more than just the report.

@abdonrd
Copy link
Author

abdonrd commented Oct 30, 2017

Why do you use spawn instead of use Lighthouse programmatically?

https://github.com/ebidel/lighthouse-ci/blob/c506715085ac979c5bcfe91e03c1636ea763f1bc/builder/server.js#L18-L34


Also, I just see as you request json format, we haven't the html report.
(I think we also should remove the hardcoded builder url)

https://github.com/ebidel/lighthouse-ci/blob/c506715085ac979c5bcfe91e03c1636ea763f1bc/frontend/lighthouse-ci.js#L41-L57

@ebidel
Copy link
Contributor

ebidel commented Oct 30, 2017

spawn gives us a process to collect the log output.

I think we also should remove the hardcoded builder url

Why?

@abdonrd
Copy link
Author

abdonrd commented Oct 31, 2017

Updating the PR...

lighthouse --output-path=reports/1509419134361 --output=json --output=html

Returns:

Printer json output written to /reports/1509419134361.report.json
Printer html output written to /reports/1509419134361.report.html

Image working:

screen shot 2017-10-30 at 23 25 27


Why?

To run the project locally, we need to have localhost instead of builder-dot-lighthouse-ci.appspot.com.

if (!url) {
res.status(400).send('Please provide a URL.');
return;
}

const file = `report.${Date.now()}.${format}`;
const fileName = `${Date.now()}`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's keep the file extension

Copy link
Author

@abdonrd abdonrd Oct 31, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed because when run:

lighthouse --output-path=reports/1509419134361 --output=json --output=html

Returns:

Printer json output written to /reports/1509419134361.report.json
Printer html output written to /reports/1509419134361.report.html

It already has the .report.{extension}.

if (!url) {
res.status(400).send('Please provide a URL.');
return;
}

const file = `report.${Date.now()}.${format}`;
const fileName = `${Date.now()}`;
const fileSavePath = `reports/${fileName}`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you run this locally in Docker? Is the reports directory accessible and have the correct permissions?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not. 😞

screen shot 2017-10-30 at 23 44 52

(I had not used docker before 😅 )

const args = [
`--output-path=${fileSavePath}`,
`--output=${format}`,
'--output=html',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we remove it, we will not have the .html report. 😕

const child = spawn('lighthouse', [...args, url]);

child.stderr.on('data', data => {
console.log(data.toString());
});

child.on('close', statusCode => {
const serverOrigin = `https://${req.host}/`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https isn't going to work locally.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const serverOrigin = `https://${req.host}/`;

const file = `${fileSavePath}.report.${format}`;
let fileContent = require(`/${file}`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this wont be JS if the format that was required is html....

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, right! I have treated it as if it could only be a json file.

@abdonrd abdonrd closed this Jul 10, 2019
@robinmetral
Copy link

Just found this, what happened @abdonrd @ebidel? Can we pick up here or was it a dead end? The issue is still open 🙂

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Proposal: Add link to the report in the bot comment
3 participants