Skip to content

Commit

Permalink
SCP-75 Adds summary on PR
Browse files Browse the repository at this point in the history
  • Loading branch information
francostramana committed Jan 25, 2024
1 parent 9842d94 commit f5646c1
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 13 deletions.
26 changes: 19 additions & 7 deletions dist/index.js

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

7 changes: 3 additions & 4 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { getLicenses, readResult } from './services/result.service';

Check warning on line 1 in src/main.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

'getLicenses' is defined but never used

Check warning on line 1 in src/main.ts

View workflow job for this annotation

GitHub Actions / TypeScript Tests

'getLicenses' is defined but never used
import { createCommentOnPR, isPullRequest } from './utils/github.utils';
import { CopyleftPolicyCheck } from './policies/copyleft-policy-check';
import { getLicensesReport } from './services/report.service';
import { generateSummary, getLicensesTable } from './services/report.service';

Check warning on line 4 in src/main.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

'getLicensesTable' is defined but never used

Check warning on line 4 in src/main.ts

View workflow job for this annotation

GitHub Actions / TypeScript Tests

'getLicensesTable' is defined but never used
import * as core from '@actions/core';
import * as exec from '@actions/exec';
import * as inputs from './app.input';
Expand Down Expand Up @@ -30,9 +30,8 @@ export async function run(): Promise<void> {

if (isPullRequest()) {
// create reports
const licenses = getLicenses(scannerResults);
const licensesReport = getLicensesReport(licenses);
createCommentOnPR(licensesReport);
const report = generateSummary(scannerResults);
createCommentOnPR(report);
}

// set outputs for other workflow steps to use
Expand Down
19 changes: 17 additions & 2 deletions src/services/report.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Licenses } from './result.service';
import { ScannerResults } from './result.interfaces';
import { Licenses, getLicenses } from './result.service';

export function getLicensesReport(licenses: Licenses[]): string {
export function getLicensesTable(licenses: Licenses[]): string {
let markdownTable = '| License | Copyleft | URL |\n';
markdownTable += '| ------- | -------- | --- |\n';

Expand All @@ -11,3 +12,17 @@ export function getLicensesReport(licenses: Licenses[]): string {

return markdownTable;
}

export function generateSummary(scannerResults: ScannerResults): string {
const licenses = getLicenses(scannerResults);
const licensesReport = getLicensesTable(licenses);

const content = `
## SCANOSS Summary :rocket:
### Licenses detected: ${licenses.length}
${licensesReport}
`;

return content;
}

0 comments on commit f5646c1

Please sign in to comment.