Skip to content

Commit

Permalink
fix kie/act-js types
Browse files Browse the repository at this point in the history
  • Loading branch information
bgawkuc committed Jun 13, 2024
1 parent 64ca929 commit 04fcd4b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/actions/javascript/authorChecklist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16967,7 +16967,7 @@ async function detectReactComponentInFile(filename) {
owner: CONST_1.default.GITHUB_OWNER,
repo: CONST_1.default.APP_REPO,
path: filename,
ref: github.context.payload.pull_request?.head.ref,
ref: github.context.payload?.pull_request?.head.ref,
};
try {
const { data } = await GithubUtils_1.default.octokit.repos.getContent(params);
Expand Down
9 changes: 4 additions & 5 deletions src/types/modules/act.d.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import type {StepIdentifier} from '@kie/act-js/build/src/step-mocker/step-mocker.types';
import type {StepIdentifier as ActStepIdentifier} from '@kie/act-js/build/src/step-mocker/step-mocker.types';

declare module '@kie/act-js' {
type StepIdentifierCustom = {
// 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<StepIdentifier, 'name' | 'id' | 'run' | 'mockWith'>;

export type {StepIdentifier, StepIdentifierCustom};
} & Omit<ActStepIdentifier, 'name' | 'id' | 'run' | 'mockWith'>;
}
8 changes: 4 additions & 4 deletions workflow_tests/utils/JobMocker.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type {StepIdentifierCustom} from '@kie/act-js';
import type {StepIdentifier} from '@kie/act-js';
import type {PathOrFileDescriptor} from 'fs';
import fs from 'fs';
import path from 'path';
Expand All @@ -12,7 +12,7 @@ type YamlWorkflow = {
};

type MockJob = {
steps: StepIdentifierCustom[];
steps: StepIdentifier[];
uses?: string;
secrets?: string[];
with?: string;
Expand Down Expand Up @@ -50,8 +50,8 @@ class JobMocker {
jobWith = job.with;
delete job.with;
}
job.steps = mockJob.steps.map((step): StepIdentifierCustom => {
const mockStep: StepIdentifierCustom = {
job.steps = mockJob.steps.map((step): StepIdentifier => {
const mockStep: StepIdentifier = {
name: step.name,
run: step.mockWith,
};
Expand Down
8 changes: 4 additions & 4 deletions workflow_tests/utils/preGenerateTest.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint no-console: ["error", { allow: ["warn", "log"] }] */
import type {StepIdentifierCustom} from '@kie/act-js';
import type {StepIdentifier} from '@kie/act-js';
import type {PathLike} from 'fs';
import fs from 'fs';
import path from 'path';
Expand Down Expand Up @@ -92,7 +92,7 @@ describe('test workflow ${workflowName}', () => {
});
`;

const mockStepTemplate = (stepMockName: string, step: StepIdentifierCustom, jobId: string | undefined) => `
const mockStepTemplate = (stepMockName: string, step: StepIdentifier, jobId: string | undefined) => `
const ${stepMockName} = utils.createMockStep(
'${step.name ?? ''}',
'${step.name ?? ''}',
Expand Down Expand Up @@ -199,7 +199,7 @@ const parseWorkflowFile = (workflow: YamlWorkflow) => {
workflowJobs[jobId] = {
steps: [],
};
job.steps.forEach((step: StepIdentifierCustom) => {
job.steps.forEach((step: StepIdentifier) => {
const workflowStep = {
name: step.name,
inputs: Object.keys(step.with ?? {}),
Expand Down Expand Up @@ -243,7 +243,7 @@ const getAssertionsFileContent = (jobs: Record<string, YamlMockJob>): string =>

Object.entries(jobs).forEach(([jobId, job]) => {
let stepAssertionsContent = '';
job.steps.forEach((step: StepIdentifierCustom) => {
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`;
Expand Down

0 comments on commit 04fcd4b

Please sign in to comment.