Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ jobs:
- run: npm run build
- name: Run Lighthouse Check
run: |
node ./dist/bin/lighthouse-check.js --verbose \
--urls "https://www.foo.software" \
--prCommentEnabled \
node ./dist/bin/lighthouse-check.js --verbose --prCommentEnabled \
--emulatedFormFactor "all" \
--urls "https://www.foo.software,https://www.automated-lighthouse-check.com/" \
--prCommentAccessToken "${{ secrets.LIGHTHOUSE_CHECK_GITHUB_ACCESS_TOKEN }}" \
--prCommentUrl "https://api.github.com/repos/foo-software/lighthouse-check/pulls/$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }')/reviews"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ Below are options for the exported `lighthouseCheck` function or `lighthouse-che
<tr>
<td><code>emulatedFormFactor</code></td>
<td>Lighthouse setting only used for local audits. See <a href="src/lighthouseConfig.js">src/lighthouseConfig.js</a> comments for details.</td>
<td><code>oneOf(['mobile', 'desktop']</code></td>
<td><code>oneOf(['mobile', 'desktop', 'all'])</code></td>
<td><code>local</code></td>
<td><code>undefined</code></td>
<td>no</td>
Expand Down
2 changes: 1 addition & 1 deletion src/lighthouseCheck.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default ({
awsBucket,
awsRegion,
awsSecretAccessKey,
emulatedFormFactor,
emulatedFormFactor = 'mobile',
extraHeaders,
branch,
isGitHubAction,
Expand Down
43 changes: 34 additions & 9 deletions src/localLighthouse.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export const localLighthouse = async ({
url,
localReport,
report,
emulatedFormFactor,
scores
};
};
Expand Down Expand Up @@ -139,15 +140,12 @@ export default async ({
}
}

const auditResults = [];
let index = 1;
// a list of audit configurations
const auditConfigs = [];

// collect all audit configs
for (const url of urls) {
if (verbose) {
console.log(`${NAME}: Auditing (${index}/${urls.length}) ${url}`);
}

const lighthouseAuditResult = await localLighthouse({
const options = {
awsAccessKeyId,
awsBucket,
awsRegion,
Expand All @@ -160,9 +158,36 @@ export default async ({
overrides,
throttling,
throttlingMethod,
url
});
url,
verbose
};

if (options.emulatedFormFactor !== 'all') {
auditConfigs.push(options);
} else {
// establish two audits for all device types
auditConfigs.push({
...options,
emulatedFormFactor: 'desktop'
});
auditConfigs.push({
...options,
emulatedFormFactor: 'mobile'
});
}
}

const auditResults = [];
let index = 1;

// for each audit config, run the audit
for (const auditConfig of auditConfigs) {
if (verbose) {
console.log(
`${NAME}: Auditing ${auditConfig.emulatedFormFactor} (${index}/${auditConfigs.length}): ${auditConfig.url}`
);
}
const lighthouseAuditResult = await localLighthouse(auditConfig);
auditResults.push(lighthouseAuditResult);
index++;
}
Expand Down
3 changes: 3 additions & 0 deletions src/postPrComment.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ export default async ({
});
});

// the emulatedformfactor
markdown += `\n\n Device: **${result.emulatedFormFactor}**`;

// the url
markdown += `\n\n${result.url}`;

Expand Down