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

cleanup strategy #10

Merged
merged 3 commits into from
Feb 5, 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: 4 additions & 2 deletions .github/workflows/report_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ jobs:
gh_pages: 'gh-pages-dir'
report_dir: 'allure-results'
list_dirs: ${{ github.ref == 'refs/heads/main' }}
cleanup_enabled: true
max_reports: 5
branch_cleanup_enabled: ${{ github.ref == 'refs/heads/main' }}
max_reports: 9

- name: Git Commit and Push Action
uses: mgrybyk/git-commit-pull-push-action@v1
Expand Down Expand Up @@ -126,6 +126,7 @@ jobs:
gh_pages: 'gh-pages-dir'
report_dir: 'allure-results'
list_dirs: ${{ github.ref == 'refs/heads/main' }}
max_reports: 0

- name: Git Commit and Push Action
uses: mgrybyk/git-commit-pull-push-action@v1
Expand Down Expand Up @@ -182,6 +183,7 @@ jobs:
gh_pages: 'gh-pages-dir'
report_dir: 'allure-results'
list_dirs: ${{ github.ref == 'refs/heads/main' }}
max_reports: 0

- name: Git Commit and Push Action
uses: mgrybyk/git-commit-pull-push-action@v1
Expand Down
10 changes: 7 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,16 @@ inputs:
description: 'Write index.html to the Github Action folders. Might cause concurrency issues!'
required: false
default: false
cleanup_enabled:
description: 'Cleanup reports from deleted branches or if reports numbers is too big'
list_dirs_branch:
description: 'Write index.html to the report branch folder. Might cause concurrency issues!'
required: false
default: true
branch_cleanup_enabled:
description: 'Cleanup reports from deleted branches. Might cause concurrency issues!'
required: false
default: false
max_reports:
description: 'Max reports to keep per branch/report. Make sure to enable cleanup_enabled'
description: 'Max reports to keep per branch/report. Set to 0 to disable cleanup.'
required: false
default: 100
outputs:
Expand Down
12 changes: 9 additions & 3 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36861,7 +36861,8 @@ try {
const ghPagesPath = _actions_core__WEBPACK_IMPORTED_MODULE_1__.getInput('gh_pages');
const reportId = _actions_core__WEBPACK_IMPORTED_MODULE_1__.getInput('report_id');
const listDirs = _actions_core__WEBPACK_IMPORTED_MODULE_1__.getInput('list_dirs') == 'true';
const cleanupEnabled = _actions_core__WEBPACK_IMPORTED_MODULE_1__.getInput('cleanup_enabled') == 'true';
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 ghPagesBaseDir = path__WEBPACK_IMPORTED_MODULE_0__.join(ghPagesPath, baseDir);
Expand Down Expand Up @@ -36891,7 +36892,8 @@ try {
reportDir,
report_url: ghPagesReportUrl,
listDirs,
cleanupEnabled,
listDirsBranch,
branchCleanupEnabled,
maxReports,
});
if (!(await (0,_src_isFileExists_js__WEBPACK_IMPORTED_MODULE_6__/* .isFileExist */ .e)(ghPagesPath))) {
Expand All @@ -36911,6 +36913,8 @@ try {
await (0,_src_writeFolderListing_js__WEBPACK_IMPORTED_MODULE_4__/* .writeFolderListing */ .l)(ghPagesPath, '.');
}
await (0,_src_writeFolderListing_js__WEBPACK_IMPORTED_MODULE_4__/* .writeFolderListing */ .l)(ghPagesPath, baseDir);
}
if (listDirsBranch) {
await (0,_src_writeFolderListing_js__WEBPACK_IMPORTED_MODULE_4__/* .writeFolderListing */ .l)(ghPagesPath, path__WEBPACK_IMPORTED_MODULE_0__.join(baseDir, branchName));
}
// process allure report
Expand Down Expand Up @@ -36938,8 +36942,10 @@ try {
_actions_core__WEBPACK_IMPORTED_MODULE_1__.setOutput('test_result_total', results.total);
_actions_core__WEBPACK_IMPORTED_MODULE_1__.setOutput('run_unique_id', runUniqueId);
_actions_core__WEBPACK_IMPORTED_MODULE_1__.setOutput('report_path', reportDir);
if (cleanupEnabled) {
if (branchCleanupEnabled) {
await (0,_src_cleanup_js__WEBPACK_IMPORTED_MODULE_7__/* .cleanupOutdatedBranches */ .B)(ghPagesBaseDir);
}
if (maxReports > 0) {
await (0,_src_cleanup_js__WEBPACK_IMPORTED_MODULE_7__/* .cleanupOutdatedReports */ .g)(ghPagesBaseDir, maxReports);
}
}
Expand Down
12 changes: 9 additions & 3 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ try {
const ghPagesPath = core.getInput('gh_pages')
const reportId = core.getInput('report_id')
const listDirs = core.getInput('list_dirs') == 'true'
const cleanupEnabled = core.getInput('cleanup_enabled') == 'true'
const listDirsBranch = core.getInput('list_dirs_branch') == 'true'
const branchCleanupEnabled = core.getInput('branch_cleanup_enabled') == 'true'
const maxReports = parseInt(core.getInput('max_reports'), 10)
const branchName = getBranchName(github.context.ref, github.context.payload.pull_request)
const ghPagesBaseDir = path.join(ghPagesPath, baseDir)
Expand Down Expand Up @@ -66,7 +67,8 @@ try {
reportDir,
report_url: ghPagesReportUrl,
listDirs,
cleanupEnabled,
listDirsBranch,
branchCleanupEnabled,
maxReports,
})

Expand All @@ -91,6 +93,8 @@ try {
await writeFolderListing(ghPagesPath, '.')
}
await writeFolderListing(ghPagesPath, baseDir)
}
if (listDirsBranch) {
await writeFolderListing(ghPagesPath, path.join(baseDir, branchName))
}

Expand Down Expand Up @@ -121,8 +125,10 @@ try {
core.setOutput('run_unique_id', runUniqueId)
core.setOutput('report_path', reportDir)

if (cleanupEnabled) {
if (branchCleanupEnabled) {
await cleanupOutdatedBranches(ghPagesBaseDir)
}
if (maxReports > 0) {
await cleanupOutdatedReports(ghPagesBaseDir, maxReports)
}
} catch (error) {
Expand Down
81 changes: 50 additions & 31 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "allure-report-branch-js-action",
"version": "1.1.2",
"version": "1.2.0",
"description": "Allure Report with history per branch",
"main": "index.js",
"type": "module",
Expand Down Expand Up @@ -45,7 +45,7 @@
"http-server": "^14.1.1",
"husky": "^9.0.10",
"npm-run-all": "^4.1.5",
"prettier": "^3.2.4",
"prettier": "^3.2.5",
"typescript": "^5.3.3"
}
}
Loading