Skip to content

Commit

Permalink
Set default report path (#174)
Browse files Browse the repository at this point in the history
* fix: fix report path (#172)

* fix: set default report path

* fix: report file path
  • Loading branch information
bokuweb authored Nov 10, 2024
1 parent 558be10 commit 4dbc350
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ The custom report page link.
- Type: String
- Default: N/A

Path of the generated report html file. This file can be deployed in other Actions steps, but is not included in the artifact. If omitted, no html report is generated.
Path of the generated report html file. This file can be deployed in other Actions steps, but is not included in the artifact. If omitted, treated as `./report.html`.

#### `artifact-name` (Optional)

Expand Down
19 changes: 10 additions & 9 deletions src/config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as core from '@actions/core';
import { statSync } from 'fs';
import { ARTIFACT_NAME } from './constants';
import { dirname } from 'path';
import { join } from 'path';

export interface Config {
imageDirectoryPath: string;
Expand Down Expand Up @@ -88,13 +88,6 @@ const validateReportFilePath = (path: string | undefined) => {
if (path === undefined || path === '') {
return;
}
try {
const s = statSync(dirname(path));
if (s.isDirectory()) return;
else throw null;
} catch (_) {
throw new Error(`'report-file-path' is not in a valid directory. Please specify path to report file.`);
}
};

function validateCommentReportFormat(format: string): asserts format is 'raw' | 'summarized' {
Expand Down Expand Up @@ -126,7 +119,15 @@ export const getConfig = (): Config => {
const branch = core.getInput('branch') || 'reg_actions';
const customReportPage = core.getInput('custom-report-page') || null;
validateCustomReportPage(customReportPage);
const reportFilePath = core.getInput('report-file-path');
let reportFilePath = core.getInput('report-file-path');
if (!reportFilePath) {
reportFilePath = './report.html';
}
try {
if (statSync(reportFilePath).isDirectory()) {
reportFilePath = join(reportFilePath, './report.html');
}
} catch {}
validateReportFilePath(reportFilePath);
const commentReportFormat = core.getInput('comment-report-format') || 'raw';
validateCommentReportFormat(commentReportFormat);
Expand Down

0 comments on commit 4dbc350

Please sign in to comment.