From 3ac3c8b11d599a5c541b3edaddf127dc51eb3f2f Mon Sep 17 00:00:00 2001 From: minsu-zip Date: Mon, 12 Aug 2024 20:32:44 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20results=20=EB=B3=80=EC=88=98=EB=A5=BC=20?= =?UTF-8?q?=EC=A0=95=EC=9D=98=ED=95=98=EC=A7=80=20=EC=95=8A=EA=B3=A0=20?= =?UTF-8?q?=EC=82=AC=EC=9A=A9=ED=95=98=EB=A0=A4=EA=B3=A0=20=ED=95=B4?= =?UTF-8?q?=EC=84=9C=20=EB=B0=9C=EC=83=9D=ED=95=9C=20=EC=97=90=EB=9F=AC=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/lhciFormat.js | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/scripts/lhciFormat.js b/scripts/lhciFormat.js index 8f10d95..d7c97a1 100644 --- a/scripts/lhciFormat.js +++ b/scripts/lhciFormat.js @@ -22,17 +22,13 @@ const getComment = (performance) => ].join("\n") module.exports = async ({ core }) => { + const resultsInput = core.getInput("lighthouse-results") // GitHub Actions에서 입력을 받음 + const results = JSON.parse(resultsInput) // 입력을 JSON으로 파싱 let comments = "" results.forEach((result) => { - const { summary, jsonPath } = result - const details = JSON.parse(fs.readFileSync(jsonPath)) - const { audits } = details - const summaryEntries = Object.entries(summary).map(([key, value]) => [ - key, - formatResult(value), - ]) - const { performance } = Object.fromEntries(summaryEntries) + const { audits, categories: summary } = result + const performance = formatResult(summary.performance.score * 100) const comment = getComment(performance) const detailRows = categories .map((category) => detailRow(category, audits)) @@ -41,5 +37,5 @@ module.exports = async ({ core }) => { comments += comment + "\n" + detail + "\n\n" }) - core.setOutput("comments", comments) + core.setOutput("comments", comments) // 결과를 PR에 댓글로 남김 }