Skip to content

Commit

Permalink
SCP-52 Adds reports table
Browse files Browse the repository at this point in the history
  • Loading branch information
francostramana committed Jan 23, 2024
1 parent dec3f4a commit c18f9ea
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 14 deletions.
3 changes: 2 additions & 1 deletion .github/linters/.eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,6 @@ rules:
'@typescript-eslint/semi': ['error', 'always'],
'@typescript-eslint/space-before-function-paren': 'off',
'@typescript-eslint/type-annotation-spacing': 'error',
'@typescript-eslint/unbound-method': 'error'
'@typescript-eslint/unbound-method': 'error',
'github/array-foreach' : 'off'
}
11 changes: 6 additions & 5 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as exec from '@actions/exec';
import { getLicenses, readResult } from './services/result.service';
import { createCommentOnPR, isPullRequest } from './utils/github.utils';
import { LicensePolicyCheck } from './policies/license-policy-check';
import { getLicensesReport } from './services/report.service';

/**
* The main function for the action.
Expand All @@ -15,7 +16,7 @@ export async function run(): Promise<void> {

// create policies
const policies = [new LicensePolicyCheck()];
policies.forEach(policy => policy.start());
policies.forEach(async policy => policy.start());

// options to get standar output
const options: exec.ExecOptions = {};
Expand All @@ -40,14 +41,14 @@ export async function run(): Promise<void> {
const scannerResults = await readResult(outputPath);
const licenses = getLicenses(scannerResults);

// get reports
const licenseReport = 'Here are the licenses found:';
// create reports
const licensesReport = getLicensesReport(licenses);

// run policies // TODO: define run action for each policy
policies.forEach(async (policy) => await policy.run(licenseReport));
policies.forEach(async policy => await policy.run(licensesReport));

if (isPullRequest()) {
createCommentOnPR(licenseReport);
createCommentOnPR(licensesReport);
}

// set outputs for other workflow steps to use
Expand Down
14 changes: 6 additions & 8 deletions src/policies/license-policy-check.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { CHECK_NAME } from "src/app.config";
import { PolicyCheck } from "./policy-check";
import { CHECK_NAME } from '../app.config';
import { PolicyCheck } from './policy-check';

export class LicensePolicyCheck extends PolicyCheck {

constructor() {
super(`${CHECK_NAME}: Licenses Policy`);
}

}
constructor() {
super(`${CHECK_NAME}: Licenses Policy`);
}
}
4 changes: 4 additions & 0 deletions src/services/report.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

Check failure on line 1 in src/services/report.service.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Delete `⏎`

Check failure on line 1 in src/services/report.service.ts

View workflow job for this annotation

GitHub Actions / TypeScript Tests

Delete `⏎`
export function getLicensesReport(licenses: any): string {

Check failure on line 2 in src/services/report.service.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

'licenses' is defined but never used

Check warning on line 2 in src/services/report.service.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Unexpected any. Specify a different type

Check failure on line 2 in src/services/report.service.ts

View workflow job for this annotation

GitHub Actions / TypeScript Tests

'licenses' is defined but never used

Check warning on line 2 in src/services/report.service.ts

View workflow job for this annotation

GitHub Actions / TypeScript Tests

Unexpected any. Specify a different type
return 'test';

Check failure on line 3 in src/services/report.service.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Delete `··`

Check failure on line 3 in src/services/report.service.ts

View workflow job for this annotation

GitHub Actions / TypeScript Tests

Delete `··`
}

Check failure on line 4 in src/services/report.service.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Insert `⏎`

Check failure on line 4 in src/services/report.service.ts

View workflow job for this annotation

GitHub Actions / TypeScript Tests

Insert `⏎`

0 comments on commit c18f9ea

Please sign in to comment.