diff --git a/src/types/modules/act.d.ts b/src/types/modules/act.d.ts deleted file mode 100644 index 5fe00ec479cf..000000000000 --- a/src/types/modules/act.d.ts +++ /dev/null @@ -1,14 +0,0 @@ -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/createNewVersion.test.ts b/workflow_tests/createNewVersion.test.js similarity index 93% rename from workflow_tests/createNewVersion.test.ts rename to workflow_tests/createNewVersion.test.js index 05dcc2b10073..08ac63ba9948 100644 --- a/workflow_tests/createNewVersion.test.ts +++ b/workflow_tests/createNewVersion.test.js @@ -1,13 +1,12 @@ -import {MockGithub} from '@kie/mock-github'; -import path from 'path'; -import assertions from './assertions/createNewVersionAssertions'; -import mocks from './mocks/createNewVersionMocks'; -import ExtendedAct from './utils/ExtendedAct'; -import * as utils from './utils/utils'; +const path = require('path'); +const kieMockGithub = require('@kie/mock-github'); +const utils = require('./utils/utils'); +const assertions = require('./assertions/createNewVersionAssertions'); +const mocks = require('./mocks/createNewVersionMocks'); +const ExtendedAct = require('./utils/ExtendedAct').default; jest.setTimeout(90 * 1000); // 90 sec -let mockGithub: MockGithub; - +let mockGithub; const FILES_TO_COPY_INTO_TEST_REPO = [ ...utils.deepCopy(utils.FILES_TO_COPY_INTO_TEST_REPO), { @@ -17,7 +16,7 @@ const FILES_TO_COPY_INTO_TEST_REPO = [ ]; describe('test workflow createNewVersion', () => { - beforeAll(() => { + beforeAll(async () => { // in case of the tests being interrupted without cleanup the mock repo directory may be left behind // which breaks the next test run, this removes any possible leftovers utils.removeMockRepoDir(); @@ -25,7 +24,7 @@ describe('test workflow createNewVersion', () => { beforeEach(async () => { // create a local repository and copy required files - mockGithub = new MockGithub({ + mockGithub = new kieMockGithub.MockGithub({ repo: { testCreateNewVersionWorkflowRepo: { files: FILES_TO_COPY_INTO_TEST_REPO, @@ -57,7 +56,7 @@ describe('test workflow createNewVersion', () => { describe('actor is admin', () => { const validateActorMockSteps = mocks.CREATENEWVERSION__VALIDATEACTOR__ADMIN__STEP_MOCKS; it('executes full workflow', async () => { - const repoPath = mockGithub.repo.getPath('testCreateNewVersionWorkflowRepo') ?? ''; + const repoPath = mockGithub.repo.getPath('testCreateNewVersionWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'createNewVersion.yml'); let act = new ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, {}, secrets, githubToken, {}, inputs); @@ -80,7 +79,7 @@ describe('test workflow createNewVersion', () => { describe('actor is writer', () => { const validateActorMockSteps = mocks.CREATENEWVERSION__VALIDATEACTOR__WRITER__STEP_MOCKS; it('executes full workflow', async () => { - const repoPath = mockGithub.repo.getPath('testCreateNewVersionWorkflowRepo') ?? ''; + const repoPath = mockGithub.repo.getPath('testCreateNewVersionWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'createNewVersion.yml'); let act = new ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, {}, secrets, githubToken, {}, inputs); @@ -103,7 +102,7 @@ describe('test workflow createNewVersion', () => { describe('actor is reader', () => { const validateActorMockSteps = mocks.CREATENEWVERSION__VALIDATEACTOR__NO_PERMISSION__STEP_MOCKS; it('stops after validation', async () => { - const repoPath = mockGithub.repo.getPath('testCreateNewVersionWorkflowRepo') ?? ''; + const repoPath = mockGithub.repo.getPath('testCreateNewVersionWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'createNewVersion.yml'); let act = new ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, {}, secrets, githubToken, {}, inputs); @@ -125,7 +124,7 @@ describe('test workflow createNewVersion', () => { describe('one step fails', () => { it('announces failure on Slack', async () => { - const repoPath = mockGithub.repo.getPath('testCreateNewVersionWorkflowRepo') ?? ''; + const repoPath = mockGithub.repo.getPath('testCreateNewVersionWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'createNewVersion.yml'); let act = new ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, {}, secrets, githubToken, {}, inputs); @@ -134,7 +133,7 @@ describe('test workflow createNewVersion', () => { validateActor: mocks.CREATENEWVERSION__VALIDATEACTOR__ADMIN__STEP_MOCKS, createNewVersion: utils.deepCopy(mocks.CREATENEWVERSION__CREATENEWVERSION__STEP_MOCKS), }; - testMockSteps.createNewVersion[5] = utils.createMockStep('Commit new version', 'Commit new version', 'CREATENEWVERSION', [], [], {}, {}, false); + testMockSteps.createNewVersion[5] = utils.createMockStep('Commit new version', 'Commit new version', 'CREATENEWVERSION', [], [], [], [], false); const result = await act.runEvent(event, { workflowFile: path.join(repoPath, '.github', 'workflows', 'createNewVersion.yml'), mockSteps: testMockSteps, @@ -147,7 +146,7 @@ describe('test workflow createNewVersion', () => { }); it('chooses source branch depending on the SEMVER_LEVEL', async () => { - const repoPath = mockGithub.repo.getPath('testCreateNewVersionWorkflowRepo') ?? ''; + const repoPath = mockGithub.repo.getPath('testCreateNewVersionWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'createNewVersion.yml'); let act = new ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, {}, secrets, githubToken, {}, {SEMVER_LEVEL: 'MAJOR'}); diff --git a/workflow_tests/deploy.test.ts b/workflow_tests/deploy.test.js similarity index 93% rename from workflow_tests/deploy.test.ts rename to workflow_tests/deploy.test.js index 4edb3b252d38..cf5b658d3ffb 100644 --- a/workflow_tests/deploy.test.ts +++ b/workflow_tests/deploy.test.js @@ -1,13 +1,12 @@ -import {MockGithub} from '@kie/mock-github'; -import path from 'path'; -import assertions from './assertions/deployAssertions'; -import mocks from './mocks/deployMocks'; -import ExtendedAct from './utils/ExtendedAct'; -import * as utils from './utils/utils'; +const path = require('path'); +const kieMockGithub = require('@kie/mock-github'); +const utils = require('./utils/utils'); +const assertions = require('./assertions/deployAssertions'); +const mocks = require('./mocks/deployMocks'); +const ExtendedAct = require('./utils/ExtendedAct').default; jest.setTimeout(90 * 1000); -let mockGithub: MockGithub; - +let mockGithub; const FILES_TO_COPY_INTO_TEST_REPO = [ ...utils.deepCopy(utils.FILES_TO_COPY_INTO_TEST_REPO), { @@ -17,7 +16,7 @@ const FILES_TO_COPY_INTO_TEST_REPO = [ ]; describe('test workflow deploy', () => { - beforeAll(() => { + beforeAll(async () => { // in case of the tests being interrupted without cleanup the mock repo directory may be left behind // which breaks the next test run, this removes any possible leftovers utils.removeMockRepoDir(); @@ -25,7 +24,7 @@ describe('test workflow deploy', () => { beforeEach(async () => { // create a local repository and copy required files - mockGithub = new MockGithub({ + mockGithub = new kieMockGithub.MockGithub({ repo: { testDeployWorkflowRepo: { files: FILES_TO_COPY_INTO_TEST_REPO, @@ -49,7 +48,7 @@ describe('test workflow deploy', () => { }; describe('push', () => { it('to main - nothing triggered', async () => { - const repoPath = mockGithub.repo.getPath('testDeployWorkflowRepo') ?? ''; + const repoPath = mockGithub.repo.getPath('testDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'deploy.yml'); let act = new ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( @@ -76,7 +75,7 @@ describe('test workflow deploy', () => { }); it('to staging - deployStaging triggered', async () => { - const repoPath = mockGithub.repo.getPath('testDeployWorkflowRepo') ?? ''; + const repoPath = mockGithub.repo.getPath('testDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'deploy.yml'); let act = new ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( @@ -103,7 +102,7 @@ describe('test workflow deploy', () => { }); it('to production - deployProduction triggered', async () => { - const repoPath = mockGithub.repo.getPath('testDeployWorkflowRepo') ?? ''; + const repoPath = mockGithub.repo.getPath('testDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'deploy.yml'); let act = new ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( @@ -131,7 +130,7 @@ describe('test workflow deploy', () => { }); it('different event than push - workflow does not execute', async () => { - const repoPath = mockGithub.repo.getPath('testDeployWorkflowRepo') ?? ''; + const repoPath = mockGithub.repo.getPath('testDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'deploy.yml'); let act = new ExtendedAct(repoPath, workflowPath); const testMockSteps = { diff --git a/workflow_tests/deployBlocker.test.ts b/workflow_tests/deployBlocker.test.js similarity index 92% rename from workflow_tests/deployBlocker.test.ts rename to workflow_tests/deployBlocker.test.js index d6ee67f97f2c..42c4f9e741f7 100644 --- a/workflow_tests/deployBlocker.test.ts +++ b/workflow_tests/deployBlocker.test.js @@ -1,13 +1,12 @@ -import {MockGithub} from '@kie/mock-github'; -import path from 'path'; -import assertions from './assertions/deployBlockerAssertions'; -import mocks from './mocks/deployBlockerMocks'; -import ExtendedAct from './utils/ExtendedAct'; -import * as utils from './utils/utils'; +const path = require('path'); +const kieMockGithub = require('@kie/mock-github'); +const utils = require('./utils/utils'); +const assertions = require('./assertions/deployBlockerAssertions'); +const mocks = require('./mocks/deployBlockerMocks'); +const ExtendedAct = require('./utils/ExtendedAct').default; jest.setTimeout(90 * 1000); -let mockGithub: MockGithub; - +let mockGithub; const FILES_TO_COPY_INTO_TEST_REPO = [ ...utils.deepCopy(utils.FILES_TO_COPY_INTO_TEST_REPO), { @@ -24,7 +23,7 @@ describe('test workflow deployBlocker', () => { SLACK_WEBHOOK: 'dummy_slack_webhook', }; - beforeAll(() => { + beforeAll(async () => { // in case of the tests being interrupted without cleanup the mock repo directory may be left behind // which breaks the next test run, this removes any possible leftovers utils.removeMockRepoDir(); @@ -32,7 +31,7 @@ describe('test workflow deployBlocker', () => { beforeEach(async () => { // create a local repository and copy required files - mockGithub = new MockGithub({ + mockGithub = new kieMockGithub.MockGithub({ repo: { testDeployBlockerWorkflowRepo: { files: FILES_TO_COPY_INTO_TEST_REPO, @@ -58,7 +57,6 @@ describe('test workflow deployBlocker', () => { issue: { title: 'Labeled issue title', number: '1234', - // eslint-disable-next-line @typescript-eslint/naming-convention html_url: 'http://issue.html.url', }, }; @@ -66,7 +64,7 @@ describe('test workflow deployBlocker', () => { const testEventOptions = utils.deepCopy(eventOptions); testEventOptions.label = {name: 'DeployBlockerCash'}; it('runs the workflow and announces success on Slack', async () => { - const repoPath = mockGithub.repo.getPath('testDeployBlockerWorkflowRepo') ?? ''; + const repoPath = mockGithub.repo.getPath('testDeployBlockerWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'deployBlocker.yml'); let act = new ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, testEventOptions, secrets, githubToken, {}, {}); @@ -92,7 +90,7 @@ describe('test workflow deployBlocker', () => { }); describe('one step fails', () => { it('announces failure on Slack', async () => { - const repoPath = mockGithub.repo.getPath('testDeployBlockerWorkflowRepo') ?? ''; + const repoPath = mockGithub.repo.getPath('testDeployBlockerWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'deployBlocker.yml'); let act = new ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, testEventOptions, secrets, githubToken, {}, {}); @@ -132,7 +130,7 @@ describe('test workflow deployBlocker', () => { const testEventOptions = utils.deepCopy(eventOptions); testEventOptions.label = {name: 'Different Label'}; it('does not run workflow', async () => { - const repoPath = mockGithub.repo.getPath('testDeployBlockerWorkflowRepo') ?? ''; + const repoPath = mockGithub.repo.getPath('testDeployBlockerWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'deployBlocker.yml'); let act = new ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, testEventOptions, secrets, githubToken, {}, {}); diff --git a/workflow_tests/finishReleaseCycle.test.ts b/workflow_tests/finishReleaseCycle.test.js similarity index 94% rename from workflow_tests/finishReleaseCycle.test.ts rename to workflow_tests/finishReleaseCycle.test.js index 44f9c57ab9da..20ab66471d91 100644 --- a/workflow_tests/finishReleaseCycle.test.ts +++ b/workflow_tests/finishReleaseCycle.test.js @@ -1,13 +1,12 @@ -import {MockGithub} from '@kie/mock-github'; -import path from 'path'; -import assertions from './assertions/finishReleaseCycleAssertions'; -import mocks from './mocks/finishReleaseCycleMocks'; -import ExtendedAct from './utils/ExtendedAct'; -import type {MockJobs} from './utils/JobMocker'; -import * as utils from './utils/utils'; +const path = require('path'); +const kieMockGithub = require('@kie/mock-github'); +const utils = require('./utils/utils'); +const assertions = require('./assertions/finishReleaseCycleAssertions'); +const mocks = require('./mocks/finishReleaseCycleMocks'); +const ExtendedAct = require('./utils/ExtendedAct').default; jest.setTimeout(90 * 1000); -let mockGithub: MockGithub; +let mockGithub; const FILES_TO_COPY_INTO_TEST_REPO = [ ...utils.deepCopy(utils.FILES_TO_COPY_INTO_TEST_REPO), { @@ -17,7 +16,7 @@ const FILES_TO_COPY_INTO_TEST_REPO = [ ]; describe('test workflow finishReleaseCycle', () => { - beforeAll(() => { + beforeAll(async () => { // in case of the tests being interrupted without cleanup the mock repo directory may be left behind // which breaks the next test run, this removes any possible leftovers utils.removeMockRepoDir(); @@ -25,7 +24,7 @@ describe('test workflow finishReleaseCycle', () => { beforeEach(async () => { // create a local repository and copy required files - mockGithub = new MockGithub({ + mockGithub = new kieMockGithub.MockGithub({ repo: { testFinishReleaseCycleWorkflowRepo: { files: FILES_TO_COPY_INTO_TEST_REPO, @@ -51,7 +50,7 @@ describe('test workflow finishReleaseCycle', () => { describe('actor is a team member', () => { describe('no deploy blockers', () => { it('production updated, new version created', async () => { - const repoPath = mockGithub.repo.getPath('testFinishReleaseCycleWorkflowRepo') ?? ''; + const repoPath = mockGithub.repo.getPath('testFinishReleaseCycleWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'finishReleaseCycle.yml'); let act = new ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( @@ -72,7 +71,7 @@ describe('test workflow finishReleaseCycle', () => { updateProduction: mocks.FINISHRELEASECYCLE__UPDATEPRODUCTION__STEP_MOCKS, updateStaging: mocks.FINISHRELEASECYCLE__UPDATESTAGING__STEP_MOCKS, }; - const testMockJobs: MockJobs = { + const testMockJobs = { createNewPatchVersion: { steps: mocks.FINISHRELEASECYCLE__CREATENEWPATCHVERSION__STEP_MOCKS, outputs: { @@ -97,7 +96,7 @@ describe('test workflow finishReleaseCycle', () => { }); describe('deploy blockers', () => { it('production not updated, new version not created, issue reopened', async () => { - const repoPath = mockGithub.repo.getPath('testFinishReleaseCycleWorkflowRepo') ?? ''; + const repoPath = mockGithub.repo.getPath('testFinishReleaseCycleWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'finishReleaseCycle.yml'); let act = new ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( @@ -144,7 +143,7 @@ describe('test workflow finishReleaseCycle', () => { }); describe('actor is not a team member', () => { it('production not updated, new version not created, issue reopened', async () => { - const repoPath = mockGithub.repo.getPath('testFinishReleaseCycleWorkflowRepo') ?? ''; + const repoPath = mockGithub.repo.getPath('testFinishReleaseCycleWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'finishReleaseCycle.yml'); let act = new ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( @@ -191,7 +190,7 @@ describe('test workflow finishReleaseCycle', () => { }); describe('issue does not have StagingDeployCash', () => { it('validate job not run', async () => { - const repoPath = mockGithub.repo.getPath('testFinishReleaseCycleWorkflowRepo') ?? ''; + const repoPath = mockGithub.repo.getPath('testFinishReleaseCycleWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'finishReleaseCycle.yml'); let act = new ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( diff --git a/workflow_tests/lint.test.ts b/workflow_tests/lint.test.js similarity index 91% rename from workflow_tests/lint.test.ts rename to workflow_tests/lint.test.js index f6ede86c5fd3..b13b4c1c3564 100644 --- a/workflow_tests/lint.test.ts +++ b/workflow_tests/lint.test.js @@ -1,14 +1,12 @@ -import type {MockStep} from '@kie/act-js/build/src/step-mocker/step-mocker.types'; -import {MockGithub} from '@kie/mock-github'; -import path from 'path'; -import assertions from './assertions/lintAssertions'; -import mocks from './mocks/lintMocks'; -import ExtendedAct from './utils/ExtendedAct'; -import * as utils from './utils/utils'; +const path = require('path'); +const kieMockGithub = require('@kie/mock-github'); +const utils = require('./utils/utils'); +const assertions = require('./assertions/lintAssertions'); +const mocks = require('./mocks/lintMocks'); +const ExtendedAct = require('./utils/ExtendedAct').default; jest.setTimeout(90 * 1000); -let mockGithub: MockGithub; - +let mockGithub; const FILES_TO_COPY_INTO_TEST_REPO = [ ...utils.deepCopy(utils.FILES_TO_COPY_INTO_TEST_REPO), { @@ -21,7 +19,7 @@ describe('test workflow lint', () => { const githubToken = 'dummy_github_token'; const actor = 'Dummy Actor'; - beforeAll(() => { + beforeAll(async () => { // in case of the tests being interrupted without cleanup the mock repo directory may be left behind // which breaks the next test run, this removes any possible leftovers utils.removeMockRepoDir(); @@ -29,7 +27,7 @@ describe('test workflow lint', () => { beforeEach(async () => { // create a local repository and copy required files - mockGithub = new MockGithub({ + mockGithub = new kieMockGithub.MockGithub({ repo: { testLintWorkflowRepo: { files: FILES_TO_COPY_INTO_TEST_REPO, @@ -49,14 +47,13 @@ describe('test workflow lint', () => { const event = 'workflow_call'; const eventOptions = {}; it('runs the lint', async () => { - const repoPath = mockGithub.repo.getPath('testLintWorkflowRepo') ?? ''; + const repoPath = mockGithub.repo.getPath('testLintWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'lint.yml'); let act = new ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, eventOptions, {}, githubToken); - const testMockSteps: MockStep = { + const testMockSteps = { lint: mocks.LINT__LINT__STEP_MOCKS, }; - const result = await act.runEvent(event, { workflowFile: path.join(repoPath, '.github', 'workflows', 'lint.yml'), mockSteps: testMockSteps, @@ -69,14 +66,13 @@ describe('test workflow lint', () => { describe('actor is OSBotify', () => { const testActor = 'OSBotify'; it('runs the lint', async () => { - const repoPath = mockGithub.repo.getPath('testLintWorkflowRepo') ?? ''; + const repoPath = mockGithub.repo.getPath('testLintWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'lint.yml'); let act = new ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, eventOptions, {}, githubToken); const testMockSteps = { lint: mocks.LINT__LINT__STEP_MOCKS, }; - const result = await act.runEvent(event, { workflowFile: path.join(repoPath, '.github', 'workflows', 'lint.yml'), mockSteps: testMockSteps, @@ -95,14 +91,13 @@ describe('test workflow lint', () => { action: 'opened', }; it('runs the lint', async () => { - const repoPath = mockGithub.repo.getPath('testLintWorkflowRepo') ?? ''; + const repoPath = mockGithub.repo.getPath('testLintWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'lint.yml'); let act = new ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, eventOptions, {}, githubToken); const testMockSteps = { lint: mocks.LINT__LINT__STEP_MOCKS, }; - const result = await act.runEvent(event, { workflowFile: path.join(repoPath, '.github', 'workflows', 'lint.yml'), mockSteps: testMockSteps, @@ -115,14 +110,13 @@ describe('test workflow lint', () => { describe('actor is OSBotify', () => { const testActor = 'OSBotify'; it('does not run the lint', async () => { - const repoPath = mockGithub.repo.getPath('testLintWorkflowRepo') ?? ''; + const repoPath = mockGithub.repo.getPath('testLintWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'lint.yml'); let act = new ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, eventOptions, {}, githubToken); const testMockSteps = { lint: mocks.LINT__LINT__STEP_MOCKS, }; - const result = await act.runEvent(event, { workflowFile: path.join(repoPath, '.github', 'workflows', 'lint.yml'), mockSteps: testMockSteps, @@ -139,14 +133,13 @@ describe('test workflow lint', () => { action: 'synchronize', }; it('runs the lint', async () => { - const repoPath = mockGithub.repo.getPath('testLintWorkflowRepo') ?? ''; + const repoPath = mockGithub.repo.getPath('testLintWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'lint.yml'); let act = new ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, eventOptions, {}, githubToken); const testMockSteps = { lint: mocks.LINT__LINT__STEP_MOCKS, }; - const result = await act.runEvent(event, { workflowFile: path.join(repoPath, '.github', 'workflows', 'lint.yml'), mockSteps: testMockSteps, diff --git a/workflow_tests/utils/JobMocker.ts b/workflow_tests/utils/JobMocker.ts index 171d625b2fe1..b6dc99771dd2 100644 --- a/workflow_tests/utils/JobMocker.ts +++ b/workflow_tests/utils/JobMocker.ts @@ -1,4 +1,3 @@ -import type {StepIdentifier} from '@kie/act-js'; import type {PathOrFileDescriptor} from 'fs'; import fs from 'fs'; import path from 'path'; @@ -12,12 +11,12 @@ type YamlWorkflow = { }; type MockJob = { - steps: StepIdentifier[]; + steps: MockJobStep[]; uses?: string; secrets?: string[]; with?: string; - outputs?: Record; - runsOn: string; + outputs?: string[]; + runsOn?: string; }; type MockJobs = Record; @@ -60,8 +59,8 @@ class JobMocker { jobWith = job.with; delete job.with; } - job.steps = mockJob.steps.map((step): StepIdentifier => { - const mockStep: StepIdentifier = { + job.steps = mockJob.steps.map((step) => { + const mockStep: MockJobStep = { name: step.name, run: step.mockWith, }; diff --git a/workflow_tests/utils/preGenerateTest.ts b/workflow_tests/utils/preGenerateTest.ts index c5e54d9a11c0..7698e618432d 100644 --- a/workflow_tests/utils/preGenerateTest.ts +++ b/workflow_tests/utils/preGenerateTest.ts @@ -1,11 +1,10 @@ /* 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, YamlWorkflow} from './JobMocker'; +import type {MockJobStep, YamlMockJob, YamlWorkflow} from './JobMocker'; const workflowsDirectory = path.resolve(__dirname, '..', '..', '.github', 'workflows'); const workflowTestsDirectory = path.resolve(__dirname, '..'); @@ -98,7 +97,7 @@ describe('test workflow ${workflowName}', () => { }); `; -const mockStepTemplate = (stepMockName: string, step: StepIdentifier, jobId: string | undefined) => ` +const mockStepTemplate = (stepMockName: string, step: MockJobStep, jobId: string | undefined) => ` const ${stepMockName} = utils.createMockStep( '${step.name ?? ''}', '${step.name ?? ''}', diff --git a/workflow_tests/utils/utils.ts b/workflow_tests/utils/utils.ts index 2b4036c8b826..df4cc0468963 100644 --- a/workflow_tests/utils/utils.ts +++ b/workflow_tests/utils/utils.ts @@ -1,10 +1,13 @@ -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'; import type ExtendedAct from './ExtendedAct'; +type EventOptions = { + action?: string; +}; + type StepAssertionInputEntry = {key: string; value: string}; type StepAssertion = { @@ -16,7 +19,7 @@ type StepAssertion = { function setUpActParams( act: ExtendedAct, event: string | null = null, - eventOptions: EventJSON | null = null, + eventOptions: EventOptions | null = null, secrets: Record | null = null, githubToken: string | null = null, envVars: Record | null = null,