From dcc53e83c902a0f72657ddaef90ad392918a4af2 Mon Sep 17 00:00:00 2001 From: VickyStash Date: Mon, 25 Mar 2024 18:32:58 +0100 Subject: [PATCH] TS fixes after merging main, remove extra updates --- package.json | 2 +- src/types/modules/act.d.ts | 14 ++++++++++++ workflow_tests/authorChecklist.test.ts | 2 +- workflow_tests/cherryPick.test.ts | 2 +- workflow_tests/failureNotifier.test.ts | 2 +- workflow_tests/mocks/cherryPickMocks.ts | 2 +- workflow_tests/utils/JobMocker.ts | 30 ++++++++----------------- workflow_tests/utils/preGenerateTest.ts | 7 +++--- 8 files changed, 32 insertions(+), 29 deletions(-) create mode 100644 src/types/modules/act.d.ts diff --git a/package.json b/package.json index 0239b2a21635..c41afac9d570 100644 --- a/package.json +++ b/package.json @@ -154,8 +154,8 @@ "react-native-plaid-link-sdk": "10.8.0", "react-native-qrcode-svg": "^6.2.0", "react-native-quick-sqlite": "^8.0.0-beta.2", - "react-native-reanimated": "^3.7.2", "react-native-release-profiler": "^0.1.6", + "react-native-reanimated": "^3.7.2", "react-native-render-html": "6.3.1", "react-native-safe-area-context": "4.8.2", "react-native-screens": "3.29.0", diff --git a/src/types/modules/act.d.ts b/src/types/modules/act.d.ts new file mode 100644 index 000000000000..5fe00ec479cf --- /dev/null +++ b/src/types/modules/act.d.ts @@ -0,0 +1,14 @@ +import type {StepIdentifier as ActStepIdentifier} from '@kie/act-js'; + +declare module '@kie/act-js' { + // eslint-disable-next-line rulesdir/no-inline-named-export + export declare type StepIdentifier = { + id?: string; + name: string; + run?: string; + mockWith?: string; + with?: string; + envs?: string[]; + inputs?: string[]; + } & Omit; +} diff --git a/workflow_tests/authorChecklist.test.ts b/workflow_tests/authorChecklist.test.ts index 1286f0c6c246..c0b1c7cf7533 100644 --- a/workflow_tests/authorChecklist.test.ts +++ b/workflow_tests/authorChecklist.test.ts @@ -3,7 +3,7 @@ import * as kieMockGithub from '@kie/mock-github'; import type {CreateRepositoryFile, MockGithub} from '@kie/mock-github'; import path from 'path'; import assertions from './assertions/authorChecklistAssertions'; -import * as mocks from './mocks/authorChecklistMocks'; +import mocks from './mocks/authorChecklistMocks'; import ExtendedAct from './utils/ExtendedAct'; import * as utils from './utils/utils'; diff --git a/workflow_tests/cherryPick.test.ts b/workflow_tests/cherryPick.test.ts index e8606e6d6323..47a1c489df70 100644 --- a/workflow_tests/cherryPick.test.ts +++ b/workflow_tests/cherryPick.test.ts @@ -3,7 +3,7 @@ import * as kieMockGithub from '@kie/mock-github'; import type {CreateRepositoryFile, MockGithub} from '@kie/mock-github'; import path from 'path'; import assertions from './assertions/cherryPickAssertions'; -import * as mocks from './mocks/cherryPickMocks'; +import mocks from './mocks/cherryPickMocks'; import ExtendedAct from './utils/ExtendedAct'; import type {MockJobs} from './utils/JobMocker'; import * as utils from './utils/utils'; diff --git a/workflow_tests/failureNotifier.test.ts b/workflow_tests/failureNotifier.test.ts index d25378f8500e..8dfc092c7e61 100644 --- a/workflow_tests/failureNotifier.test.ts +++ b/workflow_tests/failureNotifier.test.ts @@ -3,7 +3,7 @@ import type {CreateRepositoryFile} from '@kie/mock-github'; import {MockGithub} from '@kie/mock-github'; import path from 'path'; import assertions from './assertions/failureNotifierAssertions'; -import * as mocks from './mocks/failureNotifierMocks'; +import mocks from './mocks/failureNotifierMocks'; import ExtendedAct from './utils/ExtendedAct'; jest.setTimeout(90 * 1000); diff --git a/workflow_tests/mocks/cherryPickMocks.ts b/workflow_tests/mocks/cherryPickMocks.ts index e7762731c066..c1a33be868d6 100644 --- a/workflow_tests/mocks/cherryPickMocks.ts +++ b/workflow_tests/mocks/cherryPickMocks.ts @@ -110,4 +110,4 @@ const getCherryPickMockSteps = (upToDate: boolean, hasConflicts: boolean): StepI CHERRYPICK__CHERRYPICK__ANNOUNCES_A_CP_FAILURE_IN_THE_ANNOUNCE_SLACK_ROOM__STEP_MOCK, ]; -export {CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, CHERRYPICK__VALIDATEACTOR__FALSE__STEP_MOCKS, CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, getCherryPickMockSteps}; +export default {CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, CHERRYPICK__VALIDATEACTOR__FALSE__STEP_MOCKS, CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, getCherryPickMockSteps}; diff --git a/workflow_tests/utils/JobMocker.ts b/workflow_tests/utils/JobMocker.ts index 592e2a758636..dadb85014d01 100644 --- a/workflow_tests/utils/JobMocker.ts +++ b/workflow_tests/utils/JobMocker.ts @@ -1,23 +1,11 @@ -import type {GithubWorkflowStep, 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'; -type YamlStepIdentifier = Partial & { - name: string; - id?: string; - inputs?: string[]; - envs?: string[]; - run?: GithubWorkflowStep | string; - with?: string; -}; - -type YamlMockJob = Omit & { - steps: YamlStepIdentifier[]; - // eslint-disable-next-line @typescript-eslint/naming-convention - 'runs-on'?: string; -}; +// eslint-disable-next-line @typescript-eslint/naming-convention +type YamlMockJob = Omit & {'runs-on'?: string}; type YamlWorkflow = { jobs: Record; @@ -29,7 +17,7 @@ type MockJob = { secrets?: string[]; with?: string; outputs?: Record; - runsOn?: string; + runsOn: string; }; type MockJobs = Record; @@ -62,12 +50,12 @@ class JobMocker { jobWith = job.with; delete job.with; } - job.steps = mockJob.steps.map((step) => { - const mockStep: YamlStepIdentifier = { - name: 'name' in step ? step.name : '', + job.steps = mockJob.steps.map((step): StepIdentifier => { + const mockStep: StepIdentifier = { + name: step.name, run: step.mockWith, }; - if ('id' in step && step.id) { + if (step.id) { mockStep.id = step.id; } if (jobWith) { @@ -117,4 +105,4 @@ class JobMocker { } export default JobMocker; -export type {MockJob, MockJobs, YamlWorkflow, YamlMockJob, YamlStepIdentifier}; +export type {MockJob, MockJobs, YamlWorkflow, YamlMockJob}; diff --git a/workflow_tests/utils/preGenerateTest.ts b/workflow_tests/utils/preGenerateTest.ts index bc4867a83827..c5e54d9a11c0 100644 --- a/workflow_tests/utils/preGenerateTest.ts +++ b/workflow_tests/utils/preGenerateTest.ts @@ -1,10 +1,11 @@ /* eslint no-console: ["error", { allow: ["warn", "log"] }] */ +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, YamlStepIdentifier, YamlWorkflow} from './JobMocker'; +import type {YamlMockJob, YamlWorkflow} from './JobMocker'; const workflowsDirectory = path.resolve(__dirname, '..', '..', '.github', 'workflows'); const workflowTestsDirectory = path.resolve(__dirname, '..'); @@ -97,7 +98,7 @@ describe('test workflow ${workflowName}', () => { }); `; -const mockStepTemplate = (stepMockName: string, step: YamlStepIdentifier, jobId: string | undefined) => ` +const mockStepTemplate = (stepMockName: string, step: StepIdentifier, jobId: string | undefined) => ` const ${stepMockName} = utils.createMockStep( '${step.name ?? ''}', '${step.name ?? ''}', @@ -203,7 +204,7 @@ const parseWorkflowFile = (workflow: YamlWorkflow) => { steps: [], }; job.steps.forEach((step) => { - const workflowStep: YamlStepIdentifier = { + const workflowStep = { name: step.name, inputs: Object.keys(step.with ?? {}), envs: step.envs ?? [],