Skip to content

Commit

Permalink
Merge pull request #12 from actions/main
Browse files Browse the repository at this point in the history
feat(statistics): display some stats in the logs (actions#337)
  • Loading branch information
C0ZEN authored Mar 1, 2021
2 parents 915ed27 + 419a53b commit 4b097b3
Show file tree
Hide file tree
Showing 17 changed files with 1,019 additions and 677 deletions.
116 changes: 63 additions & 53 deletions README.md

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions __tests__/any-of-labels.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Issue} from '../src/classes/issue';
import {IssuesProcessor} from '../src/classes/issues-processor';
import {IIssuesProcessorOptions} from '../src/interfaces/issues-processor-options';
import {IssuesProcessorMock} from './classes/issues-processor-mock';
import {DefaultProcessorOptions} from './constants/default-processor-options';
import {generateIssue} from './functions/generate-issue';

Expand Down Expand Up @@ -95,8 +95,8 @@ class IssuesProcessorBuilder {
return this;
}

build(): IssuesProcessor {
return new IssuesProcessor(
build(): IssuesProcessorMock {
return new IssuesProcessorMock(
this._options,
async () => 'abot',
async p => (p === 1 ? this._issues : []),
Expand Down
6 changes: 3 additions & 3 deletions __tests__/assignees.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Issue} from '../src/classes/issue';
import {IssuesProcessor} from '../src/classes/issues-processor';
import {IIssuesProcessorOptions} from '../src/interfaces/issues-processor-options';
import {IssuesProcessorMock} from './classes/issues-processor-mock';
import {DefaultProcessorOptions} from './constants/default-processor-options';
import {generateIssue} from './functions/generate-issue';

Expand All @@ -21,7 +21,7 @@ interface ITestData {
describe('assignees options', (): void => {
let opts: IIssuesProcessorOptions;
let testIssueList: Issue[];
let processor: IssuesProcessor;
let processor: IssuesProcessorMock;

const setTestIssueList = (
isPullRequest: boolean,
Expand All @@ -46,7 +46,7 @@ describe('assignees options', (): void => {
};

const setProcessor = () => {
processor = new IssuesProcessor(
processor = new IssuesProcessorMock(
opts,
async () => 'abot',
async p => (p === 1 ? testIssueList : []),
Expand Down
38 changes: 38 additions & 0 deletions __tests__/classes/issues-processor-mock.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import {Issue} from '../../src/classes/issue';
import {IssuesProcessor} from '../../src/classes/issues-processor';
import {IComment} from '../../src/interfaces/comment';
import {IIssuesProcessorOptions} from '../../src/interfaces/issues-processor-options';

export class IssuesProcessorMock extends IssuesProcessor {
constructor(
options: IIssuesProcessorOptions,
getActor?: () => Promise<string>,
getIssues?: (page: number) => Promise<Issue[]>,
listIssueComments?: (
issueNumber: number,
sinceDate: string
) => Promise<IComment[]>,
getLabelCreationDate?: (
issue: Issue,
label: string
) => Promise<string | undefined>
) {
super(options);

if (getActor) {
this.getActor = getActor;
}

if (getIssues) {
this.getIssues = getIssues;
}

if (listIssueComments) {
this.listIssueComments = listIssueComments;
}

if (getLabelCreationDate) {
this.getLabelCreationDate = getLabelCreationDate;
}
}
}
3 changes: 2 additions & 1 deletion __tests__/constants/default-processor-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,6 @@ export const DefaultProcessorOptions: IIssuesProcessorOptions = Object.freeze({
exemptPrAssignees: '',
exemptAllAssignees: false,
exemptAllIssueAssignees: undefined,
exemptAllPrAssignees: undefined
exemptAllPrAssignees: undefined,
enableStatistics: false
});
Loading

0 comments on commit 4b097b3

Please sign in to comment.