Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add link to the latest report #13

Merged
merged 2 commits into from
Feb 8, 2024
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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ Docker version of the action: [allure-report-with-history-per-branch](https://gi

See examples:

- [Allure History List](https://mgrybyk.github.io/allure-report-branch-js-action/allure-js-action/main/self-test/)
- [Allure Report](https://mgrybyk.github.io/allure-report-branch-js-action/allure-js-action/main/self-test/7729626691_1706720670013/)
- [Browse different branches](https://mgrybyk.github.io/allure-report-branch-js-action/allure-js-action/)
- [Allure History List](https://mgrybyk.github.io/allure-report-branch-js-action/allure-action/main/self-test/)
- [Allure Report](https://mgrybyk.github.io/allure-report-branch-js-action/allure-action/main/self-test/latest.html)
- [Browse different branches](https://mgrybyk.github.io/allure-report-branch-js-action/allure-action/)
- [Pull Request Comment Example](https://github.com/mgrybyk/allure-report-branch-js-action/pull/3)

*Compatible with [HTML Trend Report Action](https://github.com/marketplace/actions/publish-report-per-branch).*
Expand Down
35 changes: 33 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36846,9 +36846,11 @@ __nccwpck_require__.a(module, async (__webpack_handle_async_dependencies__, __we
/* harmony import */ var _actions_io__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__nccwpck_require__.n(_actions_io__WEBPACK_IMPORTED_MODULE_3__);
/* harmony import */ var _src_writeFolderListing_js__WEBPACK_IMPORTED_MODULE_4__ = __nccwpck_require__(4362);
/* harmony import */ var _src_allure_js__WEBPACK_IMPORTED_MODULE_5__ = __nccwpck_require__(7405);
/* 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_isFileExists_js__WEBPACK_IMPORTED_MODULE_6__ = __nccwpck_require__(2139);
/* harmony import */ var _src_cleanup_js__WEBPACK_IMPORTED_MODULE_7__ = __nccwpck_require__(2193);
/* harmony import */ var _src_writeLatest_js__WEBPACK_IMPORTED_MODULE_8__ = __nccwpck_require__(2461);




Expand All @@ -36872,7 +36874,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);
/**
Expand Down Expand Up @@ -36947,6 +36949,7 @@ try {
const results = await (0,_src_allure_js__WEBPACK_IMPORTED_MODULE_5__/* .updateDataJson */ .V0)(reportBaseDir, reportDir, _actions_github__WEBPACK_IMPORTED_MODULE_2__.context.runId, runUniqueId);
await (0,_src_allure_js__WEBPACK_IMPORTED_MODULE_5__/* .writeAllureListing */ .rF)(reportBaseDir);
await (0,_src_allure_js__WEBPACK_IMPORTED_MODULE_5__/* .writeLastRunId */ .j9)(reportBaseDir, _actions_github__WEBPACK_IMPORTED_MODULE_2__.context.runId, runTimestamp);
await (0,_src_writeLatest_js__WEBPACK_IMPORTED_MODULE_8__/* .writeLatestReport */ .H)(reportBaseDir);
// outputs
_actions_core__WEBPACK_IMPORTED_MODULE_1__.setOutput('report_url', ghPagesReportUrl);
_actions_core__WEBPACK_IMPORTED_MODULE_1__.setOutput('report_history_url', ghPagesBaseUrl);
Expand Down Expand Up @@ -40710,6 +40713,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+CgogIDxib2R5PgogICAgPGgxPlJlZGlyZWN0aW5nIHRvIHRoZSBsYXRlc3QgcnVuLi4uPC9oMT4KCiAgICA8c2NyaXB0PgogICAgICBmZXRjaChgLi9sYXN0UnVuLmpzb24/dD0ke0RhdGUubm93KCl9YCkKICAgICAgICAudGhlbigocmVzcG9uc2UpID0+IHJlc3BvbnNlLm9rICYmIHJlc3BvbnNlLmpzb24oKSkKICAgICAgICAudGhlbigoanNvbikgPT4gewogICAgICAgICAgaWYgKCFqc29uKSB7CiAgICAgICAgICAgIHJldHVybgogICAgICAgICAgfQoKICAgICAgICAgIHdpbmRvdy5sb2NhdGlvbi5yZXBsYWNlKHdpbmRvdy5sb2NhdGlvbi5wYXRobmFtZS5yZXBsYWNlKCdsYXRlc3QuaHRtbCcsIGAke2pzb24ucnVuSWR9XyR7anNvbi5ydW5UaW1lc3RhbXB9YCkpCiAgICAgICAgfSkKICAgIDwvc2NyaXB0PgogIDwvYm9keT4KPC9odG1sPgo=', 'base64');

;// CONCATENATED MODULE: ./src/writeLatest.ts



const writeLatestReport = async (relPath) => {
await promises_.writeFile(external_path_.join(relPath, 'latest.html'), latestReport);
};


/***/ }),

/***/ 9491:
Expand Down
2 changes: 2 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
import { getBranchName } from './src/helpers.js'
import { isFileExist } from './src/isFileExists.js'
import { cleanupOutdatedBranches, cleanupOutdatedReports } from './src/cleanup.js'
import { writeLatestReport } from './src/writeLatest.js'

const baseDir = 'allure-action'
const allureRelease = '2.27.0'
Expand Down Expand Up @@ -121,6 +122,7 @@ try {
const results = await updateDataJson(reportBaseDir, reportDir, github.context.runId, runUniqueId)
await writeAllureListing(reportBaseDir)
await writeLastRunId(reportBaseDir, github.context.runId, runTimestamp)
await writeLatestReport(reportBaseDir)

// outputs
core.setOutput('report_url', ghPagesReportUrl)
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "allure-report-branch-js-action",
"version": "1.3.1",
"version": "1.4.0",
"description": "Allure Report with history per branch",
"main": "index.js",
"type": "module",
Expand Down
1 change: 1 addition & 0 deletions prebuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import fs from 'fs/promises'
const tasks = [
{ report: 'reports/allure/index.html', src: 'src/report_allure.ts', name: 'allureReport' },
{ 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) => [
Expand Down
24 changes: 24 additions & 0 deletions reports/html/latest.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!-- report-action -->
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Redirect to latest</title>
</head>

<body>
<h1>Redirecting to the latest run...</h1>

<script>
fetch(`./lastRun.json?t=${Date.now()}`)
.then((response) => response.ok && response.json())
.then((json) => {
if (!json) {
return
}

window.location.replace(window.location.pathname.replace('latest.html', `${json.runId}_${json.runTimestamp}`))
})
</script>
</body>
</html>
7 changes: 7 additions & 0 deletions src/writeLatest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import * as path from 'path'
import * as fs from 'fs/promises'
import { latestReport } from './report_latest.js'

export const writeLatestReport = async (relPath: string) => {
await fs.writeFile(path.join(relPath, 'latest.html'), latestReport)
}
Loading