Skip to content
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
202 changes: 162 additions & 40 deletions dist/index.js

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions src/data/manager/description/base/content_interface.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as core from "@actions/core";
import { logError } from "../../../utils/logger";

export abstract class ContentInterface {
abstract get id(): string
Expand Down Expand Up @@ -34,7 +35,7 @@ export abstract class ContentInterface {

return description.split(this.startPattern)[1].split(this.endPattern)[0]
} catch (error) {
core.error(`Error reading issue configuration: ${error}`);
logError(`Error reading issue configuration: ${error}`);
throw error;
}
}
Expand Down Expand Up @@ -75,7 +76,7 @@ export abstract class ContentInterface {

return this._updateContent(description, content);
} catch (error) {
console.error(`Error updating issue description: ${error}`);
logError(`Error updating issue description: ${error}`);
return undefined;
}
}
Expand Down
11 changes: 9 additions & 2 deletions src/data/model/execution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@ import {incrementVersion} from "../utils/version_utils";
import {SingleAction} from "./single_action";
import {Ai} from "./ai";
import { SizeThresholds } from "./size_thresholds";
import { logDebugInfo, setGlobalLoggerDebug } from "../utils/logger";

export class Execution {
debug: boolean = false;

/**
* Every usage of this field should be checked.
* PRs with no issue ID in the head branch won't have it.
Expand Down Expand Up @@ -151,6 +154,7 @@ export class Execution {
}

constructor(
debug: boolean,
singleAction: SingleAction,
commitPrefixBuilder: string,
issue: Issue,
Expand All @@ -167,6 +171,7 @@ export class Execution {
workflows: Workflows,
projects: ProjectDetail[],
) {
this.debug = debug;
this.singleAction = singleAction;
this.commitPrefixBuilder = commitPrefixBuilder;
this.issue = issue;
Expand All @@ -186,6 +191,8 @@ export class Execution {
}

setup = async () => {
setGlobalLoggerDebug(this.debug);

const issueRepository = new IssueRepository();

/**
Expand Down Expand Up @@ -228,7 +235,7 @@ export class Execution {
}

this.previousConfiguration = await new ConfigurationHandler().get(this)
console.log(`Previous configuration: ${JSON.stringify(this.previousConfiguration, null, 2)}`);
logDebugInfo(`Previous configuration: ${JSON.stringify(this.previousConfiguration, null, 2)}`);

/**
* Get labels of issue
Expand Down Expand Up @@ -339,6 +346,6 @@ export class Execution {

this.currentConfiguration.branchType = this.issueType

console.log(`Current configuration: ${JSON.stringify(this.currentConfiguration, null, 2)}`);
logDebugInfo(`Current configuration: ${JSON.stringify(this.currentConfiguration, null, 2)}`);
}
}
6 changes: 4 additions & 2 deletions src/data/model/single_action.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { logError } from "../utils/logger";

const deployedAction = 'deployed_action'

export class SingleAction {
Expand All @@ -22,8 +24,8 @@ export class SingleAction {
this.currentSingleActionIssue = parseInt(currentSingleActionIssue)
validIssueNumber = true;
} catch (error) {
console.error(error)
console.error(`Issue ${currentSingleActionIssue} is not a number.`)
logError(`Issue ${currentSingleActionIssue} is not a number.`)
logError(error)
}
this.currentSingleAction = currentSingleAction;
this.enabledSingleAction = this.currentSingleAction.length > 0;
Expand Down
5 changes: 3 additions & 2 deletions src/data/repository/branch_repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {Execution} from "../model/execution";
import {getLatestVersion} from "../utils/version_utils";
import { Labels } from '../model/labels';
import { SizeThresholds } from '../model/size_thresholds';
import { logDebugInfo, logError } from '../utils/logger';

export class BranchRepository {

Expand Down Expand Up @@ -122,7 +123,7 @@ export class BranchRepository {
core.info(`Managing branches`);

const branches = await this.getListOfBranches(owner, repository, token)
console.log(JSON.stringify(branches, null, 2));
logDebugInfo(JSON.stringify(branches, null, 2));

if (hotfixBranch === undefined && isHotfix) {
result.push(
Expand Down Expand Up @@ -226,7 +227,7 @@ export class BranchRepository {
)
)
} catch (error) {
console.error(error);
logError(error);
result.push(
new Result({
id: 'branch_repository',
Expand Down
5 changes: 3 additions & 2 deletions src/data/repository/issue_repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as github from "@actions/github";
import * as core from "@actions/core";
import {Milestone} from "../model/milestone";
import {Labels} from "../model/labels";
import { logError } from "../utils/logger";

export class IssueRepository {

Expand Down Expand Up @@ -224,7 +225,7 @@ export class IssueRepository {
body: description,
});
} catch (error) {
console.error(`Error updating issue description: ${error}`);
logError(`Error updating issue description: ${error}`);
throw error;
}
}
Expand Down Expand Up @@ -371,7 +372,7 @@ export class IssueRepository {

return issue.title;
} catch (error) {
console.error(`Failed to fetch the issue title: ${error}`);
logError(`Failed to fetch the issue title: ${error}`);
return undefined;
}
};
Expand Down
3 changes: 2 additions & 1 deletion src/data/usecase/actions/deployed_action_use_case.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {IssueRepository} from "../../repository/issue_repository";
import * as core from "@actions/core";
import {Result} from "../../model/result";
import {BranchRepository} from "../../repository/branch_repository";
import { logError } from "../../utils/logger";

export class DeployedActionUseCase implements ParamUseCase<Execution, Result[]> {
taskId: string = 'DeployedActionUseCase';
Expand Down Expand Up @@ -116,7 +117,7 @@ export class DeployedActionUseCase implements ParamUseCase<Execution, Result[]>

return result;
} catch (error) {
console.error(error);
logError(error);
result.push(
new Result({
id: this.taskId,
Expand Down
3 changes: 2 additions & 1 deletion src/data/usecase/commit_check_use_case.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {Result} from "../model/result";
import * as core from '@actions/core';
import { CheckChangesIssueSizeUseCase } from "./steps/check_changes_issue_size_use_case";
import { NotifyNewCommitOnIssueUseCase } from "./steps/notify_new_commit_on_issue_use_case";
import { logError } from "../utils/logger";

export class CommitCheckUseCase implements ParamUseCase<Execution, Result[]> {
taskId: string = 'CommitCheckUseCase';
Expand All @@ -25,7 +26,7 @@ export class CommitCheckUseCase implements ParamUseCase<Execution, Result[]> {
results.push(...(await new NotifyNewCommitOnIssueUseCase().invoke(param)));
results.push(...(await new CheckChangesIssueSizeUseCase().invoke(param)));
} catch (error) {
console.error(error);
logError(error);
results.push(
new Result({
id: this.taskId,
Expand Down
3 changes: 2 additions & 1 deletion src/data/usecase/publish_resume_use_case.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {Execution} from "../model/execution";
import {Result} from "../model/result";
import {getRandomElement} from "../utils/list_utils";
import * as core from '@actions/core';
import { logError } from "../utils/logger";

/**
* Publish the resume of actions
Expand Down Expand Up @@ -168,7 +169,7 @@ ${footer}
)
}
} catch (error) {
console.error(error);
logError(error);
param.currentConfiguration.results.push(
new Result({
id: this.taskId,
Expand Down
3 changes: 2 additions & 1 deletion src/data/usecase/pull_request_link_use_case.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {AssignReviewersToIssueUseCase} from "./steps/assign_reviewers_to_issue_u
import {UpdateTitleUseCase} from "./steps/update_title_use_case";
import { UpdatePullRequestDescriptionUseCase } from "./steps/update_pull_request_description_use_case";
import { CheckChangesPullRequestSizeUseCase } from "./steps/check_changes_pull_request_size_use_case";
import { logError } from "../utils/logger";

export class PullRequestLinkUseCase implements ParamUseCase<Execution, Result[]> {
taskId: string = 'PullRequestLinkUseCase';
Expand Down Expand Up @@ -82,7 +83,7 @@ export class PullRequestLinkUseCase implements ParamUseCase<Execution, Result[]>
results.push(...await new CloseIssueAfterMergingUseCase().invoke(param));
}
} catch (error) {
console.error(error);
logError(error);
results.push(
new Result({
id: this.taskId,
Expand Down
3 changes: 2 additions & 1 deletion src/data/usecase/remove_issue_branches_use_case.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {ParamUseCase} from "./base/param_usecase";
import {Execution} from "../model/execution";
import {Result} from "../model/result";
import * as core from '@actions/core';
import { logError } from "../utils/logger";

/**
* Remove any branch created for this issue
Expand Down Expand Up @@ -66,7 +67,7 @@ export class RemoveIssueBranchesUseCase implements ParamUseCase<Execution, Resul
}
}
} catch (error) {
console.error(error);
logError(error);
results.push(
new Result({
id: this.taskId,
Expand Down
3 changes: 2 additions & 1 deletion src/data/usecase/single_action_use_case.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {Execution} from "../model/execution";
import {Result} from "../model/result";
import * as core from '@actions/core';
import {DeployedActionUseCase} from "./actions/deployed_action_use_case";
import { logError } from "../utils/logger";

export class SingleActionUseCase implements ParamUseCase<Execution, Result[]> {
taskId: string = 'SingleActionUseCase';
Expand All @@ -21,7 +22,7 @@ export class SingleActionUseCase implements ParamUseCase<Execution, Result[]> {
results.push(...await new DeployedActionUseCase().invoke(param));
}
} catch (error) {
console.error(error);
logError(error);
results.push(
new Result({
id: this.taskId,
Expand Down
3 changes: 2 additions & 1 deletion src/data/usecase/steps/assign_members_to_issue_use_case.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {IssueRepository} from "../../repository/issue_repository";
import {ProjectRepository} from "../../repository/project_repository";
import * as core from "@actions/core";
import {Result} from "../../model/result";
import { logError } from "../../utils/logger";

export class AssignMemberToIssueUseCase implements ParamUseCase<Execution, Result[]> {
taskId: string = 'AssignMemberToIssueUseCase';
Expand Down Expand Up @@ -150,7 +151,7 @@ export class AssignMemberToIssueUseCase implements ParamUseCase<Execution, Resul

return result;
} catch (error) {
console.error(error);
logError(error);
result.push(
new Result({
id: this.taskId,
Expand Down
3 changes: 2 additions & 1 deletion src/data/usecase/steps/assign_reviewers_to_issue_use_case.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {ProjectRepository} from "../../repository/project_repository";
import * as core from "@actions/core";
import {Result} from "../../model/result";
import {PullRequestRepository} from "../../repository/pull_request_repository";
import { logError } from "../../utils/logger";

export class AssignReviewersToIssueUseCase implements ParamUseCase<Execution, Result[]> {
taskId: string = 'AssignReviewersToIssueUseCase';
Expand Down Expand Up @@ -105,7 +106,7 @@ export class AssignReviewersToIssueUseCase implements ParamUseCase<Execution, Re

return result;
} catch (error) {
console.error(error);
logError(error);
result.push(
new Result({
id: this.taskId,
Expand Down
3 changes: 2 additions & 1 deletion src/data/usecase/steps/check_changes_issue_size_use_case.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {Result} from "../../model/result";
import * as core from '@actions/core';
import { BranchRepository } from "../../repository/branch_repository";
import { IssueRepository } from "../../repository/issue_repository";
import { logError } from "../../utils/logger";

export class CheckChangesIssueSizeUseCase implements ParamUseCase<Execution, Result[]> {
taskId: string = 'CheckChangesIssueSizeUseCase';
Expand Down Expand Up @@ -58,7 +59,7 @@ export class CheckChangesIssueSizeUseCase implements ParamUseCase<Execution, Res
);
}
} catch (error) {
console.error(error);
logError(error);
result.push(
new Result({
id: this.taskId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {Result} from "../../model/result";
import * as core from '@actions/core';
import { BranchRepository } from "../../repository/branch_repository";
import { IssueRepository } from "../../repository/issue_repository";
import { logError } from "../../utils/logger";

export class CheckChangesPullRequestSizeUseCase implements ParamUseCase<Execution, Result[]> {
taskId: string = 'CheckChangesPullRequestSizeUseCase';
Expand Down Expand Up @@ -50,7 +51,7 @@ export class CheckChangesPullRequestSizeUseCase implements ParamUseCase<Executio
);
}
} catch (error) {
console.error(error);
logError(error);
result.push(
new Result({
id: this.taskId,
Expand Down
3 changes: 2 additions & 1 deletion src/data/usecase/steps/check_permissions_use_case.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {Execution} from "../../model/execution";
import {ProjectRepository} from "../../repository/project_repository";
import * as core from "@actions/core";
import {Result} from "../../model/result";
import { logError } from "../../utils/logger";

export class CheckPermissionsUseCase implements ParamUseCase<Execution, Result[]> {
taskId: string = 'CheckPermissionsUseCase';
Expand Down Expand Up @@ -70,7 +71,7 @@ export class CheckPermissionsUseCase implements ParamUseCase<Execution, Result[]
);
}
} catch (error) {
console.error(error);
logError(error);
result.push(
new Result({
id: this.taskId,
Expand Down
3 changes: 2 additions & 1 deletion src/data/usecase/steps/execute_script_use_case.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {Execution} from "../../model/execution";
import * as core from "@actions/core";
import {Result} from "../../model/result";
import ivm from 'isolated-vm';
import { logError } from "../../utils/logger";

export class ExecuteScriptUseCase implements ParamUseCase<Execution, Result[]> {
taskId: string = 'ExecuteScriptUseCase';
Expand Down Expand Up @@ -45,7 +46,7 @@ export class ExecuteScriptUseCase implements ParamUseCase<Execution, Result[]> {
})
)
} catch (error) {
console.error(error);
logError(error);
result.push(
new Result({
id: this.taskId,
Expand Down
3 changes: 2 additions & 1 deletion src/data/usecase/steps/get_hotfix_version_use_case.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {Result} from "../../model/result";
import {MarkdownContentHotfixHandler} from "../../manager/description/markdown_content_hotfix_handler";
import {IssueRepository} from "../../repository/issue_repository";
import {extractVersion} from "../../utils/content_utils";
import { logError } from "../../utils/logger";

export class GetHotfixVersionUseCase implements ParamUseCase<Execution, Result[]> {
taskId: string = 'GetHotfixVersionUseCase';
Expand Down Expand Up @@ -92,7 +93,7 @@ export class GetHotfixVersionUseCase implements ParamUseCase<Execution, Result[]
})
);
} catch (error) {
console.error(error);
logError(error);
result.push(
new Result({
id: this.taskId,
Expand Down
3 changes: 2 additions & 1 deletion src/data/usecase/steps/get_release_type_use_case.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {Result} from "../../model/result";
import {MarkdownContentHotfixHandler} from "../../manager/description/markdown_content_hotfix_handler";
import {IssueRepository} from "../../repository/issue_repository";
import {extractReleaseType, extractVersion} from "../../utils/content_utils";
import { logError } from "../../utils/logger";

export class GetReleaseTypeUseCase implements ParamUseCase<Execution, Result[]> {
taskId: string = 'GetReleaseTypeUseCase';
Expand Down Expand Up @@ -80,7 +81,7 @@ export class GetReleaseTypeUseCase implements ParamUseCase<Execution, Result[]>
})
);
} catch (error) {
console.error(error);
logError(error);
result.push(
new Result({
id: this.taskId,
Expand Down
Loading