From 33e42d0a1f6e167db4df176a2e7dc61dcc7a0304 Mon Sep 17 00:00:00 2001 From: Mykola Grybyk <25589559+mgrybyk@users.noreply.github.com> Date: Thu, 8 Feb 2024 13:34:46 +0100 Subject: [PATCH 1/2] add link to the latest report (#6) --- .github/workflows/report_test.yml | 2 +- README.md | 2 +- dist/index.js | 44 +++++++++++++++++++++++++++---- index.ts | 9 +++++-- package-lock.json | 4 +-- package.json | 2 +- prebuild.js | 1 + reports/chart/index.html | 6 ++--- reports/html/latest.html | 33 +++++++++++++++++++++++ src/writeLatest.ts | 7 +++++ 10 files changed, 94 insertions(+), 16 deletions(-) create mode 100644 reports/html/latest.html create mode 100644 src/writeLatest.ts diff --git a/.github/workflows/report_test.yml b/.github/workflows/report_test.yml index bd7dc97..778ef3f 100644 --- a/.github/workflows/report_test.yml +++ b/.github/workflows/report_test.yml @@ -84,7 +84,6 @@ jobs: outFile=test-results/Allure_Trend.csv echo Passed,Failed,Total > $outFile echo ${{ steps.allure.outputs.test_result_passed }},${{ steps.allure.outputs.test_result_failed }},${{ steps.allure.outputs.test_result_total }} >> $outFile - - name: Local HTML Report if: always() uses: ./ # Uses an action in the root directory @@ -127,6 +126,7 @@ jobs: with: repository: gh-pages-dir branch: gh-pages + pull_args: --rebase -X ours - name: Comment PR with Allure Report link if: ${{ always() && github.event_name == 'pull_request' && (steps.allure.outputs.report_url || steps.html-1.outputs.report_url || steps.chart-2.outputs.report_url) }} diff --git a/README.md b/README.md index aaf76cd..96639f1 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ See examples: - [CSV report, single file, Allure Trend](https://mgrybyk.github.io/html-trend-report-action/report-action/main/Allure%20Trend%20Report/) - [CSV report, multiple files, Lighthouse Trend](https://mgrybyk.github.io/html-trend-report-action/report-action/main/Lighthouse%20Trend%20Report/) -- [HTML Report](https://mgrybyk.github.io/html-trend-report-action/report-action/main/Lighthouse%20Report/7784322733_1707135682151/) +- [HTML Report](https://mgrybyk.github.io/html-trend-report-action/report-action/main/Lighthouse%20Report/latest.html) - [HTML Report history](https://mgrybyk.github.io/html-trend-report-action/report-action/main/Lighthouse%20Report/) - [Browse different branches](https://mgrybyk.github.io/html-trend-report-action/) - [Pull Request Comment Example](https://github.com/mgrybyk/html-trend-report-action/pull/3) diff --git a/dist/index.js b/dist/index.js index 66e2bf7..9164db8 100644 --- a/dist/index.js +++ b/dist/index.js @@ -38589,8 +38589,10 @@ __nccwpck_require__.a(module, async (__webpack_handle_async_dependencies__, __we /* harmony import */ var _src_csvReport_js__WEBPACK_IMPORTED_MODULE_4__ = __nccwpck_require__(7925); /* harmony import */ var _src_isFileExists_js__WEBPACK_IMPORTED_MODULE_5__ = __nccwpck_require__(2139); /* harmony import */ var _src_writeFolderListing_js__WEBPACK_IMPORTED_MODULE_6__ = __nccwpck_require__(4362); -/* harmony import */ var _src_helpers_js__WEBPACK_IMPORTED_MODULE_8__ = __nccwpck_require__(3015); +/* harmony import */ var _src_helpers_js__WEBPACK_IMPORTED_MODULE_9__ = __nccwpck_require__(3015); /* harmony import */ var _src_cleanup_js__WEBPACK_IMPORTED_MODULE_7__ = __nccwpck_require__(646); +/* harmony import */ var _src_writeLatest_js__WEBPACK_IMPORTED_MODULE_8__ = __nccwpck_require__(2461); + @@ -38612,7 +38614,7 @@ try { const listDirsBranch = _actions_core__WEBPACK_IMPORTED_MODULE_1__.getInput('list_dirs_branch') == 'true'; const branchCleanupEnabled = _actions_core__WEBPACK_IMPORTED_MODULE_1__.getInput('branch_cleanup_enabled') == 'true'; const maxReports = parseInt(_actions_core__WEBPACK_IMPORTED_MODULE_1__.getInput('max_reports'), 10); - const branchName = (0,_src_helpers_js__WEBPACK_IMPORTED_MODULE_8__/* .getBranchName */ .L)(_actions_github__WEBPACK_IMPORTED_MODULE_2__.context.ref, _actions_github__WEBPACK_IMPORTED_MODULE_2__.context.payload.pull_request); + const branchName = (0,_src_helpers_js__WEBPACK_IMPORTED_MODULE_9__/* .getBranchName */ .L)(_actions_github__WEBPACK_IMPORTED_MODULE_2__.context.ref, _actions_github__WEBPACK_IMPORTED_MODULE_2__.context.payload.pull_request); const ghPagesBaseDir = path__WEBPACK_IMPORTED_MODULE_0__.join(ghPagesPath, baseDir); const reportBaseDir = path__WEBPACK_IMPORTED_MODULE_0__.join(ghPagesBaseDir, branchName, reportId); /** @@ -38650,6 +38652,7 @@ try { if (!['html', 'csv'].includes(reportType)) { throw new Error('Unsupported report type: ' + reportType); } + const isHtmlReport = reportType === 'html'; // action await _actions_io__WEBPACK_IMPORTED_MODULE_3__.mkdirP(reportBaseDir); // cleanup (should be before the folder listing) @@ -38660,7 +38663,7 @@ try { await (0,_src_cleanup_js__WEBPACK_IMPORTED_MODULE_7__/* .cleanupOutdatedReports */ .g)(ghPagesBaseDir, maxReports); } // process report - if (reportType === 'html') { + if (isHtmlReport) { await _actions_io__WEBPACK_IMPORTED_MODULE_3__.cp(sourceReportDir, reportDir, { recursive: true }); } else if (reportType === 'csv') { @@ -38678,10 +38681,13 @@ try { if (listDirsBranch) { await (0,_src_writeFolderListing_js__WEBPACK_IMPORTED_MODULE_6__/* .writeFolderListing */ .l)(ghPagesPath, path__WEBPACK_IMPORTED_MODULE_0__.join(baseDir, branchName)); await (0,_src_writeFolderListing_js__WEBPACK_IMPORTED_MODULE_6__/* .writeFolderListing */ .l)(ghPagesPath, path__WEBPACK_IMPORTED_MODULE_0__.join(baseDir, branchName)); - if (reportType === 'html') { + if (isHtmlReport) { await (0,_src_writeFolderListing_js__WEBPACK_IMPORTED_MODULE_6__/* .writeFolderListing */ .l)(ghPagesPath, path__WEBPACK_IMPORTED_MODULE_0__.join(baseDir, branchName, reportId)); } } + if (isHtmlReport) { + await (0,_src_writeLatest_js__WEBPACK_IMPORTED_MODULE_8__/* .writeLatestReport */ .H)(reportBaseDir); + } // outputs _actions_core__WEBPACK_IMPORTED_MODULE_1__.setOutput('report_url', reportUrl); _actions_core__WEBPACK_IMPORTED_MODULE_1__.setOutput('report_history_url', ghPagesBaseUrl); @@ -38818,7 +38824,7 @@ var v2_default = /*#__PURE__*/__nccwpck_require__.n(v2); var isFileExists = __nccwpck_require__(2139); ;// CONCATENATED MODULE: ./src/report_chart.ts // autogenerated -const chartReport = Buffer.from('PCEtLSByZXBvcnQtYWN0aW9uIC0tPgo8IWRvY3R5cGUgaHRtbD4KPGh0bWwgbGFuZz0iZW4iPgogIDxoZWFkPgogICAgPG1ldGEgY2hhcnNldD0iVVRGLTgiIC8+CiAgICA8dGl0bGU+Q2hhcnQ8L3RpdGxlPgogIDwvaGVhZD4KCiAgPGJvZHk+CiAgICA8bWFpbiBpZD0ibWFpbiI+PC9tYWluPgoKICAgIDwhLS0gaHR0cHM6Ly9jZG5qcy5jb20vbGlicmFyaWVzL0NoYXJ0LmpzIC0tPgogICAgPHNjcmlwdCBzcmM9Imh0dHBzOi8vY2RuanMuY2xvdWRmbGFyZS5jb20vYWpheC9saWJzL0NoYXJ0LmpzLzQuMy4zL2NoYXJ0LnVtZC5qcyI+PC9zY3JpcHQ+CiAgICA8IS0tIGh0dHBzOi8vZ2l0aHViLmNvbS9jaGFydGpzL2NoYXJ0anMtYWRhcHRlci1kYXRlLWZucyAtLT4KICAgIDxzY3JpcHQgc3JjPSJodHRwczovL2Nkbi5qc2RlbGl2ci5uZXQvbnBtL2NoYXJ0anMtYWRhcHRlci1kYXRlLWZuc0AzLjAuMC9kaXN0L2NoYXJ0anMtYWRhcHRlci1kYXRlLWZucy5idW5kbGUubWluLmpzIj48L3NjcmlwdD4KCiAgICA8c2NyaXB0PgogICAgICBjb25zdCBjaGFydHNSb290ID0gZG9jdW1lbnQuZ2V0RWxlbWVudEJ5SWQoJ21haW4nKQoKICAgICAgY29uc3QgQ0hBUlRfQ09MT1JTID0gewogICAgICAgIHJlZDogJ3JnYigyNTUsIDk5LCAxMzIpJywKICAgICAgICBvcmFuZ2U6ICdyZ2IoMjU1LCAxNTksIDY0KScsCiAgICAgICAgeWVsbG93OiAncmdiKDI1NSwgMjA1LCA4NiknLAogICAgICAgIGdyZWVuOiAncmdiKDc1LCAxOTIsIDE5MiknLAogICAgICAgIGJsdWU6ICdyZ2IoNTQsIDE2MiwgMjM1KScsCiAgICAgICAgcHVycGxlOiAncmdiKDE1MywgMTAyLCAyNTUpJywKICAgICAgICBncmV5OiAncmdiKDIwMSwgMjAzLCAyMDcpJywKICAgICAgfQoKICAgICAgY29uc3QgTkFNRURfQ09MT1JTID0gWwogICAgICAgIENIQVJUX0NPTE9SUy5yZWQsCiAgICAgICAgQ0hBUlRfQ09MT1JTLm9yYW5nZSwKICAgICAgICBDSEFSVF9DT0xPUlMueWVsbG93LAogICAgICAgIENIQVJUX0NPTE9SUy5ncmVlbiwKICAgICAgICBDSEFSVF9DT0xPUlMuYmx1ZSwKICAgICAgICBDSEFSVF9DT0xPUlMucHVycGxlLAogICAgICAgIENIQVJUX0NPTE9SUy5ncmV5LAogICAgICBdCgogICAgICBmZXRjaChgLi9kYXRhLmpzb24/dD0ke0RhdGUubm93KCl9YCkKICAgICAgICAudGhlbigocmVzcG9uc2UpID0+IHJlc3BvbnNlLm9rICYmIHJlc3BvbnNlLmpzb24oKSkKICAgICAgICAudGhlbigoanNvbikgPT4gewogICAgICAgICAgaWYgKCFqc29uKSB7CiAgICAgICAgICAgIHJldHVybgogICAgICAgICAgfQoKICAgICAgICAgIGRvY3VtZW50LnRpdGxlID0ganNvbi50aXRsZQoKICAgICAgICAgIGpzb24uZGF0YS5mb3JFYWNoKChyZXBvcnRDb25maWcpID0+IHsKICAgICAgICAgICAgY29uc3QgZGl2ID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgnZGl2JykKICAgICAgICAgICAgZGl2LnNldEF0dHJpYnV0ZSgnZGF0YS10ZXN0aWQnLCByZXBvcnRDb25maWcubmFtZSkKCiAgICAgICAgICAgIGNvbnN0IGlkID0gcmVwb3J0Q29uZmlnLm5hbWUucmVwbGFjZUFsbCgnICcsICdfJykKCiAgICAgICAgICAgIGNvbnN0IGN0eCA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoJ2NhbnZhcycpCiAgICAgICAgICAgIGNvbnN0IGgyID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgnaDInKQogICAgICAgICAgICBoMi5pZCA9IGlkCiAgICAgICAgICAgIGgyLmFwcGVuZENoaWxkKGRvY3VtZW50LmNyZWF0ZVRleHROb2RlKHJlcG9ydENvbmZpZy5uYW1lKSkKICAgICAgICAgICAgY29uc3QgbGluayA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoJ2EnKQogICAgICAgICAgICBsaW5rLmhyZWYgPSBgIyR7aWR9YAogICAgICAgICAgICBsaW5rLmFwcGVuZENoaWxkKGRvY3VtZW50LmNyZWF0ZVRleHROb2RlKCcgIycpKQogICAgICAgICAgICBoMi5hcHBlbmRDaGlsZChsaW5rKQogICAgICAgICAgICBkaXYuYXBwZW5kQ2hpbGQoaDIpCiAgICAgICAgICAgIGRpdi5hcHBlbmRDaGlsZChjdHgpCiAgICAgICAgICAgIGNoYXJ0c1Jvb3QuYXBwZW5kKGRpdikKCiAgICAgICAgICAgIGNvbnN0IGRhdGFzZXRzID0gW10KICAgICAgICAgICAgZm9yIChsZXQgaWR4ID0gMDsgaWR4IDwgcmVwb3J0Q29uZmlnLmxpbmVzOyBpZHgrKykgewogICAgICAgICAgICAgIGNvbnN0IGRhdGEgPSBbXQogICAgICAgICAgICAgIGRhdGFzZXRzLnB1c2goewogICAgICAgICAgICAgICAgcmFkaXVzOiAxLAogICAgICAgICAgICAgICAgYm9yZGVyV2lkdGg6IDEsCiAgICAgICAgICAgICAgICBib3JkZXJDb2xvcjogTkFNRURfQ09MT1JTW2lkeF0sCiAgICAgICAgICAgICAgICBsYWJlbDogcmVwb3J0Q29uZmlnLmxhYmVsc1tpZHhdLAogICAgICAgICAgICAgICAgZGF0YSwKICAgICAgICAgICAgICB9KQoKICAgICAgICAgICAgICByZXBvcnRDb25maWcucmVjb3Jkcy5mb3JFYWNoKChyKSA9PiB7CiAgICAgICAgICAgICAgICAvLyByLm1ldGEgLy8gVE9ETyBzaG93IHJ1bklkIGFuZCBzaGEgaW4gdG9vbHRpcAogICAgICAgICAgICAgICAgaWYgKHIuZGF0YVtpZHhdKSB7CiAgICAgICAgICAgICAgICAgIGRhdGEucHVzaChyLmRhdGFbaWR4XSkKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB9KQogICAgICAgICAgICB9CgogICAgICAgICAgICBuZXcgQ2hhcnQoY3R4LCB7CiAgICAgICAgICAgICAgdHlwZTogJ2xpbmUnLAogICAgICAgICAgICAgIGRhdGE6IHsKICAgICAgICAgICAgICAgIGRhdGFzZXRzLAogICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgb3B0aW9uczogewogICAgICAgICAgICAgICAgLy8gVHVybiBvZmYgYW5pbWF0aW9ucyBhbmQgZGF0YSBwYXJzaW5nIGZvciBwZXJmb3JtYW5jZQogICAgICAgICAgICAgICAgYW5pbWF0aW9uOiBmYWxzZSwKICAgICAgICAgICAgICAgIHBhcnNpbmc6IGZhbHNlLAoKICAgICAgICAgICAgICAgIGludGVyYWN0aW9uOiB7CiAgICAgICAgICAgICAgICAgIG1vZGU6ICduZWFyZXN0JywKICAgICAgICAgICAgICAgICAgYXhpczogJ3gnLAogICAgICAgICAgICAgICAgICBpbnRlcnNlY3Q6IGZhbHNlLAogICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgIHBsdWdpbnM6IHsKICAgICAgICAgICAgICAgICAgZGVjaW1hdGlvbjogeyBlbmFibGVkOiB0cnVlLCBhbGdvcml0aG06ICdsdHRiJywgc2FtcGxlczogNjAsIHRocmVzaG9sZDogNjAgfSwKICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICBzY2FsZXM6IHsKICAgICAgICAgICAgICAgICAgeDogewogICAgICAgICAgICAgICAgICAgIHR5cGU6ICd0aW1lJywKICAgICAgICAgICAgICAgICAgICB0aWNrczogewogICAgICAgICAgICAgICAgICAgICAgc291cmNlOiAnYXV0bycsCiAgICAgICAgICAgICAgICAgICAgICAvLyBEaXNhYmxlZCByb3RhdGlvbiBmb3IgcGVyZm9ybWFuY2UKICAgICAgICAgICAgICAgICAgICAgIG1heFJvdGF0aW9uOiAwLAogICAgICAgICAgICAgICAgICAgICAgYXV0b1NraXA6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgfSkKICAgICAgICAgIH0pCiAgICAgICAgfSkKICAgIDwvc2NyaXB0PgogIDwvYm9keT4KPC9odG1sPgo=', 'base64'); +const chartReport = Buffer.from('PCEtLSByZXBvcnQtYWN0aW9uIC0tPgo8IWRvY3R5cGUgaHRtbD4KPGh0bWwgbGFuZz0iZW4iPgogIDxoZWFkPgogICAgPG1ldGEgY2hhcnNldD0iVVRGLTgiIC8+CiAgICA8dGl0bGU+Q2hhcnQ8L3RpdGxlPgogIDwvaGVhZD4KCiAgPGJvZHk+CiAgICA8bWFpbiBpZD0ibWFpbiI+PC9tYWluPgoKICAgIDxzY3JpcHQgc3JjPSJodHRwczovL2Nkbi5qc2RlbGl2ci5uZXQvbnBtL2NoYXJ0LmpzQDQiPjwvc2NyaXB0PgogICAgPHNjcmlwdCBzcmM9Imh0dHBzOi8vY2RuLmpzZGVsaXZyLm5ldC9ucG0vY2hhcnRqcy1hZGFwdGVyLWRhdGUtZm5zQDMiPjwvc2NyaXB0PgoKICAgIDxzY3JpcHQ+CiAgICAgIGNvbnN0IGNoYXJ0c1Jvb3QgPSBkb2N1bWVudC5nZXRFbGVtZW50QnlJZCgnbWFpbicpCgogICAgICBjb25zdCBDSEFSVF9DT0xPUlMgPSB7CiAgICAgICAgcmVkOiAncmdiKDI1NSwgOTksIDEzMiknLAogICAgICAgIG9yYW5nZTogJ3JnYigyNTUsIDE1OSwgNjQpJywKICAgICAgICB5ZWxsb3c6ICdyZ2IoMjU1LCAyMDUsIDg2KScsCiAgICAgICAgZ3JlZW46ICdyZ2IoNzUsIDE5MiwgMTkyKScsCiAgICAgICAgYmx1ZTogJ3JnYig1NCwgMTYyLCAyMzUpJywKICAgICAgICBwdXJwbGU6ICdyZ2IoMTUzLCAxMDIsIDI1NSknLAogICAgICAgIGdyZXk6ICdyZ2IoMjAxLCAyMDMsIDIwNyknLAogICAgICB9CgogICAgICBjb25zdCBOQU1FRF9DT0xPUlMgPSBbCiAgICAgICAgQ0hBUlRfQ09MT1JTLnJlZCwKICAgICAgICBDSEFSVF9DT0xPUlMub3JhbmdlLAogICAgICAgIENIQVJUX0NPTE9SUy55ZWxsb3csCiAgICAgICAgQ0hBUlRfQ09MT1JTLmdyZWVuLAogICAgICAgIENIQVJUX0NPTE9SUy5ibHVlLAogICAgICAgIENIQVJUX0NPTE9SUy5wdXJwbGUsCiAgICAgICAgQ0hBUlRfQ09MT1JTLmdyZXksCiAgICAgIF0KCiAgICAgIGZldGNoKGAuL2RhdGEuanNvbj90PSR7RGF0ZS5ub3coKX1gKQogICAgICAgIC50aGVuKChyZXNwb25zZSkgPT4gcmVzcG9uc2Uub2sgJiYgcmVzcG9uc2UuanNvbigpKQogICAgICAgIC50aGVuKChqc29uKSA9PiB7CiAgICAgICAgICBpZiAoIWpzb24pIHsKICAgICAgICAgICAgcmV0dXJuCiAgICAgICAgICB9CgogICAgICAgICAgZG9jdW1lbnQudGl0bGUgPSBqc29uLnRpdGxlCgogICAgICAgICAganNvbi5kYXRhLmZvckVhY2goKHJlcG9ydENvbmZpZykgPT4gewogICAgICAgICAgICBjb25zdCBkaXYgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCdkaXYnKQogICAgICAgICAgICBkaXYuc2V0QXR0cmlidXRlKCdkYXRhLXRlc3RpZCcsIHJlcG9ydENvbmZpZy5uYW1lKQoKICAgICAgICAgICAgY29uc3QgaWQgPSByZXBvcnRDb25maWcubmFtZS5yZXBsYWNlQWxsKCcgJywgJ18nKQoKICAgICAgICAgICAgY29uc3QgY3R4ID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgnY2FudmFzJykKICAgICAgICAgICAgY29uc3QgaDIgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCdoMicpCiAgICAgICAgICAgIGgyLmlkID0gaWQKICAgICAgICAgICAgaDIuYXBwZW5kQ2hpbGQoZG9jdW1lbnQuY3JlYXRlVGV4dE5vZGUocmVwb3J0Q29uZmlnLm5hbWUpKQogICAgICAgICAgICBjb25zdCBsaW5rID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgnYScpCiAgICAgICAgICAgIGxpbmsuaHJlZiA9IGAjJHtpZH1gCiAgICAgICAgICAgIGxpbmsuYXBwZW5kQ2hpbGQoZG9jdW1lbnQuY3JlYXRlVGV4dE5vZGUoJyAjJykpCiAgICAgICAgICAgIGgyLmFwcGVuZENoaWxkKGxpbmspCiAgICAgICAgICAgIGRpdi5hcHBlbmRDaGlsZChoMikKICAgICAgICAgICAgZGl2LmFwcGVuZENoaWxkKGN0eCkKICAgICAgICAgICAgY2hhcnRzUm9vdC5hcHBlbmQoZGl2KQoKICAgICAgICAgICAgY29uc3QgZGF0YXNldHMgPSBbXQogICAgICAgICAgICBmb3IgKGxldCBpZHggPSAwOyBpZHggPCByZXBvcnRDb25maWcubGluZXM7IGlkeCsrKSB7CiAgICAgICAgICAgICAgY29uc3QgZGF0YSA9IFtdCiAgICAgICAgICAgICAgZGF0YXNldHMucHVzaCh7CiAgICAgICAgICAgICAgICByYWRpdXM6IDEsCiAgICAgICAgICAgICAgICBib3JkZXJXaWR0aDogMSwKICAgICAgICAgICAgICAgIGJvcmRlckNvbG9yOiBOQU1FRF9DT0xPUlNbaWR4XSwKICAgICAgICAgICAgICAgIGxhYmVsOiByZXBvcnRDb25maWcubGFiZWxzW2lkeF0sCiAgICAgICAgICAgICAgICBkYXRhLAogICAgICAgICAgICAgIH0pCgogICAgICAgICAgICAgIHJlcG9ydENvbmZpZy5yZWNvcmRzLmZvckVhY2goKHIpID0+IHsKICAgICAgICAgICAgICAgIC8vIHIubWV0YSAvLyBUT0RPIHNob3cgcnVuSWQgYW5kIHNoYSBpbiB0b29sdGlwCiAgICAgICAgICAgICAgICBpZiAoci5kYXRhW2lkeF0pIHsKICAgICAgICAgICAgICAgICAgZGF0YS5wdXNoKHIuZGF0YVtpZHhdKQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIH0pCiAgICAgICAgICAgIH0KCiAgICAgICAgICAgIG5ldyBDaGFydChjdHgsIHsKICAgICAgICAgICAgICB0eXBlOiAnbGluZScsCiAgICAgICAgICAgICAgZGF0YTogewogICAgICAgICAgICAgICAgZGF0YXNldHMsCiAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICBvcHRpb25zOiB7CiAgICAgICAgICAgICAgICAvLyBUdXJuIG9mZiBhbmltYXRpb25zIGFuZCBkYXRhIHBhcnNpbmcgZm9yIHBlcmZvcm1hbmNlCiAgICAgICAgICAgICAgICBhbmltYXRpb246IGZhbHNlLAogICAgICAgICAgICAgICAgcGFyc2luZzogZmFsc2UsCgogICAgICAgICAgICAgICAgaW50ZXJhY3Rpb246IHsKICAgICAgICAgICAgICAgICAgbW9kZTogJ25lYXJlc3QnLAogICAgICAgICAgICAgICAgICBheGlzOiAneCcsCiAgICAgICAgICAgICAgICAgIGludGVyc2VjdDogZmFsc2UsCiAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgcGx1Z2luczogewogICAgICAgICAgICAgICAgICBkZWNpbWF0aW9uOiB7IGVuYWJsZWQ6IHRydWUsIGFsZ29yaXRobTogJ2x0dGInLCBzYW1wbGVzOiA2MCwgdGhyZXNob2xkOiA2MCB9LAogICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgIHNjYWxlczogewogICAgICAgICAgICAgICAgICB4OiB7CiAgICAgICAgICAgICAgICAgICAgdHlwZTogJ3RpbWUnLAogICAgICAgICAgICAgICAgICAgIHRpY2tzOiB7CiAgICAgICAgICAgICAgICAgICAgICBzb3VyY2U6ICdhdXRvJywKICAgICAgICAgICAgICAgICAgICAgIC8vIERpc2FibGVkIHJvdGF0aW9uIGZvciBwZXJmb3JtYW5jZQogICAgICAgICAgICAgICAgICAgICAgbWF4Um90YXRpb246IDAsCiAgICAgICAgICAgICAgICAgICAgICBhdXRvU2tpcDogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICB9LAogICAgICAgICAgICB9KQogICAgICAgICAgfSkKICAgICAgICB9KQogICAgPC9zY3JpcHQ+CiAgPC9ib2R5Pgo8L2h0bWw+Cg==', 'base64'); ;// CONCATENATED MODULE: ./src/csvReport.ts @@ -39006,6 +39012,34 @@ const shouldWriteRootHtml = async (ghPagesPath) => { }; +/***/ }), + +/***/ 2461: +/***/ ((__unused_webpack_module, __webpack_exports__, __nccwpck_require__) => { + + +// EXPORTS +__nccwpck_require__.d(__webpack_exports__, { + "H": () => (/* binding */ writeLatestReport) +}); + +// EXTERNAL MODULE: external "path" +var external_path_ = __nccwpck_require__(1017); +// EXTERNAL MODULE: external "fs/promises" +var promises_ = __nccwpck_require__(3292); +;// CONCATENATED MODULE: ./src/report_latest.ts +// autogenerated +const latestReport = Buffer.from('PCEtLSByZXBvcnQtYWN0aW9uIC0tPgo8IWRvY3R5cGUgaHRtbD4KPGh0bWwgbGFuZz0iZW4iPgogIDxoZWFkPgogICAgPG1ldGEgY2hhcnNldD0iVVRGLTgiIC8+CiAgICA8dGl0bGU+UmVkaXJlY3QgdG8gbGF0ZXN0PC90aXRsZT4KICA8L2hlYWQ+CgogIDxib2R5PgogICAgPGgxPlJlZGlyZWN0aW5nIHRvIHRoZSBsYXRlc3QgcnVuLi4uPC9oMT4KCiAgICA8c2NyaXB0PgogICAgICBmZXRjaChgLi9kYXRhLmpzb24/dD0ke0RhdGUubm93KCl9YCkKICAgICAgICAudGhlbigocmVzcG9uc2UpID0+IHJlc3BvbnNlLm9rICYmIHJlc3BvbnNlLmpzb24oKSkKICAgICAgICAudGhlbigoanNvbikgPT4gewogICAgICAgICAgaWYgKCFqc29uKSB7CiAgICAgICAgICAgIHJldHVybgogICAgICAgICAgfQoKICAgICAgICAgIGNvbnN0IGVuZGluZyA9IHdpbmRvdy5sb2NhdGlvbi5wYXRobmFtZS5lbmRzV2l0aCgnbGF0ZXN0Lmh0bWwnKQogICAgICAgICAgICA/ICdsYXRlc3QuaHRtbCcKICAgICAgICAgICAgOiB3aW5kb3cubG9jYXRpb24ucGF0aG5hbWUuZW5kc1dpdGgoJ2xhdGVzdCcpCiAgICAgICAgICAgICAgPyAnbGF0ZXN0JwogICAgICAgICAgICAgIDogbnVsbAogICAgICAgICAgaWYgKGVuZGluZykgewogICAgICAgICAgICB3aW5kb3cubG9jYXRpb24ucmVwbGFjZSh3aW5kb3cubG9jYXRpb24ucGF0aG5hbWUucmVwbGFjZShlbmRpbmcsIGAke2pzb24ubGlua3MucG9wKCl9YCkpCiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBjb25zb2xlLmVycm9yKCdzb21ldGhpbmcgd2VudCB3cm9uZycpCiAgICAgICAgICB9CiAgICAgICAgfSkKICAgIDwvc2NyaXB0PgogIDwvYm9keT4KPC9odG1sPgo=', 'base64'); + +;// CONCATENATED MODULE: ./src/writeLatest.ts + + + +const writeLatestReport = async (relPath) => { + await promises_.writeFile(external_path_.join(relPath, 'latest.html'), latestReport); +}; + + /***/ }), /***/ 9491: diff --git a/index.ts b/index.ts index d0d37e4..2c54306 100644 --- a/index.ts +++ b/index.ts @@ -7,6 +7,7 @@ import { isFileExist } from './src/isFileExists.js' import { shouldWriteRootHtml, writeFolderListing } from './src/writeFolderListing.js' import { getBranchName } from './src/helpers.js' import { cleanupOutdatedBranches, cleanupOutdatedReports } from './src/cleanup.js' +import { writeLatestReport } from './src/writeLatest.js' const baseDir = 'report-action' @@ -66,6 +67,7 @@ try { if (!['html', 'csv'].includes(reportType)) { throw new Error('Unsupported report type: ' + reportType) } + const isHtmlReport = reportType === 'html' // action await io.mkdirP(reportBaseDir) @@ -79,7 +81,7 @@ try { } // process report - if (reportType === 'html') { + if (isHtmlReport) { await io.cp(sourceReportDir, reportDir, { recursive: true }) } else if (reportType === 'csv') { await csvReport(sourceReportDir, reportBaseDir, reportId, { @@ -97,10 +99,13 @@ try { if (listDirsBranch) { await writeFolderListing(ghPagesPath, path.join(baseDir, branchName)) await writeFolderListing(ghPagesPath, path.join(baseDir, branchName)) - if (reportType === 'html') { + if (isHtmlReport) { await writeFolderListing(ghPagesPath, path.join(baseDir, branchName, reportId)) } } + if (isHtmlReport) { + await writeLatestReport(reportBaseDir) + } // outputs core.setOutput('report_url', reportUrl) diff --git a/package-lock.json b/package-lock.json index 2300984..30a0535 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "html-trend-report-action", - "version": "1.1.2", + "version": "1.2.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "html-trend-report-action", - "version": "1.1.2", + "version": "1.2.0", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index e2e5107..765f487 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "html-trend-report-action", - "version": "1.1.2", + "version": "1.2.0", "description": "Publish html trend reports per branch", "main": "index.js", "type": "module", diff --git a/prebuild.js b/prebuild.js index e3d0eb0..24d89cf 100644 --- a/prebuild.js +++ b/prebuild.js @@ -3,6 +3,7 @@ import fs from 'fs/promises' const tasks = [ { report: 'reports/chart/index.html', src: 'src/report_chart.ts', name: 'chartReport' }, { report: 'reports/html/index.html', src: 'src/report_listing.ts', name: 'listingReport' }, + { report: 'reports/html/latest.html', src: 'src/report_latest.ts', name: 'latestReport' }, ] const buildString = (name, report) => [ diff --git a/reports/chart/index.html b/reports/chart/index.html index 39cd32e..3760119 100644 --- a/reports/chart/index.html +++ b/reports/chart/index.html @@ -9,10 +9,8 @@
- - - - + + + +