From 0dacedd6cc90f7e278b2e2aa08e7a887fc71eec8 Mon Sep 17 00:00:00 2001
From: Max Ostapenko <1611259+max-ostapenko@users.noreply.github.com>
Date: Sat, 21 Sep 2024 20:54:04 +0000
Subject: [PATCH 1/9] commenting
---
tests/wpt.js | 32 +++++++++++++++++++-------------
1 file changed, 19 insertions(+), 13 deletions(-)
diff --git a/tests/wpt.js b/tests/wpt.js
index 4ae2d1f..df639fa 100644
--- a/tests/wpt.js
+++ b/tests/wpt.js
@@ -11,6 +11,7 @@ class WPTTestRunner {
const wptApiKey = process.env.WPT_API_KEY;
this.wpt = new WebPageTest(this.wptServer, wptApiKey);
this.testResultsFile = 'comment.md';
+ this.artifactFile = 'artifact.md';
this.uploadArtifact = false;
}
@@ -40,20 +41,21 @@ class WPTTestRunner {
* Check if the test results are too big for a comment
* @param {number} stringLength Length of the test results string
*/
- checkCommentSize(stringLength) {
+ checkCommentSizeLimitHit(stringLength) {
let commentSize = 0;
try {
- commentSize = fs.statSync(testResultsFile).size;
+ commentSize = fs.statSync(this.testResultsFile).size;
} catch (err) { }
if (commentSize + stringLength > 65536) {
- const artifactFile = 'artifact.md';
this.uploadArtifact = true;
if (commentSize > 0) {
- fs.renameSync(this.testResultsFile, artifactFile);
+ fs.renameSync(this.testResultsFile, this.artifactFile);
}
- fs.appendFileSync(this.testResultsFile, `Webpage test results that are too big for a comment are available as [the action's artifact]({artifact-url}).`);
- this.testResultsFile = artifactFile;
+ fs.appendFileSync(this.testResultsFile, `Webpage test results are too big for a comment - [download them as an artifact]({artifact-url}).`);
+ return true;
+ } else {
+ return false;
}
}
@@ -75,7 +77,6 @@ class WPTTestRunner {
});
}
-
/**
* Run a WebPageTest test for a given URL
* @param {string} url URL to test
@@ -102,19 +103,24 @@ class WPTTestRunner {
const metricsToLogObject = this.extractLogMetrics(metricsObject, metricsToLog);
const metricsToLogString = JSON.stringify(metricsToLogObject, null, 2);
- if (!this.uploadArtifact) {
- this.checkCommentSize(metricsToLogString.length);
- }
-
- fs.appendFileSync(this.testResultsFile, `
+ let WPTResults = `
Custom metrics for ${url}
WPT test run results: ${response.data.summary}
+`,
+ metricsObjectResult = `
Changed custom metrics values:
\`\`\`json
${metricsToLogString}
\`\`\`
- \n\n`);
+ \n\n`;
+
+ if (!this.uploadArtifact && !this.checkCommentSizeLimitHit(metricsToLogString.length)) {
+ fs.appendFileSync(this.testResultsFile, WPTResults + metricsObjectResult);
+ } else {
+ fs.appendFileSync(this.testResultsFile, WPTResults);
+ fs.appendFileSync(this.artifactFile, WPTResults + metricsObjectResult);
+ }
console.log('::endgroup::');
return metricsObject;
From f4c6adc1b55908ae1d513bbd111e0a8148a273f1 Mon Sep 17 00:00:00 2001
From: Max Ostapenko <1611259+max-ostapenko@users.noreply.github.com>
Date: Sat, 21 Sep 2024 20:54:52 +0000
Subject: [PATCH 2/9] test metric change
---
dist/css-variables.js | 1 +
1 file changed, 1 insertion(+)
diff --git a/dist/css-variables.js b/dist/css-variables.js
index 16dfa84..31f9a26 100644
--- a/dist/css-variables.js
+++ b/dist/css-variables.js
@@ -1,6 +1,7 @@
//[css-variables]
function analyzeVariables() {
+
const PREFIX = "almanac-var2020-";
// Selector to find elements that are relevant to the graph
From 967097f95e7b92cef6f4fd323d0442a3cd488715 Mon Sep 17 00:00:00 2001
From: Max Ostapenko <1611259+max-ostapenko@users.noreply.github.com>
Date: Sat, 21 Sep 2024 21:11:35 +0000
Subject: [PATCH 3/9] formatting
---
tests/wpt.js | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/tests/wpt.js b/tests/wpt.js
index df639fa..f68040d 100644
--- a/tests/wpt.js
+++ b/tests/wpt.js
@@ -41,7 +41,7 @@ class WPTTestRunner {
* Check if the test results are too big for a comment
* @param {number} stringLength Length of the test results string
*/
- checkCommentSizeLimitHit(stringLength) {
+ commentSizeLimitHit(stringLength) {
let commentSize = 0;
try {
commentSize = fs.statSync(this.testResultsFile).size;
@@ -49,10 +49,9 @@ class WPTTestRunner {
if (commentSize + stringLength > 65536) {
this.uploadArtifact = true;
- if (commentSize > 0) {
- fs.renameSync(this.testResultsFile, this.artifactFile);
- }
- fs.appendFileSync(this.testResultsFile, `Webpage test results are too big for a comment - [download them as an artifact]({artifact-url}).`);
+ fs.appendFileSync(this.testResultsFile, `
+Next Webpage test results are too big for a comment - [download them as an artifact]({artifact-url}).
+ `);
return true;
} else {
return false;
@@ -115,10 +114,14 @@ ${metricsToLogString}
\`\`\`
\n\n`;
- if (!this.uploadArtifact && !this.checkCommentSizeLimitHit(metricsToLogString.length)) {
+ if (!this.uploadArtifact && !this.commentSizeLimitHit(metricsToLogString.length)) {
fs.appendFileSync(this.testResultsFile, WPTResults + metricsObjectResult);
} else {
- fs.appendFileSync(this.testResultsFile, WPTResults);
+ fs.appendFileSync(this.testResultsFile, `
+Custom metrics for ${url}
+
+WPT test run results: ${response.data.summary}
+`);
fs.appendFileSync(this.artifactFile, WPTResults + metricsObjectResult);
}
From 0c6a8ba775ea271ab7b4b07429fd74f82ba09ab4 Mon Sep 17 00:00:00 2001
From: Max Ostapenko <1611259+max-ostapenko@users.noreply.github.com>
Date: Sat, 21 Sep 2024 21:20:19 +0000
Subject: [PATCH 4/9] typo
---
tests/wpt.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/wpt.js b/tests/wpt.js
index f68040d..f2103ec 100644
--- a/tests/wpt.js
+++ b/tests/wpt.js
@@ -50,7 +50,7 @@ class WPTTestRunner {
if (commentSize + stringLength > 65536) {
this.uploadArtifact = true;
fs.appendFileSync(this.testResultsFile, `
-Next Webpage test results are too big for a comment - [download them as an artifact]({artifact-url}).
+Next WebPageTest results are too big for a comment - [download them as an artifact]({artifact-url}).
`);
return true;
} else {
From feb35e36dd1ba3d2f9aea9e1bf44192b30ee05e5 Mon Sep 17 00:00:00 2001
From: Max Ostapenko <1611259+max-ostapenko@users.noreply.github.com>
Date: Sat, 21 Sep 2024 21:20:27 +0000
Subject: [PATCH 5/9] formatting
---
dist/css-variables.js | 419 +++++++++++++++++++++---------------------
1 file changed, 209 insertions(+), 210 deletions(-)
diff --git a/dist/css-variables.js b/dist/css-variables.js
index 31f9a26..bc57282 100644
--- a/dist/css-variables.js
+++ b/dist/css-variables.js
@@ -1,287 +1,286 @@
//[css-variables]
function analyzeVariables() {
+ const PREFIX = "almanac-var2020-";
-const PREFIX = "almanac-var2020-";
+ // Selector to find elements that are relevant to the graph
+ const selector = `.${PREFIX}element, [style*="--"]`;
-// Selector to find elements that are relevant to the graph
-const selector = `.${PREFIX}element, [style*="--"]`;
+ // Extract a list of custom properties set by a value
+ function extractValueProperties(value) {
+ // https://drafts.csswg.org/css-syntax-3/#ident-token-diagram
+ let ret = value.match(/var\(--[-\w\u{0080}-\u{FFFF}]+(?=[,)])/gui)?.map(p => p.slice(4));
-// Extract a list of custom properties set by a value
-function extractValueProperties(value) {
- // https://drafts.csswg.org/css-syntax-3/#ident-token-diagram
- let ret = value.match(/var\(--[-\w\u{0080}-\u{FFFF}]+(?=[,)])/gui)?.map(p => p.slice(4));
-
- if (ret) {
- // Drop duplicates
- return [...new Set(ret)];
- }
-}
-
-let visited = new Set();
-let modifiedRules = [];
-
-// Recursively walk a CSSStyleRule or CSSStyleDeclaration
-function walkRule(rule, ret) {
- if (!rule || visited.has(rule)) {
- return;
+ if (ret) {
+ // Drop duplicates
+ return [...new Set(ret)];
+ }
}
- visited.add(rule);
-
- let style, selector;
-
- if (rule instanceof CSSStyleRule && rule.style) {
- style = rule.style;
- selector = rule.selectorText;
- }
- else if (rule instanceof CSSStyleDeclaration) {
- style = rule;
- selector = "";
- }
+ let visited = new Set();
+ let modifiedRules = [];
- if (style) {
- let condition;
- // mirror properties to add. We add them afterwards, so we don't pointlessly traverse them
- let additions = {};
+ // Recursively walk a CSSStyleRule or CSSStyleDeclaration
+ function walkRule(rule, ret) {
+ if (!rule || visited.has(rule)) {
+ return;
+ }
- for (let property of style) {
- let value = style.getPropertyValue(property);
+ visited.add(rule);
- let containsRef = value.indexOf("var(--") > -1;
- let setsVar = property.indexOf("--") === 0 && property.indexOf("--" + PREFIX) === -1;
+ let style, selector;
- if (containsRef || setsVar) {
- if (!condition && rule.parentRule) {
- condition = [];
- let r = rule;
+ if (rule instanceof CSSStyleRule && rule.style) {
+ style = rule.style;
+ selector = rule.selectorText;
+ }
+ else if (rule instanceof CSSStyleDeclaration) {
+ style = rule;
+ selector = "";
+ }
- while (r.parentRule?.conditionText) {
- r = r.parentRule;
- condition.push({
- type: r instanceof CSSMediaRule? "media" : "supports",
- test: r.conditionText
- });
+ if (style) {
+ let condition;
+ // mirror properties to add. We add them afterwards, so we don't pointlessly traverse them
+ let additions = {};
+
+ for (let property of style) {
+ let value = style.getPropertyValue(property);
+
+ let containsRef = value.indexOf("var(--") > -1;
+ let setsVar = property.indexOf("--") === 0 && property.indexOf("--" + PREFIX) === -1;
+
+ if (containsRef || setsVar) {
+ if (!condition && rule.parentRule) {
+ condition = [];
+ let r = rule;
+
+ while (r.parentRule?.conditionText) {
+ r = r.parentRule;
+ condition.push({
+ type: r instanceof CSSMediaRule ? "media" : "supports",
+ test: r.conditionText
+ });
+ }
}
- }
- if (containsRef) {
- // Set mirror property so we can find it in the computed style
- additions["--" + PREFIX + property] = value.replace(/var\(--/g, PREFIX + "$&");
+ if (containsRef) {
+ // Set mirror property so we can find it in the computed style
+ additions["--" + PREFIX + property] = value.replace(/var\(--/g, PREFIX + "$&");
- let properties = extractValueProperties(value);
+ let properties = extractValueProperties(value);
- for (let prop of properties) {
- let info = ret[prop] = ret[prop] || {get: [], set: []};
- info.get.push({ usedIn: property, value, selector, condition });
+ for (let prop of properties) {
+ let info = ret[prop] = ret[prop] || { get: [], set: [] };
+ info.get.push({ usedIn: property, value, selector, condition });
+ }
}
- }
- if (setsVar) {
- let info = ret[property] = ret[property] || {get: [], set: []};
- info.set.push({ value, selector, condition });
- }
+ if (setsVar) {
+ let info = ret[property] = ret[property] || { get: [], set: [] };
+ info.set.push({ value, selector, condition });
+ }
- // Add class so we can find these later
- if (selector) {
- for (let el of document.querySelectorAll(selector)) {
- el.classList.add(`${PREFIX}element`);
+ // Add class so we can find these later
+ if (selector) {
+ for (let el of document.querySelectorAll(selector)) {
+ el.classList.add(`${PREFIX}element`);
+ }
}
}
}
- }
- // Now that we're done, add the mirror properties
- for (let property in additions) {
- modifiedRules.push({style, additions});
- style.setProperty(property, additions[property]);
+ // Now that we're done, add the mirror properties
+ for (let property in additions) {
+ modifiedRules.push({ style, additions });
+ style.setProperty(property, additions[property]);
+ }
}
- }
- if (rule instanceof CSSMediaRule || rule instanceof CSSSupportsRule) {
- // rules with child rules, e.g. @media, @supports
- for (let r of rule.cssRules) {
- walkRule(r, ret);
+ if (rule instanceof CSSMediaRule || rule instanceof CSSSupportsRule) {
+ // rules with child rules, e.g. @media, @supports
+ for (let r of rule.cssRules) {
+ walkRule(r, ret);
+ }
}
}
-}
-// Return a subset of the DOM tree that contains variable reads or writes
-function buildGraph() {
- // Elements that contain variable reads or writes.
- let elements = new Set(document.querySelectorAll(selector));
- let map = new Map(); // keep pointers to object for each element
- let ret = [];
+ // Return a subset of the DOM tree that contains variable reads or writes
+ function buildGraph() {
+ // Elements that contain variable reads or writes.
+ let elements = new Set(document.querySelectorAll(selector));
+ let map = new Map(); // keep pointers to object for each element
+ let ret = [];
- for (let element of elements) {
- map.set(element, {element, children: []});
- }
+ for (let element of elements) {
+ map.set(element, { element, children: [] });
+ }
- for (let element of elements) {
- let ancestor = element.parentNode.closest?.(selector);
- let obj = map.get(element);
+ for (let element of elements) {
+ let ancestor = element.parentNode.closest?.(selector);
+ let obj = map.get(element);
- if (ancestor) {
- let o = map.get(ancestor);
- o.children.push(obj)
- }
- else {
- // Top-level
- ret.push(obj);
- }
+ if (ancestor) {
+ let o = map.get(ancestor);
+ o.children.push(obj)
+ }
+ else {
+ // Top-level
+ ret.push(obj);
+ }
- let cs = element.computedStyleMap();
- let parentCS = element.parentNode.computedStyleMap?.();
- let vars = extractVars(cs, parentCS);
+ let cs = element.computedStyleMap();
+ let parentCS = element.parentNode.computedStyleMap?.();
+ let vars = extractVars(cs, parentCS);
- if (Object.keys(vars).length > 0) {
- obj.declarations = vars;
+ if (Object.keys(vars).length > 0) {
+ obj.declarations = vars;
+ }
}
- }
- return ret;
-}
+ return ret;
+ }
-// Extract custom property declarations from a computed style map
-// The schema of the returned object is:
-// {get: {--var1: [{property, value, computedValue}]}, set: {--var2: {value, type}}}
-function extractVars(cs, parentCS) {
- let ret = {};
- let norefs = {};
-
- for (let [property, [originalValue]] of cs) {
- // Do references first
- if (property.indexOf("--") === 0) {
- let value = originalValue + "";
-
- // Skip inherited values
- if (parentCS && (parentCS.get(property) + "" === value + "")) {
- continue; // most likely inherited
- }
+ // Extract custom property declarations from a computed style map
+ // The schema of the returned object is:
+ // {get: {--var1: [{property, value, computedValue}]}, set: {--var2: {value, type}}}
+ function extractVars(cs, parentCS) {
+ let ret = {};
+ let norefs = {};
+
+ for (let [property, [originalValue]] of cs) {
+ // Do references first
+ if (property.indexOf("--") === 0) {
+ let value = originalValue + "";
+
+ // Skip inherited values
+ if (parentCS && (parentCS.get(property) + "" === value + "")) {
+ continue; // most likely inherited
+ }
- if (property.indexOf("--" + PREFIX) === 0) {
- // Usage
- let originalProperty = property.replace("--" + PREFIX, "");
+ if (property.indexOf("--" + PREFIX) === 0) {
+ // Usage
+ let originalProperty = property.replace("--" + PREFIX, "");
- value = value.replace(RegExp(PREFIX + "var\\(--", "g"), "var(--");
- let properties = extractValueProperties(value);
- let computed = cs.get(originalProperty) + "";
+ value = value.replace(RegExp(PREFIX + "var\\(--", "g"), "var(--");
+ let properties = extractValueProperties(value);
+ let computed = cs.get(originalProperty) + "";
- ret[originalProperty] = {
- value,
- references: properties
- }
+ ret[originalProperty] = {
+ value,
+ references: properties
+ }
- if (computed !== value) {
- ret[originalProperty].computed = computed;
+ if (computed !== value) {
+ ret[originalProperty].computed = computed;
+ }
}
- }
- else {
- // Definition
- norefs[property] = {value};
+ else {
+ // Definition
+ norefs[property] = { value };
- if (originalValue + "" !== value) {
- norefs[property].computed = originalValue + "";
- }
+ if (originalValue + "" !== value) {
+ norefs[property].computed = originalValue + "";
+ }
- // If value is of another type, we have Houdini P&V usage!
- if (!(originalValue instanceof CSSUnparsedValue)) {
- norefs[property].type = Object.prototype.toString.call(originalValue).slice(8, -1);
+ // If value is of another type, we have Houdini P&V usage!
+ if (!(originalValue instanceof CSSUnparsedValue)) {
+ norefs[property].type = Object.prototype.toString.call(originalValue).slice(8, -1);
+ }
}
}
}
- }
- // Merge static with ret
- for (let property in norefs) {
- if (!(property in ret)) {
- ret[property] = norefs[property];
+ // Merge static with ret
+ for (let property in norefs) {
+ if (!(property in ret)) {
+ ret[property] = norefs[property];
+ }
}
- }
- return ret;
-}
+ return ret;
+ }
-let summary = {};
+ let summary = {};
-// Walk through stylesheet and add custom properties for every declaration that uses var()
-// This way we can retrieve them in the computed styles and build a dependency graph.
-// Otherwise, they get resolved before they hit the computed style.
-for (let stylesheet of document.styleSheets) {
- try {
- var rules = stylesheet.cssRules;
- }
- catch (e) {}
+ // Walk through stylesheet and add custom properties for every declaration that uses var()
+ // This way we can retrieve them in the computed styles and build a dependency graph.
+ // Otherwise, they get resolved before they hit the computed style.
+ for (let stylesheet of document.styleSheets) {
+ try {
+ var rules = stylesheet.cssRules;
+ }
+ catch (e) { }
- if (rules) {
- for (let rule of rules) {
- walkRule(rule, summary);
+ if (rules) {
+ for (let rule of rules) {
+ walkRule(rule, summary);
+ }
}
}
-}
-function collapseDuplicateSiblings(arr) {
- if (arr) {
- let map = {};
+ function collapseDuplicateSiblings(arr) {
+ if (arr) {
+ let map = {};
- for (let child of arr) {
- let serialized = serialize(child);
+ for (let child of arr) {
+ let serialized = serialize(child);
- if (serialized in map) {
- // Dupe
- map[serialized]++;
- }
- else {
- map[serialized] = 0;
+ if (serialized in map) {
+ // Dupe
+ map[serialized]++;
+ }
+ else {
+ map[serialized] = 0;
+ }
}
- }
- let entries = Object.entries(map);
+ let entries = Object.entries(map);
- if (entries.length < arr.length) {
- // There are duplicates
- arr = entries.map(e => {
- let child = JSON.parse(e[0]);
+ if (entries.length < arr.length) {
+ // There are duplicates
+ arr = entries.map(e => {
+ let child = JSON.parse(e[0]);
- if (e[1] > 0) {
- child.times = e[1] + 1;
- }
+ if (e[1] > 0) {
+ child.times = e[1] + 1;
+ }
+
+ return child;
+ })
+ }
- return child;
- })
+ arr.forEach(o => {
+ o.children = collapseDuplicateSiblings(o.children);
+ });
}
- arr.forEach(o => {
- o.children = collapseDuplicateSiblings(o.children);
- });
+ return arr;
}
- return arr;
-}
-
-// Do the same thing with inline styles
-for (let element of document.querySelectorAll('[style*="--"]')) {
- walkRule(element.style, summary);
-}
+ // Do the same thing with inline styles
+ for (let element of document.querySelectorAll('[style*="--"]')) {
+ walkRule(element.style, summary);
+ }
-let computed = buildGraph();
+ let computed = buildGraph();
-// Cleanup: Remove classes
-for (let el of document.querySelectorAll(`.${PREFIX}element`)) {
- el.classList.remove(`${PREFIX}element`);
-}
+ // Cleanup: Remove classes
+ for (let el of document.querySelectorAll(`.${PREFIX}element`)) {
+ el.classList.remove(`${PREFIX}element`);
+ }
-// Cleanup: Remove custom properties
-for (let o of modifiedRules) {
- for (let prop in o.additions) {
- o.style.removeProperty(prop);
+ // Cleanup: Remove custom properties
+ for (let o of modifiedRules) {
+ for (let prop in o.additions) {
+ o.style.removeProperty(prop);
+ }
}
-}
-computed = collapseDuplicateSiblings(computed);
+ computed = collapseDuplicateSiblings(computed);
-return {summary, computed};
+ return { summary, computed };
};
From d6289169b34286cb80b79288718c2abc70c95539 Mon Sep 17 00:00:00 2001
From: Max Ostapenko <1611259+max-ostapenko@users.noreply.github.com>
Date: Sun, 22 Sep 2024 21:44:32 +0000
Subject: [PATCH 6/9] comment restructured
---
.github/workflows/wpt-test.yml | 16 -------------
tests/wpt.js | 44 +++++++++++++---------------------
2 files changed, 17 insertions(+), 43 deletions(-)
diff --git a/.github/workflows/wpt-test.yml b/.github/workflows/wpt-test.yml
index 27a3836..c2bb596 100644
--- a/.github/workflows/wpt-test.yml
+++ b/.github/workflows/wpt-test.yml
@@ -35,22 +35,6 @@ jobs:
WPT_API_KEY: ${{ secrets.HA_API_KEY }}
PR_BODY: ${{ github.event.pull_request.body }}
- - name: Upload artifact if needed
- id: artifact-upload-step
- uses: actions/upload-artifact@v4
- with:
- path: artifact.md
-
- - name: Update comment.md
- run: |
- if grep -q "{artifact-url}" comment.md; then
- artifact_url="${{ steps.artifact-upload-step.outputs.artifact-url }}"
- sed -i "s|{artifact-url}|$artifact_url|g" comment.md
- echo "Placeholder {artifact-url} replaced with a value: $artifact_url."
- else
- echo "No placeholder {artifact-url} found in comment.md."
- fi
-
- name: Add comment to PR
uses: mshick/add-pr-comment@v2
if: always()
diff --git a/tests/wpt.js b/tests/wpt.js
index f2103ec..f1bbeb2 100644
--- a/tests/wpt.js
+++ b/tests/wpt.js
@@ -11,8 +11,7 @@ class WPTTestRunner {
const wptApiKey = process.env.WPT_API_KEY;
this.wpt = new WebPageTest(this.wptServer, wptApiKey);
this.testResultsFile = 'comment.md';
- this.artifactFile = 'artifact.md';
- this.uploadArtifact = false;
+ this.commentSizeLimitHit = false;
}
/**
@@ -41,21 +40,15 @@ class WPTTestRunner {
* Check if the test results are too big for a comment
* @param {number} stringLength Length of the test results string
*/
- commentSizeLimitHit(stringLength) {
- let commentSize = 0;
- try {
- commentSize = fs.statSync(this.testResultsFile).size;
- } catch (err) { }
-
- if (commentSize + stringLength > 65536) {
- this.uploadArtifact = true;
- fs.appendFileSync(this.testResultsFile, `
-Next WebPageTest results are too big for a comment - [download them as an artifact]({artifact-url}).
- `);
- return true;
- } else {
- return false;
+ checkCommentSizeLimit(stringLength) {
+ let commentSize = fs.statSync(this.testResultsFile, throwIfNoEntry=false) ?
+ fs.statSync(this.testResultsFile, throwIfNoEntry=false)?.size : 0;
+
+ if (commentSize + stringLength > 64500) {
+ this.commentSizeLimitHit = true;
}
+
+ return this.commentSizeLimitHit;
}
/**
@@ -102,27 +95,24 @@ Next WebPageTest results are too big for a comment - [download them as an artifa
const metricsToLogObject = this.extractLogMetrics(metricsObject, metricsToLog);
const metricsToLogString = JSON.stringify(metricsToLogObject, null, 2);
- let WPTResults = `
-Custom metrics for ${url}
+ let WPTResults = `${url}
-WPT test run results: ${response.data.summary}
-`,
+[WPT test results](${response.data.summary})\n`,
metricsObjectResult = `
Changed custom metrics values:
\`\`\`json
${metricsToLogString}
\`\`\`
+ \n\n`,
+ metricsObjectJSON = `
+Cannot display changed custom metrics due to comment size limits, \
+use [test JSON](https://webpagetest.httparchive.org/jsonResult.php?test=${response.data.id}&pretty=1) instead.
\n\n`;
- if (!this.uploadArtifact && !this.commentSizeLimitHit(metricsToLogString.length)) {
+ if (!this.commentSizeLimitHit && !this.checkCommentSizeLimit(metricsToLogString.length)) {
fs.appendFileSync(this.testResultsFile, WPTResults + metricsObjectResult);
} else {
- fs.appendFileSync(this.testResultsFile, `
-Custom metrics for ${url}
-
-WPT test run results: ${response.data.summary}
-`);
- fs.appendFileSync(this.artifactFile, WPTResults + metricsObjectResult);
+ fs.appendFileSync(this.testResultsFile, WPTResults + metricsObjectJSON);
}
console.log('::endgroup::');
From 5b935fb2d25ce2f8072f2b212ae613ad0030b612 Mon Sep 17 00:00:00 2001
From: Max Ostapenko <1611259+max-ostapenko@users.noreply.github.com>
Date: Sun, 22 Sep 2024 21:59:32 +0000
Subject: [PATCH 7/9] options fix
---
tests/wpt.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tests/wpt.js b/tests/wpt.js
index f1bbeb2..f919748 100644
--- a/tests/wpt.js
+++ b/tests/wpt.js
@@ -41,8 +41,8 @@ class WPTTestRunner {
* @param {number} stringLength Length of the test results string
*/
checkCommentSizeLimit(stringLength) {
- let commentSize = fs.statSync(this.testResultsFile, throwIfNoEntry=false) ?
- fs.statSync(this.testResultsFile, throwIfNoEntry=false)?.size : 0;
+ let commentSize = fs.statSync('comment.md', { throwIfNoEntry: false }) ?
+ fs.statSync('comment.md', {throwIfNoEntry: false})?.size : 0;
if (commentSize + stringLength > 64500) {
this.commentSizeLimitHit = true;
From d4b52a424e1794fbf81afdc86b463e0b84b48e67 Mon Sep 17 00:00:00 2001
From: Barry Pollard
Date: Wed, 25 Sep 2024 19:07:16 +0100
Subject: [PATCH 8/9] Limit data URLs in css-variables (#145)
---
dist/css-variables.js | 3 +++
1 file changed, 3 insertions(+)
diff --git a/dist/css-variables.js b/dist/css-variables.js
index bc57282..53a54f8 100644
--- a/dist/css-variables.js
+++ b/dist/css-variables.js
@@ -46,6 +46,9 @@ function analyzeVariables() {
for (let property of style) {
let value = style.getPropertyValue(property);
+ if (value.startsWith("url(\"data:image/svg+xml") && value.length > 54) {
+ value = value.slice(0, 50) + '…' + "\");";
+ }
let containsRef = value.indexOf("var(--") > -1;
let setsVar = property.indexOf("--") === 0 && property.indexOf("--" + PREFIX) === -1;
From 3204def5900d9b56e6d26492812a6a2dd957e9d9 Mon Sep 17 00:00:00 2001
From: Max Ostapenko <1611259+max-ostapenko@users.noreply.github.com>
Date: Mon, 14 Oct 2024 18:42:47 +0200
Subject: [PATCH 9/9] link updates
---
tests/wpt.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tests/wpt.js b/tests/wpt.js
index f919748..f490b03 100644
--- a/tests/wpt.js
+++ b/tests/wpt.js
@@ -97,7 +97,7 @@ class WPTTestRunner {
let WPTResults = `${url}
-[WPT test results](${response.data.summary})\n`,
+[WPT result details](https://webpagetest.httparchive.org/result/${response.data.id}/1/details/#result)\n`,
metricsObjectResult = `
Changed custom metrics values:
\`\`\`json
@@ -106,7 +106,7 @@ ${metricsToLogString}
\n\n`,
metricsObjectJSON = `
Cannot display changed custom metrics due to comment size limits, \
-use [test JSON](https://webpagetest.httparchive.org/jsonResult.php?test=${response.data.id}&pretty=1) instead.
+[view test JSON](https://webpagetest.httparchive.org/jsonResult.php?test=${response.data.id}&pretty=1) instead.
\n\n`;
if (!this.commentSizeLimitHit && !this.checkCommentSizeLimit(metricsToLogString.length)) {