diff --git a/src/types/modules/act.d.ts b/src/types/modules/act.d.ts new file mode 100644 index 000000000000..da2041d430b9 --- /dev/null +++ b/src/types/modules/act.d.ts @@ -0,0 +1,17 @@ +import type {MockStep as ActMockStep, StepIdentifier as ActStepIdentifier} from '@kie/act-js/build/src/step-mocker/step-mocker.types'; + +declare module '@kie/act-js' { + type StepIdentifier = ActStepIdentifier & { + id?: string; + name: string; + run?: string; + mockWith?: string; + with?: string; + envs?: string[]; + inputs?: string[]; + }; + + type MockStep = ActMockStep; + + export type {StepIdentifier, MockStep}; +} diff --git a/workflow_tests/authorChecklist.test.ts b/workflow_tests/authorChecklist.test.ts index 84509818ff61..a40b183f6d7a 100644 --- a/workflow_tests/authorChecklist.test.ts +++ b/workflow_tests/authorChecklist.test.ts @@ -1,4 +1,4 @@ -import type {MockStep} from '@kie/act-js/build/src/step-mocker/step-mocker.types'; +import type {MockStep} from '@kie/act-js'; import {MockGithub} from '@kie/mock-github'; import type {CreateRepositoryFile} from '@kie/mock-github'; import path from 'path'; diff --git a/workflow_tests/cherryPick.test.ts b/workflow_tests/cherryPick.test.ts index 56ce851755b6..964be3ec427d 100644 --- a/workflow_tests/cherryPick.test.ts +++ b/workflow_tests/cherryPick.test.ts @@ -1,4 +1,4 @@ -import type {MockStep} from '@kie/act-js/build/src/step-mocker/step-mocker.types'; +import type {MockStep} from '@kie/act-js'; import {MockGithub} from '@kie/mock-github'; import type {CreateRepositoryFile} from '@kie/mock-github'; import path from 'path'; diff --git a/workflow_tests/failureNotifier.test.ts b/workflow_tests/failureNotifier.test.ts index 07ebb45517b3..772cd5d28050 100644 --- a/workflow_tests/failureNotifier.test.ts +++ b/workflow_tests/failureNotifier.test.ts @@ -1,4 +1,4 @@ -import type {MockStep} from '@kie/act-js/build/src/step-mocker/step-mocker.types'; +import type {MockStep} from '@kie/act-js'; import {MockGithub} from '@kie/mock-github'; import type {CreateRepositoryFile} from '@kie/mock-github'; import path from 'path'; diff --git a/workflow_tests/lockDeploys.test.ts b/workflow_tests/lockDeploys.test.ts index c9b083b4d804..7ffb4ed87b7a 100644 --- a/workflow_tests/lockDeploys.test.ts +++ b/workflow_tests/lockDeploys.test.ts @@ -1,4 +1,4 @@ -import type {MockStep} from '@kie/act-js/build/src/step-mocker/step-mocker.types'; +import type {MockStep} from '@kie/act-js'; import {MockGithub} from '@kie/mock-github'; import type {CreateRepositoryFile} from '@kie/mock-github'; import path from 'path'; diff --git a/workflow_tests/mocks/authorChecklistMocks.ts b/workflow_tests/mocks/authorChecklistMocks.ts index 50e90ddae799..34e6b0984e83 100644 --- a/workflow_tests/mocks/authorChecklistMocks.ts +++ b/workflow_tests/mocks/authorChecklistMocks.ts @@ -1,5 +1,5 @@ /* eslint-disable @typescript-eslint/naming-convention */ -import type {StepIdentifier} from '@kie/act-js/build/src/step-mocker/step-mocker.types'; +import type {StepIdentifier} from '@kie/act-js'; import {createMockStep} from '../utils/utils'; // checklist diff --git a/workflow_tests/mocks/cherryPickMocks.ts b/workflow_tests/mocks/cherryPickMocks.ts index c1a33be868d6..13d7ebf95bfd 100644 --- a/workflow_tests/mocks/cherryPickMocks.ts +++ b/workflow_tests/mocks/cherryPickMocks.ts @@ -1,5 +1,5 @@ /* eslint-disable @typescript-eslint/naming-convention */ -import type {StepIdentifier} from '@kie/act-js/build/src/step-mocker/step-mocker.types'; +import type {StepIdentifier} from '@kie/act-js'; import {createMockStep} from '../utils/utils'; // validateactor diff --git a/workflow_tests/mocks/createNewVersionMocks.ts b/workflow_tests/mocks/createNewVersionMocks.ts index 4703b13e3779..dd094e6459e8 100644 --- a/workflow_tests/mocks/createNewVersionMocks.ts +++ b/workflow_tests/mocks/createNewVersionMocks.ts @@ -1,5 +1,5 @@ /* eslint-disable @typescript-eslint/naming-convention */ -import type {StepIdentifier} from '@kie/act-js/build/src/step-mocker/step-mocker.types'; +import type {StepIdentifier} from '@kie/act-js'; import {createMockStep} from '../utils/utils'; // validateactor diff --git a/workflow_tests/mocks/deployBlockerMocks.ts b/workflow_tests/mocks/deployBlockerMocks.ts index a5b26f876103..b60d41383a1e 100644 --- a/workflow_tests/mocks/deployBlockerMocks.ts +++ b/workflow_tests/mocks/deployBlockerMocks.ts @@ -1,5 +1,5 @@ /* eslint-disable @typescript-eslint/naming-convention */ -import type {StepIdentifier} from '@kie/act-js/build/src/step-mocker/step-mocker.types'; +import type {StepIdentifier} from '@kie/act-js'; import {createMockStep} from '../utils/utils'; // updateChecklist diff --git a/workflow_tests/mocks/deployMocks.ts b/workflow_tests/mocks/deployMocks.ts index f7d0c7132f7a..2fda1efe8e78 100644 --- a/workflow_tests/mocks/deployMocks.ts +++ b/workflow_tests/mocks/deployMocks.ts @@ -1,5 +1,5 @@ /* eslint-disable @typescript-eslint/naming-convention */ -import type {StepIdentifier} from '@kie/act-js/build/src/step-mocker/step-mocker.types'; +import type {StepIdentifier} from '@kie/act-js'; import {createMockStep} from '../utils/utils'; const DEPLOY_STAGING__CHECKOUT__STEP_MOCK = createMockStep('Checkout staging branch', 'Checking out staging branch', 'DEPLOY_STAGING', ['ref', 'token']); diff --git a/workflow_tests/mocks/finishReleaseCycleMocks.ts b/workflow_tests/mocks/finishReleaseCycleMocks.ts index 2c5d84488e3f..23d81a557705 100644 --- a/workflow_tests/mocks/finishReleaseCycleMocks.ts +++ b/workflow_tests/mocks/finishReleaseCycleMocks.ts @@ -1,5 +1,5 @@ /* eslint-disable @typescript-eslint/naming-convention */ -import type {StepIdentifier} from '@kie/act-js/build/src/step-mocker/step-mocker.types'; +import type {StepIdentifier} from '@kie/act-js'; import {createMockStep} from '../utils/utils'; // validate diff --git a/workflow_tests/mocks/lintMocks.ts b/workflow_tests/mocks/lintMocks.ts index a3eb2b61cbc5..27ce53afc1f4 100644 --- a/workflow_tests/mocks/lintMocks.ts +++ b/workflow_tests/mocks/lintMocks.ts @@ -1,5 +1,5 @@ /* eslint-disable @typescript-eslint/naming-convention */ -import type {StepIdentifier} from '@kie/act-js/build/src/step-mocker/step-mocker.types'; +import type {StepIdentifier} from '@kie/act-js'; import {createMockStep} from '../utils/utils'; // lint diff --git a/workflow_tests/platformDeploy.test.ts b/workflow_tests/platformDeploy.test.ts index 0ac68eb6d55b..f3247acd0d14 100644 --- a/workflow_tests/platformDeploy.test.ts +++ b/workflow_tests/platformDeploy.test.ts @@ -1,4 +1,4 @@ -import type {MockStep} from '@kie/act-js/build/src/step-mocker/step-mocker.types'; +import type {MockStep} from '@kie/act-js'; import {MockGithub} from '@kie/mock-github'; import type {CreateRepositoryFile} from '@kie/mock-github'; import path from 'path'; diff --git a/workflow_tests/preDeploy.test.ts b/workflow_tests/preDeploy.test.ts index 1739fec13815..a69356f84972 100644 --- a/workflow_tests/preDeploy.test.ts +++ b/workflow_tests/preDeploy.test.ts @@ -1,4 +1,4 @@ -import type {MockStep} from '@kie/act-js/build/src/step-mocker/step-mocker.types'; +import type {MockStep} from '@kie/act-js'; import {MockGithub} from '@kie/mock-github'; import type {CreateRepositoryFile} from '@kie/mock-github'; import path from 'path'; diff --git a/workflow_tests/reviewerChecklist.test.ts b/workflow_tests/reviewerChecklist.test.ts index d70afd31f115..1fea2b60008c 100644 --- a/workflow_tests/reviewerChecklist.test.ts +++ b/workflow_tests/reviewerChecklist.test.ts @@ -1,4 +1,4 @@ -import type {MockStep} from '@kie/act-js/build/src/step-mocker/step-mocker.types'; +import type {MockStep} from '@kie/act-js'; import {MockGithub} from '@kie/mock-github'; import type {CreateRepositoryFile} from '@kie/mock-github'; import path from 'path'; diff --git a/workflow_tests/test.test.ts b/workflow_tests/test.test.ts index 085a2b3902d6..fe189f2a8e8a 100644 --- a/workflow_tests/test.test.ts +++ b/workflow_tests/test.test.ts @@ -1,4 +1,4 @@ -import type {MockStep} from '@kie/act-js/build/src/step-mocker/step-mocker.types'; +import type {MockStep} from '@kie/act-js'; import {MockGithub} from '@kie/mock-github'; import type {CreateRepositoryFile} from '@kie/mock-github'; import path from 'path'; diff --git a/workflow_tests/utils/JobMocker.ts b/workflow_tests/utils/JobMocker.ts index 14e721eb3612..78be5c5861e6 100644 --- a/workflow_tests/utils/JobMocker.ts +++ b/workflow_tests/utils/JobMocker.ts @@ -1,9 +1,8 @@ -import type {StepIdentifier} from '@kie/act-js/build/src/step-mocker/step-mocker.types'; +import type {StepIdentifier} from '@kie/act-js'; import type {PathOrFileDescriptor} from 'fs'; import fs from 'fs'; import path from 'path'; import yaml from 'yaml'; -import type CustemStepIdentifier from './types'; // eslint-disable-next-line @typescript-eslint/naming-convention type YamlMockJob = Omit & {'runs-on'?: string}; @@ -13,7 +12,7 @@ type YamlWorkflow = { }; type MockJob = { - steps: Array; + steps: StepIdentifier[]; uses?: string; secrets?: string[]; with?: string; @@ -52,13 +51,12 @@ class JobMocker { delete job.with; } job.steps = mockJob.steps.map((step) => { - const customStep = step as CustemStepIdentifier; - const mockStep: CustemStepIdentifier = { - name: customStep.name, + const mockStep = { + name: step.name, run: step.mockWith, - }; - if (customStep.id) { - mockStep.id = customStep.id; + } as StepIdentifier; + if (step.id) { + mockStep.id = step.id; } if (jobWith) { mockStep.with = jobWith; diff --git a/workflow_tests/utils/preGenerateTest.ts b/workflow_tests/utils/preGenerateTest.ts index ac90e690b72e..1fbbd6e3de4c 100644 --- a/workflow_tests/utils/preGenerateTest.ts +++ b/workflow_tests/utils/preGenerateTest.ts @@ -1,12 +1,11 @@ /* eslint no-console: ["error", { allow: ["warn", "log"] }] */ -import type {StepIdentifier} from '@kie/act-js/build/src/step-mocker/step-mocker.types'; +import type {StepIdentifier} from '@kie/act-js'; import type {PathLike} from 'fs'; import fs from 'fs'; import path from 'path'; import {exit} from 'process'; import yaml from 'yaml'; import type {YamlMockJob, YamlWorkflow} from './JobMocker'; -import type CustemStepIdentifier from './types'; const workflowsDirectory = path.resolve(__dirname, '..', '..', '.github', 'workflows'); const workflowTestsDirectory = path.resolve(__dirname, '..'); @@ -93,7 +92,7 @@ describe('test workflow ${workflowName}', () => { }); `; -const mockStepTemplate = (stepMockName: string, step: CustemStepIdentifier, jobId: string | undefined) => ` +const mockStepTemplate = (stepMockName: string, step: StepIdentifier, jobId: string | undefined) => ` const ${stepMockName} = utils.createMockStep( '${step.name ?? ''}', '${step.name ?? ''}', @@ -201,12 +200,11 @@ const parseWorkflowFile = (workflow: YamlWorkflow) => { steps: [], }; job.steps.forEach((step) => { - const step2 = step as CustemStepIdentifier; const workflowStep = { - name: step2.name ?? '', - inputs: Object.keys(step2.with ?? {}), - envs: step2.envs ?? [], - }; + name: step.name ?? '', + inputs: Object.keys(step.with ?? {}), + envs: step.envs ?? [], + } as StepIdentifier; workflowJobs[jobId].steps.push(workflowStep); }); }); @@ -219,8 +217,7 @@ const getMockFileContent = (workflowName: string, jobs: Record { - const customStep = step as CustemStepIdentifier; - const stepMockName = `${workflowName.toUpperCase()}__${jobId.toUpperCase()}__${customStep.name + const stepMockName = `${workflowName.toUpperCase()}__${jobId.toUpperCase()}__${step.name .replaceAll(' ', '_') .replaceAll('-', '_') .replaceAll(',', '') @@ -229,7 +226,7 @@ const getMockFileContent = (workflowName: string, jobs: Record): string => Object.entries(jobs).forEach(([jobId, job]) => { let stepAssertionsContent = ''; - job.steps.forEach((step: CustemStepIdentifier | StepIdentifier) => { - const customStep = step as CustemStepIdentifier; - stepAssertionsContent += stepAssertionTemplate(customStep.name, jobId.toUpperCase(), customStep.name, customStep.inputs, customStep.envs); + job.steps.forEach((step: StepIdentifier) => { + stepAssertionsContent += stepAssertionTemplate(step.name, jobId.toUpperCase(), step.name, step.inputs, step.envs); }); const jobAssertionName = `assert${jobId.charAt(0).toUpperCase() + jobId.slice(1)}JobExecuted`; jobAssertions.push(jobAssertionName); diff --git a/workflow_tests/utils/types.ts b/workflow_tests/utils/types.ts deleted file mode 100644 index 79b2e7756498..000000000000 --- a/workflow_tests/utils/types.ts +++ /dev/null @@ -1,13 +0,0 @@ -import type {GithubWorkflowStep, StepIdentifier} from '@kie/act-js/build/src/step-mocker/step-mocker.types'; - -type CustemStepIdentifier = { - id?: string; - name: string; - run?: string | GithubWorkflowStep; - mockWith?: string | GithubWorkflowStep; - with?: string; - envs?: string[]; - inputs?: string[]; -} & Omit; - -export default CustemStepIdentifier; diff --git a/workflow_tests/utils/utils.ts b/workflow_tests/utils/utils.ts index 77e15c0602eb..e0ff88a3a5bd 100644 --- a/workflow_tests/utils/utils.ts +++ b/workflow_tests/utils/utils.ts @@ -1,5 +1,5 @@ +import type {StepIdentifier} from '@kie/act-js'; import type {EventJSON} from '@kie/act-js/build/src/action-event/action-event.types'; -import type {StepIdentifier} from '@kie/act-js/build/src/step-mocker/step-mocker.types'; import fs from 'fs'; import path from 'path'; import yaml from 'yaml';