Skip to content

Commit

Permalink
TS fixes after merging main, remove extra updates
Browse files Browse the repository at this point in the history
  • Loading branch information
VickyStash committed Mar 25, 2024
1 parent 0f90985 commit dcc53e8
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 29 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
14 changes: 14 additions & 0 deletions src/types/modules/act.d.ts
Original file line number Diff line number Diff line change
@@ -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<ActStepIdentifier, 'name' | 'id' | 'run' | 'mockWith'>;
}
2 changes: 1 addition & 1 deletion workflow_tests/authorChecklist.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
2 changes: 1 addition & 1 deletion workflow_tests/cherryPick.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion workflow_tests/failureNotifier.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion workflow_tests/mocks/cherryPickMocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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};
30 changes: 9 additions & 21 deletions workflow_tests/utils/JobMocker.ts
Original file line number Diff line number Diff line change
@@ -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<StepIdentifier> & {
name: string;
id?: string;
inputs?: string[];
envs?: string[];
run?: GithubWorkflowStep | string;
with?: string;
};

type YamlMockJob = Omit<MockJob, 'runsOn' | 'steps'> & {
steps: YamlStepIdentifier[];
// eslint-disable-next-line @typescript-eslint/naming-convention
'runs-on'?: string;
};
// eslint-disable-next-line @typescript-eslint/naming-convention
type YamlMockJob = Omit<MockJob, 'runsOn'> & {'runs-on'?: string};

type YamlWorkflow = {
jobs: Record<string, YamlMockJob>;
Expand All @@ -29,7 +17,7 @@ type MockJob = {
secrets?: string[];
with?: string;
outputs?: Record<string, string>;
runsOn?: string;
runsOn: string;
};

type MockJobs = Record<string, MockJob>;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -117,4 +105,4 @@ class JobMocker {
}

export default JobMocker;
export type {MockJob, MockJobs, YamlWorkflow, YamlMockJob, YamlStepIdentifier};
export type {MockJob, MockJobs, YamlWorkflow, YamlMockJob};
7 changes: 4 additions & 3 deletions workflow_tests/utils/preGenerateTest.ts
Original file line number Diff line number Diff line change
@@ -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, '..');
Expand Down Expand Up @@ -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 ?? ''}',
Expand Down Expand Up @@ -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 ?? [],
Expand Down

0 comments on commit dcc53e8

Please sign in to comment.