From 5d56fb096ca6cf1d7c346b5581fcd5939c05ad18 Mon Sep 17 00:00:00 2001 From: Jakub Szymczak Date: Mon, 18 Mar 2024 17:36:07 +0100 Subject: [PATCH 01/11] migrate jest.config --- workflow_tests/jest.config.js | 9 --------- workflow_tests/jest.config.ts | 13 +++++++++++++ 2 files changed, 13 insertions(+), 9 deletions(-) delete mode 100644 workflow_tests/jest.config.js create mode 100644 workflow_tests/jest.config.ts diff --git a/workflow_tests/jest.config.js b/workflow_tests/jest.config.js deleted file mode 100644 index cecdf8589d7f..000000000000 --- a/workflow_tests/jest.config.js +++ /dev/null @@ -1,9 +0,0 @@ -module.exports = { - verbose: true, - transform: { - '^.+\\.jsx?$': 'babel-jest', - '^.+\\.tsx?$': 'ts-jest', - }, - clearMocks: true, - resetMocks: true, -}; diff --git a/workflow_tests/jest.config.ts b/workflow_tests/jest.config.ts new file mode 100644 index 000000000000..da9dd2e15794 --- /dev/null +++ b/workflow_tests/jest.config.ts @@ -0,0 +1,13 @@ +/* eslint-disable @typescript-eslint/naming-convention */ +import type {Config} from 'jest'; + +const config: Config = { + verbose: true, + transform: { + '^.+\\.jsx?$': 'babel-jest', + }, + clearMocks: true, + resetMocks: true, +}; + +export default config; From 94702fbd9564b31afd94e78d37e54d374edd9cf2 Mon Sep 17 00:00:00 2001 From: Jakub Szymczak Date: Mon, 18 Mar 2024 17:36:27 +0100 Subject: [PATCH 02/11] migrate testBuild --- .../{testBuild.test.js => testBuild.test.ts} | 58 ++++++++++--------- 1 file changed, 31 insertions(+), 27 deletions(-) rename workflow_tests/{testBuild.test.js => testBuild.test.ts} (97%) diff --git a/workflow_tests/testBuild.test.js b/workflow_tests/testBuild.test.ts similarity index 97% rename from workflow_tests/testBuild.test.js rename to workflow_tests/testBuild.test.ts index 371759607ed5..2c676a63adfe 100644 --- a/workflow_tests/testBuild.test.js +++ b/workflow_tests/testBuild.test.ts @@ -1,12 +1,16 @@ -const path = require('path'); -const kieMockGithub = require('@kie/mock-github'); -const utils = require('./utils/utils'); -const assertions = require('./assertions/testBuildAssertions'); -const mocks = require('./mocks/testBuildMocks'); -const eAct = require('./utils/ExtendedAct'); +/* eslint-disable @typescript-eslint/naming-convention */ + +/* eslint-disable @typescript-eslint/require-await */ +import type {MockGithub} from '@kie/mock-github'; +import kieMockGithub from '@kie/mock-github'; +import path from 'path'; +import assertions from './assertions/testBuildAssertions'; +import mocks from './mocks/testBuildMocks'; +import * as eAct from './utils/ExtendedAct'; +import * as utils from './utils/utils'; jest.setTimeout(90 * 1000); -let mockGithub; +let mockGithub: MockGithub; const FILES_TO_COPY_INTO_TEST_REPO = [ ...utils.deepCopy(utils.FILES_TO_COPY_INTO_TEST_REPO), { @@ -60,7 +64,7 @@ describe('test workflow testBuild', () => { PULL_REQUEST_NUMBER: '1234', }; it('executes workflow', async () => { - const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') || ''; + const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') ?? ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, {}, secrets, githubToken, {}, inputs); @@ -91,7 +95,7 @@ describe('test workflow testBuild', () => { }); describe('actor is not a team member', () => { it('stops the workflow after validation', async () => { - const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') || ''; + const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') ?? ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, {}, secrets, githubToken, {}, inputs); @@ -123,7 +127,7 @@ describe('test workflow testBuild', () => { }); describe('PR does not have READY_TO_BUILD label', () => { it('stops the workflow after validation', async () => { - const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') || ''; + const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') ?? ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, {}, secrets, githubToken, {}, inputs); @@ -155,7 +159,7 @@ describe('test workflow testBuild', () => { }); describe('actor is not a team member and PR does not have READY_TO_BUILD label', () => { it('stops the workflow after validation', async () => { - const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') || ''; + const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') ?? ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, {}, secrets, githubToken, {}, inputs); @@ -187,7 +191,7 @@ describe('test workflow testBuild', () => { }); describe('android fails', () => { it('executes workflow, failure reflected', async () => { - const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') || ''; + const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') ?? ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, {}, secrets, githubToken, {}, inputs); @@ -220,7 +224,7 @@ describe('test workflow testBuild', () => { }); describe('iOS fails', () => { it('executes workflow, failure reflected', async () => { - const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') || ''; + const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') ?? ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, {}, secrets, githubToken, {}, inputs); @@ -253,7 +257,7 @@ describe('test workflow testBuild', () => { }); describe('desktop fails', () => { it('executes workflow, failure reflected', async () => { - const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') || ''; + const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') ?? ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, {}, secrets, githubToken, {}, inputs); @@ -295,7 +299,7 @@ describe('test workflow testBuild', () => { }); describe('web fails', () => { it('executes workflow, failure reflected', async () => { - const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') || ''; + const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') ?? ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, {}, secrets, githubToken, {}, inputs); @@ -348,7 +352,7 @@ describe('test workflow testBuild', () => { }, }; it('executes workflow, without getBranchRef', async () => { - const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') || ''; + const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') ?? ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, eventOptions, secrets, githubToken, {}); @@ -379,7 +383,7 @@ describe('test workflow testBuild', () => { }); describe('actor is not a team member', () => { it('stops the workflow after validation', async () => { - const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') || ''; + const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') ?? ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, eventOptions, secrets, githubToken, {}); @@ -411,7 +415,7 @@ describe('test workflow testBuild', () => { }); describe('PR does not have READY_TO_BUILD label', () => { it('stops the workflow after validation', async () => { - const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') || ''; + const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') ?? ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, eventOptions, secrets, githubToken, {}); @@ -443,7 +447,7 @@ describe('test workflow testBuild', () => { }); describe('actor is not a team member and PR does not have READY_TO_BUILD label', () => { it('stops the workflow after validation', async () => { - const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') || ''; + const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') ?? ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, eventOptions, secrets, githubToken, {}); @@ -486,7 +490,7 @@ describe('test workflow testBuild', () => { }, }; it('executes workflow, without getBranchRef', async () => { - const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') || ''; + const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') ?? ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, eventOptions, secrets, githubToken, {}); @@ -517,7 +521,7 @@ describe('test workflow testBuild', () => { }); describe('actor is not a team member', () => { it('stops the workflow after validation', async () => { - const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') || ''; + const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') ?? ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, eventOptions, secrets, githubToken, {}); @@ -549,7 +553,7 @@ describe('test workflow testBuild', () => { }); describe('PR does not have READY_TO_BUILD label', () => { it('stops the workflow after validation', async () => { - const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') || ''; + const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') ?? ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, eventOptions, secrets, githubToken, {}); @@ -581,7 +585,7 @@ describe('test workflow testBuild', () => { }); describe('actor is not a team member and PR does not have READY_TO_BUILD label', () => { it('stops the workflow after validation', async () => { - const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') || ''; + const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') ?? ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, eventOptions, secrets, githubToken, {}); @@ -624,7 +628,7 @@ describe('test workflow testBuild', () => { }, }; it('executes workflow, withuout getBranchRef', async () => { - const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') || ''; + const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') ?? ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, eventOptions, secrets, githubToken, {}); @@ -655,7 +659,7 @@ describe('test workflow testBuild', () => { }); describe('actor is not a team member', () => { it('stops the workflow after validation', async () => { - const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') || ''; + const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') ?? ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, eventOptions, secrets, githubToken, {}); @@ -687,7 +691,7 @@ describe('test workflow testBuild', () => { }); describe('PR does not have READY_TO_BUILD label', () => { it('stops the workflow after validation', async () => { - const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') || ''; + const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') ?? ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, eventOptions, secrets, githubToken, {}); @@ -719,7 +723,7 @@ describe('test workflow testBuild', () => { }); describe('actor is not a team member and PR does not have READY_TO_BUILD label', () => { it('stops the workflow after validation', async () => { - const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') || ''; + const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') ?? ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, eventOptions, secrets, githubToken, {}); From d6aefab946dd40cd7576b7d23be9c939bf477792 Mon Sep 17 00:00:00 2001 From: Jakub Szymczak Date: Mon, 18 Mar 2024 17:36:45 +0100 Subject: [PATCH 03/11] migrate validateGithubActions --- ....test.js => validateGithubActions.test.ts} | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) rename workflow_tests/{validateGithubActions.test.js => validateGithubActions.test.ts} (87%) diff --git a/workflow_tests/validateGithubActions.test.js b/workflow_tests/validateGithubActions.test.ts similarity index 87% rename from workflow_tests/validateGithubActions.test.js rename to workflow_tests/validateGithubActions.test.ts index dfa5e9362ce7..850f21a54163 100644 --- a/workflow_tests/validateGithubActions.test.js +++ b/workflow_tests/validateGithubActions.test.ts @@ -1,12 +1,14 @@ -const path = require('path'); -const kieMockGithub = require('@kie/mock-github'); -const utils = require('./utils/utils'); -const assertions = require('./assertions/validateGithubActionsAssertions'); -const mocks = require('./mocks/validateGithubActionsMocks'); -const eAct = require('./utils/ExtendedAct'); +/* eslint-disable @typescript-eslint/require-await */ +import type {MockGithub} from '@kie/mock-github'; +import kieMockGithub from '@kie/mock-github'; +import path from 'path'; +import assertions from './assertions/validateGithubActionsAssertions'; +import mocks from './mocks/validateGithubActionsMocks'; +import * as eAct from './utils/ExtendedAct'; +import * as utils from './utils/utils'; jest.setTimeout(90 * 1000); -let mockGithub; +let mockGithub: MockGithub; const FILES_TO_COPY_INTO_TEST_REPO = [ ...utils.deepCopy(utils.FILES_TO_COPY_INTO_TEST_REPO), { @@ -47,7 +49,7 @@ describe('test workflow validateGithubActions', () => { action: 'opened', }; it('executes verification', async () => { - const repoPath = mockGithub.repo.getPath('testValidateGithubActionsWorkflowRepo') || ''; + const repoPath = mockGithub.repo.getPath('testValidateGithubActionsWorkflowRepo') ?? ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'validateGithubActions.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, eventOptions, {}, githubToken); @@ -70,7 +72,7 @@ describe('test workflow validateGithubActions', () => { action: 'synchronize', }; it('executes verification', async () => { - const repoPath = mockGithub.repo.getPath('testValidateGithubActionsWorkflowRepo') || ''; + const repoPath = mockGithub.repo.getPath('testValidateGithubActionsWorkflowRepo') ?? ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'validateGithubActions.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, eventOptions, {}, githubToken); From 9c18645db6ba2b9602d459bdf21cd44880cbabde Mon Sep 17 00:00:00 2001 From: Jakub Szymczak Date: Mon, 18 Mar 2024 17:37:05 +0100 Subject: [PATCH 04/11] migrate verifyPodfile --- ...yPodfile.test.js => verifyPodfile.test.ts} | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) rename workflow_tests/{verifyPodfile.test.js => verifyPodfile.test.ts} (91%) diff --git a/workflow_tests/verifyPodfile.test.js b/workflow_tests/verifyPodfile.test.ts similarity index 91% rename from workflow_tests/verifyPodfile.test.js rename to workflow_tests/verifyPodfile.test.ts index de062af2a2c2..b5ccfc46c336 100644 --- a/workflow_tests/verifyPodfile.test.js +++ b/workflow_tests/verifyPodfile.test.ts @@ -1,12 +1,15 @@ -const path = require('path'); -const kieMockGithub = require('@kie/mock-github'); -const utils = require('./utils/utils'); -const assertions = require('./assertions/verifyPodfileAssertions'); -const mocks = require('./mocks/verifyPodfileMocks'); -const eAct = require('./utils/ExtendedAct'); +/* eslint-disable @typescript-eslint/require-await */ +import kieMockGithub from '@kie/mock-github'; +import type {MockGithub} from '@kie/mock-github'; +import path from 'path'; +import assertions from './assertions/verifyPodfileAssertions'; +import mocks from './mocks/verifyPodfileMocks'; +import * as eAct from './utils/ExtendedAct'; +import * as utils from './utils/utils'; jest.setTimeout(90 * 1000); -let mockGithub; +let mockGithub: MockGithub; + const FILES_TO_COPY_INTO_TEST_REPO = [ ...utils.deepCopy(utils.FILES_TO_COPY_INTO_TEST_REPO), { @@ -48,7 +51,7 @@ describe('test workflow verifyPodfile', () => { action: 'opened', }; it('executes workflow', async () => { - const repoPath = mockGithub.repo.getPath('testVerifyPodfileWorkflowRepo') || ''; + const repoPath = mockGithub.repo.getPath('testVerifyPodfileWorkflowRepo') ?? ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'verifyPodfile.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, eventOptions, {}, githubToken); @@ -67,7 +70,7 @@ describe('test workflow verifyPodfile', () => { }); describe('actor is OSBotify', () => { it('does not execute workflow', async () => { - const repoPath = mockGithub.repo.getPath('testVerifyPodfileWorkflowRepo') || ''; + const repoPath = mockGithub.repo.getPath('testVerifyPodfileWorkflowRepo') ?? ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'verifyPodfile.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, eventOptions, {}, githubToken); @@ -92,7 +95,7 @@ describe('test workflow verifyPodfile', () => { action: 'synchronize', }; it('executes workflow', async () => { - const repoPath = mockGithub.repo.getPath('testVerifyPodfileWorkflowRepo') || ''; + const repoPath = mockGithub.repo.getPath('testVerifyPodfileWorkflowRepo') ?? ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'verifyPodfile.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, eventOptions, {}, githubToken); @@ -111,7 +114,7 @@ describe('test workflow verifyPodfile', () => { }); describe('actor is OSBotify', () => { it('does not execute workflow', async () => { - const repoPath = mockGithub.repo.getPath('testVerifyPodfileWorkflowRepo') || ''; + const repoPath = mockGithub.repo.getPath('testVerifyPodfileWorkflowRepo') ?? ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'verifyPodfile.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, eventOptions, {}, githubToken); From fe4547d7ea539a7460539a9fc869375281ebcb08 Mon Sep 17 00:00:00 2001 From: Jakub Szymczak Date: Mon, 18 Mar 2024 17:37:31 +0100 Subject: [PATCH 05/11] migrate verifySignedCommits --- workflow_tests/scripts/runWorkflowTests.sh | 2 +- ...ts.test.js => verifySignedCommits.test.ts} | 21 +++++++++++-------- 2 files changed, 13 insertions(+), 10 deletions(-) rename workflow_tests/{verifySignedCommits.test.js => verifySignedCommits.test.ts} (87%) diff --git a/workflow_tests/scripts/runWorkflowTests.sh b/workflow_tests/scripts/runWorkflowTests.sh index 71ddcdceffb5..c8ee88e33e99 100755 --- a/workflow_tests/scripts/runWorkflowTests.sh +++ b/workflow_tests/scripts/runWorkflowTests.sh @@ -60,4 +60,4 @@ info 'ACT_BINARY environment variable set to an Act executable' success 'Environment setup properly - running tests' # Run tests -npm test -- --config=workflow_tests/jest.config.js --runInBand "$@" +npm test -- --config=workflow_tests/jest.config.ts --runInBand "$@" diff --git a/workflow_tests/verifySignedCommits.test.js b/workflow_tests/verifySignedCommits.test.ts similarity index 87% rename from workflow_tests/verifySignedCommits.test.js rename to workflow_tests/verifySignedCommits.test.ts index 911208e91f4a..9319829118e6 100644 --- a/workflow_tests/verifySignedCommits.test.js +++ b/workflow_tests/verifySignedCommits.test.ts @@ -1,12 +1,15 @@ -const path = require('path'); -const kieMockGithub = require('@kie/mock-github'); -const utils = require('./utils/utils'); -const assertions = require('./assertions/verifySignedCommitsAssertions'); -const mocks = require('./mocks/verifySignedCommitsMocks'); -const eAct = require('./utils/ExtendedAct'); +/* eslint-disable @typescript-eslint/require-await */ +import type {MockGithub} from '@kie/mock-github'; +import kieMockGithub from '@kie/mock-github'; +import path from 'path'; +import assertions from './assertions/verifySignedCommitsAssertions'; +import mocks from './mocks/verifySignedCommitsMocks'; +import * as eAct from './utils/ExtendedAct'; +import * as utils from './utils/utils'; jest.setTimeout(90 * 1000); -let mockGithub; +let mockGithub: MockGithub; + const FILES_TO_COPY_INTO_TEST_REPO = [ ...utils.deepCopy(utils.FILES_TO_COPY_INTO_TEST_REPO), { @@ -47,7 +50,7 @@ describe('test workflow verifySignedCommits', () => { action: 'opened', }; it('test stub', async () => { - const repoPath = mockGithub.repo.getPath('testVerifySignedCommitsWorkflowRepo') || ''; + const repoPath = mockGithub.repo.getPath('testVerifySignedCommitsWorkflowRepo') ?? ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'verifySignedCommits.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, eventOptions, {}, githubToken); @@ -70,7 +73,7 @@ describe('test workflow verifySignedCommits', () => { action: 'synchronize', }; it('test stub', async () => { - const repoPath = mockGithub.repo.getPath('testVerifySignedCommitsWorkflowRepo') || ''; + const repoPath = mockGithub.repo.getPath('testVerifySignedCommitsWorkflowRepo') ?? ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'verifySignedCommits.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, eventOptions, {}, githubToken); From c6f9af1d8e456f73e80cd1a2d109f8710820f361 Mon Sep 17 00:00:00 2001 From: Jakub Szymczak Date: Tue, 19 Mar 2024 17:05:47 +0100 Subject: [PATCH 06/11] fix babel not formatting test files --- workflow_tests/jest.config.ts | 2 +- workflow_tests/testBuild.test.ts | 5 ++--- workflow_tests/validateGithubActions.test.ts | 11 +++++------ workflow_tests/verifyPodfile.test.ts | 5 ++--- workflow_tests/verifySignedCommits.test.ts | 5 ++--- 5 files changed, 12 insertions(+), 16 deletions(-) diff --git a/workflow_tests/jest.config.ts b/workflow_tests/jest.config.ts index da9dd2e15794..8156e449039f 100644 --- a/workflow_tests/jest.config.ts +++ b/workflow_tests/jest.config.ts @@ -4,7 +4,7 @@ import type {Config} from 'jest'; const config: Config = { verbose: true, transform: { - '^.+\\.jsx?$': 'babel-jest', + '^.+\\.(js|jsx|ts|tsx)$': 'ts-jest', }, clearMocks: true, resetMocks: true, diff --git a/workflow_tests/testBuild.test.ts b/workflow_tests/testBuild.test.ts index 2c676a63adfe..5f09b851a5b5 100644 --- a/workflow_tests/testBuild.test.ts +++ b/workflow_tests/testBuild.test.ts @@ -1,8 +1,7 @@ /* eslint-disable @typescript-eslint/naming-convention */ /* eslint-disable @typescript-eslint/require-await */ -import type {MockGithub} from '@kie/mock-github'; -import kieMockGithub from '@kie/mock-github'; +import {MockGithub} from '@kie/mock-github'; import path from 'path'; import assertions from './assertions/testBuildAssertions'; import mocks from './mocks/testBuildMocks'; @@ -44,7 +43,7 @@ describe('test workflow testBuild', () => { beforeEach(async () => { // create a local repository and copy required files - mockGithub = new kieMockGithub.MockGithub({ + mockGithub = new MockGithub({ repo: { testTestBuildWorkflowRepo: { files: FILES_TO_COPY_INTO_TEST_REPO, diff --git a/workflow_tests/validateGithubActions.test.ts b/workflow_tests/validateGithubActions.test.ts index 850f21a54163..1fcfd95834b6 100644 --- a/workflow_tests/validateGithubActions.test.ts +++ b/workflow_tests/validateGithubActions.test.ts @@ -1,10 +1,9 @@ /* eslint-disable @typescript-eslint/require-await */ -import type {MockGithub} from '@kie/mock-github'; -import kieMockGithub from '@kie/mock-github'; +import {MockGithub} from '@kie/mock-github'; import path from 'path'; import assertions from './assertions/validateGithubActionsAssertions'; import mocks from './mocks/validateGithubActionsMocks'; -import * as eAct from './utils/ExtendedAct'; +import {ExtendedAct} from './utils/ExtendedAct'; import * as utils from './utils/utils'; jest.setTimeout(90 * 1000); @@ -29,7 +28,7 @@ describe('test workflow validateGithubActions', () => { beforeEach(async () => { // create a local repository and copy required files - mockGithub = new kieMockGithub.MockGithub({ + mockGithub = new MockGithub({ repo: { testValidateGithubActionsWorkflowRepo: { files: FILES_TO_COPY_INTO_TEST_REPO, @@ -51,7 +50,7 @@ describe('test workflow validateGithubActions', () => { it('executes verification', async () => { const repoPath = mockGithub.repo.getPath('testValidateGithubActionsWorkflowRepo') ?? ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'validateGithubActions.yml'); - let act = new eAct.ExtendedAct(repoPath, workflowPath); + let act = new ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, eventOptions, {}, githubToken); const testMockSteps = { verify: mocks.VALIDATEGITHUBACTIONS__VERIFY__STEP_MOCKS, @@ -74,7 +73,7 @@ describe('test workflow validateGithubActions', () => { it('executes verification', async () => { const repoPath = mockGithub.repo.getPath('testValidateGithubActionsWorkflowRepo') ?? ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'validateGithubActions.yml'); - let act = new eAct.ExtendedAct(repoPath, workflowPath); + let act = new ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, eventOptions, {}, githubToken); const testMockSteps = { verify: mocks.VALIDATEGITHUBACTIONS__VERIFY__STEP_MOCKS, diff --git a/workflow_tests/verifyPodfile.test.ts b/workflow_tests/verifyPodfile.test.ts index b5ccfc46c336..2748eae25542 100644 --- a/workflow_tests/verifyPodfile.test.ts +++ b/workflow_tests/verifyPodfile.test.ts @@ -1,6 +1,5 @@ /* eslint-disable @typescript-eslint/require-await */ -import kieMockGithub from '@kie/mock-github'; -import type {MockGithub} from '@kie/mock-github'; +import {MockGithub} from '@kie/mock-github'; import path from 'path'; import assertions from './assertions/verifyPodfileAssertions'; import mocks from './mocks/verifyPodfileMocks'; @@ -31,7 +30,7 @@ describe('test workflow verifyPodfile', () => { beforeEach(async () => { // create a local repository and copy required files - mockGithub = new kieMockGithub.MockGithub({ + mockGithub = new MockGithub({ repo: { testVerifyPodfileWorkflowRepo: { files: FILES_TO_COPY_INTO_TEST_REPO, diff --git a/workflow_tests/verifySignedCommits.test.ts b/workflow_tests/verifySignedCommits.test.ts index 9319829118e6..c861597368c3 100644 --- a/workflow_tests/verifySignedCommits.test.ts +++ b/workflow_tests/verifySignedCommits.test.ts @@ -1,6 +1,5 @@ /* eslint-disable @typescript-eslint/require-await */ -import type {MockGithub} from '@kie/mock-github'; -import kieMockGithub from '@kie/mock-github'; +import {MockGithub} from '@kie/mock-github'; import path from 'path'; import assertions from './assertions/verifySignedCommitsAssertions'; import mocks from './mocks/verifySignedCommitsMocks'; @@ -30,7 +29,7 @@ describe('test workflow verifySignedCommits', () => { beforeEach(async () => { // create a local repository and copy required files - mockGithub = new kieMockGithub.MockGithub({ + mockGithub = new MockGithub({ repo: { testVerifySignedCommitsWorkflowRepo: { files: FILES_TO_COPY_INTO_TEST_REPO, From e80c43d4338efc4cef0b5c5f2b24760dd8896684 Mon Sep 17 00:00:00 2001 From: Jakub Szymczak Date: Sun, 24 Mar 2024 18:45:26 +0100 Subject: [PATCH 07/11] fix typescript errors --- workflow_tests/mocks/testBuildMocks.ts | 20 +++++++++---------- .../mocks/validateGithubActionsMocks.ts | 2 +- workflow_tests/mocks/verifyPodfileMocks.ts | 6 +----- .../mocks/verifySignedCommitsMocks.ts | 2 +- workflow_tests/testBuild.test.ts | 2 +- workflow_tests/validateGithubActions.test.ts | 2 +- workflow_tests/verifyPodfile.test.ts | 2 +- workflow_tests/verifySignedCommits.test.ts | 2 +- 8 files changed, 17 insertions(+), 21 deletions(-) diff --git a/workflow_tests/mocks/testBuildMocks.ts b/workflow_tests/mocks/testBuildMocks.ts index 12109d0a875b..f502bfb248ba 100644 --- a/workflow_tests/mocks/testBuildMocks.ts +++ b/workflow_tests/mocks/testBuildMocks.ts @@ -27,19 +27,19 @@ const TESTBUILD__VALIDATEACTOR__SET_HAS_READY_TO_BUILD_LABEL_FLAG__FALSE__STEP_M const TESTBUILD__VALIDATEACTOR__TEAM_MEMBER_HAS_FLAG__STEP_MOCKS = [ TESTBUILD__VALIDATEACTOR__IS_TEAM_MEMBER__TRUE__STEP_MOCK, TESTBUILD__VALIDATEACTOR__SET_HAS_READY_TO_BUILD_LABEL_FLAG__TRUE__STEP_MOCK, -] as const; +]; const TESTBUILD__VALIDATEACTOR__TEAM_MEMBER_NO_FLAG__STEP_MOCKS = [ TESTBUILD__VALIDATEACTOR__IS_TEAM_MEMBER__TRUE__STEP_MOCK, TESTBUILD__VALIDATEACTOR__SET_HAS_READY_TO_BUILD_LABEL_FLAG__FALSE__STEP_MOCK, -] as const; +]; const TESTBUILD__VALIDATEACTOR__NO_TEAM_MEMBER_HAS_FLAG__STEP_MOCKS = [ TESTBUILD__VALIDATEACTOR__IS_TEAM_MEMBER__FALSE__STEP_MOCK, TESTBUILD__VALIDATEACTOR__SET_HAS_READY_TO_BUILD_LABEL_FLAG__TRUE__STEP_MOCK, -] as const; +]; const TESTBUILD__VALIDATEACTOR__NO_TEAM_MEMBER_NO_FLAG__STEP_MOCKS = [ TESTBUILD__VALIDATEACTOR__IS_TEAM_MEMBER__FALSE__STEP_MOCK, TESTBUILD__VALIDATEACTOR__SET_HAS_READY_TO_BUILD_LABEL_FLAG__FALSE__STEP_MOCK, -] as const; +]; // getbranchref const TESTBUILD__GETBRANCHREF__CHECKOUT__STEP_MOCK = createMockStep('Checkout', 'Checkout', 'GETBRANCHREF', [], []); @@ -51,7 +51,7 @@ const TESTBUILD__GETBRANCHREF__CHECK_IF_PULL_REQUEST_NUMBER_IS_CORRECT__STEP_MOC ['GITHUB_TOKEN'], {REF: 'test-ref'}, ); -const TESTBUILD__GETBRANCHREF__STEP_MOCKS = [TESTBUILD__GETBRANCHREF__CHECKOUT__STEP_MOCK, TESTBUILD__GETBRANCHREF__CHECK_IF_PULL_REQUEST_NUMBER_IS_CORRECT__STEP_MOCK] as const; +const TESTBUILD__GETBRANCHREF__STEP_MOCKS = [TESTBUILD__GETBRANCHREF__CHECKOUT__STEP_MOCK, TESTBUILD__GETBRANCHREF__CHECK_IF_PULL_REQUEST_NUMBER_IS_CORRECT__STEP_MOCK]; // android const TESTBUILD__ANDROID__CHECKOUT__STEP_MOCK = createMockStep('Checkout', 'Checkout', 'ANDROID', ['ref'], []); @@ -95,7 +95,7 @@ const TESTBUILD__ANDROID__STEP_MOCKS = [ TESTBUILD__ANDROID__CONFIGURE_MAPBOX_SDK__STEP_MOCK, TESTBUILD__ANDROID__RUN_FASTLANE_BETA_TEST__STEP_MOCK, TESTBUILD__ANDROID__UPLOAD_ARTIFACT__STEP_MOCK, -] as const; +]; // ios const TESTBUILD__IOS__CHECKOUT__STEP_MOCK = createMockStep('Checkout', 'Checkout', 'IOS', ['ref'], []); @@ -151,7 +151,7 @@ const TESTBUILD__IOS__STEP_MOCKS = [ TESTBUILD__IOS__CONFIGURE_AWS_CREDENTIALS__STEP_MOCK, TESTBUILD__IOS__RUN_FASTLANE__STEP_MOCK, TESTBUILD__IOS__UPLOAD_ARTIFACT__STEP_MOCK, -] as const; +]; // desktop const TESTBUILD__DESKTOP__CHECKOUT__STEP_MOCK = createMockStep('Checkout', 'Checkout', 'DESKTOP', ['ref'], []); @@ -191,7 +191,7 @@ const TESTBUILD__DESKTOP__STEP_MOCKS = [ TESTBUILD__DESKTOP__DECRYPT_DEVELOPER_ID_CERTIFICATE__STEP_MOCK, TESTBUILD__DESKTOP__CONFIGURE_AWS_CREDENTIALS__STEP_MOCK, TESTBUILD__DESKTOP__BUILD_DESKTOP_APP_FOR_TESTING__STEP_MOCK, -] as const; +]; // web const TESTBUILD__WEB__CHECKOUT__STEP_MOCK = createMockStep('Checkout', 'Checkout', 'WEB', ['ref'], []); @@ -221,7 +221,7 @@ const TESTBUILD__WEB__STEP_MOCKS = [ TESTBUILD__WEB__BUILD_WEB_FOR_TESTING__STEP_MOCK, TESTBUILD__WEB__BUILD_DOCS__STEP_MOCK, TESTBUILD__WEB__DEPLOY_TO_S3_FOR_INTERNAL_TESTING__STEP_MOCK, -] as const; +]; // postgithubcomment const TESTBUILD__POSTGITHUBCOMMENT__CHECKOUT__STEP_MOCK = createMockStep('Checkout', 'Checkout', 'POSTGITHUBCOMMENT', ['ref'], []); @@ -245,7 +245,7 @@ const TESTBUILD__POSTGITHUBCOMMENT__STEP_MOCKS = [ TESTBUILD__POSTGITHUBCOMMENT__READ_JSONS_WITH_ANDROID_PATHS__STEP_MOCK, TESTBUILD__POSTGITHUBCOMMENT__READ_JSONS_WITH_IOS_PATHS__STEP_MOCK, TESTBUILD__POSTGITHUBCOMMENT__PUBLISH_LINKS_TO_APPS_FOR_DOWNLOAD__STEP_MOCK, -] as const; +]; export { TESTBUILD__VALIDATEACTOR__TEAM_MEMBER_HAS_FLAG__STEP_MOCKS, diff --git a/workflow_tests/mocks/validateGithubActionsMocks.ts b/workflow_tests/mocks/validateGithubActionsMocks.ts index 8249945dbfc7..dc7ee14616d3 100644 --- a/workflow_tests/mocks/validateGithubActionsMocks.ts +++ b/workflow_tests/mocks/validateGithubActionsMocks.ts @@ -11,7 +11,7 @@ const VALIDATEGITHUBACTIONS__VERIFY__STEP_MOCKS = [ VALIDATEGITHUBACTIONS__VERIFY__SETUP_NODE__STEP_MOCK, VALIDATEGITHUBACTIONS__VERIFY__VERIFY_JAVASCRIPT_ACTION_BUILDS__STEP_MOCK, VALIDATEGITHUBACTIONS__VERIFY__VALIDATE_ACTIONS_AND_WORKFLOWS__STEP_MOCK, -] as const; +]; export { // eslint-disable-next-line import/prefer-default-export diff --git a/workflow_tests/mocks/verifyPodfileMocks.ts b/workflow_tests/mocks/verifyPodfileMocks.ts index b1f0669b8b00..389140d935ec 100644 --- a/workflow_tests/mocks/verifyPodfileMocks.ts +++ b/workflow_tests/mocks/verifyPodfileMocks.ts @@ -5,11 +5,7 @@ import {createMockStep} from '../utils/utils'; const VERIFYPODFILE__VERIFY__CHECKOUT__STEP_MOCK = createMockStep('Checkout', 'Checkout', 'VERIFY'); const VERIFYPODFILE__VERIFY__SETUP_NODE__STEP_MOCK = createMockStep('Setup Node', 'Setup Node', 'VERIFY', [], []); const VERIFYPODFILE__VERIFY__VERIFY_PODFILE__STEP_MOCK = createMockStep('Verify podfile', 'Verify podfile', 'VERIFY', [], []); -const VERIFYPODFILE__VERIFY__STEP_MOCKS = [ - VERIFYPODFILE__VERIFY__CHECKOUT__STEP_MOCK, - VERIFYPODFILE__VERIFY__SETUP_NODE__STEP_MOCK, - VERIFYPODFILE__VERIFY__VERIFY_PODFILE__STEP_MOCK, -] as const; +const VERIFYPODFILE__VERIFY__STEP_MOCKS = [VERIFYPODFILE__VERIFY__CHECKOUT__STEP_MOCK, VERIFYPODFILE__VERIFY__SETUP_NODE__STEP_MOCK, VERIFYPODFILE__VERIFY__VERIFY_PODFILE__STEP_MOCK]; export { // eslint-disable-next-line import/prefer-default-export diff --git a/workflow_tests/mocks/verifySignedCommitsMocks.ts b/workflow_tests/mocks/verifySignedCommitsMocks.ts index 953d09d1255f..ac9b42c8c92b 100644 --- a/workflow_tests/mocks/verifySignedCommitsMocks.ts +++ b/workflow_tests/mocks/verifySignedCommitsMocks.ts @@ -9,7 +9,7 @@ const VERIFYSIGNEDCOMMITS__VERIFYSIGNEDCOMMITS__VERIFY_SIGNED_COMMITS__STEP_MOCK ['GITHUB_TOKEN'], [], ); -const VERIFYSIGNEDCOMMITS__VERIFYSIGNEDCOMMITS__STEP_MOCKS = [VERIFYSIGNEDCOMMITS__VERIFYSIGNEDCOMMITS__VERIFY_SIGNED_COMMITS__STEP_MOCK] as const; +const VERIFYSIGNEDCOMMITS__VERIFYSIGNEDCOMMITS__STEP_MOCKS = [VERIFYSIGNEDCOMMITS__VERIFYSIGNEDCOMMITS__VERIFY_SIGNED_COMMITS__STEP_MOCK]; export { // eslint-disable-next-line import/prefer-default-export diff --git a/workflow_tests/testBuild.test.ts b/workflow_tests/testBuild.test.ts index a38d95e8c09a..434cc60d649e 100644 --- a/workflow_tests/testBuild.test.ts +++ b/workflow_tests/testBuild.test.ts @@ -4,7 +4,7 @@ import {MockGithub} from '@kie/mock-github'; import path from 'path'; import assertions from './assertions/testBuildAssertions'; -import mocks from './mocks/testBuildMocks'; +import * as mocks from './mocks/testBuildMocks'; import ExtendedAct from './utils/ExtendedAct'; import * as utils from './utils/utils'; diff --git a/workflow_tests/validateGithubActions.test.ts b/workflow_tests/validateGithubActions.test.ts index e3852341db1b..b20e3996db13 100644 --- a/workflow_tests/validateGithubActions.test.ts +++ b/workflow_tests/validateGithubActions.test.ts @@ -2,7 +2,7 @@ import {MockGithub} from '@kie/mock-github'; import path from 'path'; import assertions from './assertions/validateGithubActionsAssertions'; -import mocks from './mocks/validateGithubActionsMocks'; +import * as mocks from './mocks/validateGithubActionsMocks'; import ExtendedAct from './utils/ExtendedAct'; import * as utils from './utils/utils'; diff --git a/workflow_tests/verifyPodfile.test.ts b/workflow_tests/verifyPodfile.test.ts index d54ca21faf16..04ba6910b571 100644 --- a/workflow_tests/verifyPodfile.test.ts +++ b/workflow_tests/verifyPodfile.test.ts @@ -2,7 +2,7 @@ import {MockGithub} from '@kie/mock-github'; import path from 'path'; import assertions from './assertions/verifyPodfileAssertions'; -import mocks from './mocks/verifyPodfileMocks'; +import * as mocks from './mocks/verifyPodfileMocks'; import ExtendedAct from './utils/ExtendedAct'; import * as utils from './utils/utils'; diff --git a/workflow_tests/verifySignedCommits.test.ts b/workflow_tests/verifySignedCommits.test.ts index 99be075b1ce2..c1ff8ff6b01b 100644 --- a/workflow_tests/verifySignedCommits.test.ts +++ b/workflow_tests/verifySignedCommits.test.ts @@ -2,7 +2,7 @@ import {MockGithub} from '@kie/mock-github'; import path from 'path'; import assertions from './assertions/verifySignedCommitsAssertions'; -import mocks from './mocks/verifySignedCommitsMocks'; +import * as mocks from './mocks/verifySignedCommitsMocks'; import ExtendedAct from './utils/ExtendedAct'; import * as utils from './utils/utils'; From f0fe698599e120be12689fd37cf36dc1e9664c89 Mon Sep 17 00:00:00 2001 From: Jakub Szymczak Date: Mon, 25 Mar 2024 10:16:48 +0100 Subject: [PATCH 08/11] fix mock types --- workflow_tests/mocks/testBuildMocks.ts | 24 +++++++++++-------- .../mocks/validateGithubActionsMocks.ts | 3 ++- workflow_tests/mocks/verifyPodfileMocks.ts | 7 +++++- .../mocks/verifySignedCommitsMocks.ts | 3 ++- 4 files changed, 24 insertions(+), 13 deletions(-) diff --git a/workflow_tests/mocks/testBuildMocks.ts b/workflow_tests/mocks/testBuildMocks.ts index f502bfb248ba..fb5ab85878ac 100644 --- a/workflow_tests/mocks/testBuildMocks.ts +++ b/workflow_tests/mocks/testBuildMocks.ts @@ -1,4 +1,5 @@ /* eslint-disable @typescript-eslint/naming-convention */ +import type {StepIdentifier} from '@kie/act-js/build/src/step-mocker/step-mocker.types'; import {createMockStep} from '../utils/utils'; // validateactor @@ -27,19 +28,19 @@ const TESTBUILD__VALIDATEACTOR__SET_HAS_READY_TO_BUILD_LABEL_FLAG__FALSE__STEP_M const TESTBUILD__VALIDATEACTOR__TEAM_MEMBER_HAS_FLAG__STEP_MOCKS = [ TESTBUILD__VALIDATEACTOR__IS_TEAM_MEMBER__TRUE__STEP_MOCK, TESTBUILD__VALIDATEACTOR__SET_HAS_READY_TO_BUILD_LABEL_FLAG__TRUE__STEP_MOCK, -]; +] as const satisfies StepIdentifier[]; const TESTBUILD__VALIDATEACTOR__TEAM_MEMBER_NO_FLAG__STEP_MOCKS = [ TESTBUILD__VALIDATEACTOR__IS_TEAM_MEMBER__TRUE__STEP_MOCK, TESTBUILD__VALIDATEACTOR__SET_HAS_READY_TO_BUILD_LABEL_FLAG__FALSE__STEP_MOCK, -]; +] as const satisfies StepIdentifier[]; const TESTBUILD__VALIDATEACTOR__NO_TEAM_MEMBER_HAS_FLAG__STEP_MOCKS = [ TESTBUILD__VALIDATEACTOR__IS_TEAM_MEMBER__FALSE__STEP_MOCK, TESTBUILD__VALIDATEACTOR__SET_HAS_READY_TO_BUILD_LABEL_FLAG__TRUE__STEP_MOCK, -]; +] as const satisfies StepIdentifier[]; const TESTBUILD__VALIDATEACTOR__NO_TEAM_MEMBER_NO_FLAG__STEP_MOCKS = [ TESTBUILD__VALIDATEACTOR__IS_TEAM_MEMBER__FALSE__STEP_MOCK, TESTBUILD__VALIDATEACTOR__SET_HAS_READY_TO_BUILD_LABEL_FLAG__FALSE__STEP_MOCK, -]; +] as const satisfies StepIdentifier[]; // getbranchref const TESTBUILD__GETBRANCHREF__CHECKOUT__STEP_MOCK = createMockStep('Checkout', 'Checkout', 'GETBRANCHREF', [], []); @@ -51,7 +52,10 @@ const TESTBUILD__GETBRANCHREF__CHECK_IF_PULL_REQUEST_NUMBER_IS_CORRECT__STEP_MOC ['GITHUB_TOKEN'], {REF: 'test-ref'}, ); -const TESTBUILD__GETBRANCHREF__STEP_MOCKS = [TESTBUILD__GETBRANCHREF__CHECKOUT__STEP_MOCK, TESTBUILD__GETBRANCHREF__CHECK_IF_PULL_REQUEST_NUMBER_IS_CORRECT__STEP_MOCK]; +const TESTBUILD__GETBRANCHREF__STEP_MOCKS = [ + TESTBUILD__GETBRANCHREF__CHECKOUT__STEP_MOCK, + TESTBUILD__GETBRANCHREF__CHECK_IF_PULL_REQUEST_NUMBER_IS_CORRECT__STEP_MOCK, +] as const satisfies StepIdentifier[]; // android const TESTBUILD__ANDROID__CHECKOUT__STEP_MOCK = createMockStep('Checkout', 'Checkout', 'ANDROID', ['ref'], []); @@ -95,7 +99,7 @@ const TESTBUILD__ANDROID__STEP_MOCKS = [ TESTBUILD__ANDROID__CONFIGURE_MAPBOX_SDK__STEP_MOCK, TESTBUILD__ANDROID__RUN_FASTLANE_BETA_TEST__STEP_MOCK, TESTBUILD__ANDROID__UPLOAD_ARTIFACT__STEP_MOCK, -]; +] as const satisfies StepIdentifier[]; // ios const TESTBUILD__IOS__CHECKOUT__STEP_MOCK = createMockStep('Checkout', 'Checkout', 'IOS', ['ref'], []); @@ -151,7 +155,7 @@ const TESTBUILD__IOS__STEP_MOCKS = [ TESTBUILD__IOS__CONFIGURE_AWS_CREDENTIALS__STEP_MOCK, TESTBUILD__IOS__RUN_FASTLANE__STEP_MOCK, TESTBUILD__IOS__UPLOAD_ARTIFACT__STEP_MOCK, -]; +] as const satisfies StepIdentifier[]; // desktop const TESTBUILD__DESKTOP__CHECKOUT__STEP_MOCK = createMockStep('Checkout', 'Checkout', 'DESKTOP', ['ref'], []); @@ -191,7 +195,7 @@ const TESTBUILD__DESKTOP__STEP_MOCKS = [ TESTBUILD__DESKTOP__DECRYPT_DEVELOPER_ID_CERTIFICATE__STEP_MOCK, TESTBUILD__DESKTOP__CONFIGURE_AWS_CREDENTIALS__STEP_MOCK, TESTBUILD__DESKTOP__BUILD_DESKTOP_APP_FOR_TESTING__STEP_MOCK, -]; +] as const satisfies StepIdentifier[]; // web const TESTBUILD__WEB__CHECKOUT__STEP_MOCK = createMockStep('Checkout', 'Checkout', 'WEB', ['ref'], []); @@ -221,7 +225,7 @@ const TESTBUILD__WEB__STEP_MOCKS = [ TESTBUILD__WEB__BUILD_WEB_FOR_TESTING__STEP_MOCK, TESTBUILD__WEB__BUILD_DOCS__STEP_MOCK, TESTBUILD__WEB__DEPLOY_TO_S3_FOR_INTERNAL_TESTING__STEP_MOCK, -]; +] as const satisfies StepIdentifier[]; // postgithubcomment const TESTBUILD__POSTGITHUBCOMMENT__CHECKOUT__STEP_MOCK = createMockStep('Checkout', 'Checkout', 'POSTGITHUBCOMMENT', ['ref'], []); @@ -245,7 +249,7 @@ const TESTBUILD__POSTGITHUBCOMMENT__STEP_MOCKS = [ TESTBUILD__POSTGITHUBCOMMENT__READ_JSONS_WITH_ANDROID_PATHS__STEP_MOCK, TESTBUILD__POSTGITHUBCOMMENT__READ_JSONS_WITH_IOS_PATHS__STEP_MOCK, TESTBUILD__POSTGITHUBCOMMENT__PUBLISH_LINKS_TO_APPS_FOR_DOWNLOAD__STEP_MOCK, -]; +] as const satisfies StepIdentifier[]; export { TESTBUILD__VALIDATEACTOR__TEAM_MEMBER_HAS_FLAG__STEP_MOCKS, diff --git a/workflow_tests/mocks/validateGithubActionsMocks.ts b/workflow_tests/mocks/validateGithubActionsMocks.ts index dc7ee14616d3..50af4062724b 100644 --- a/workflow_tests/mocks/validateGithubActionsMocks.ts +++ b/workflow_tests/mocks/validateGithubActionsMocks.ts @@ -1,4 +1,5 @@ /* eslint-disable @typescript-eslint/naming-convention */ +import type {StepIdentifier} from '@kie/act-js/build/src/step-mocker/step-mocker.types'; import {createMockStep} from '../utils/utils'; // verify @@ -11,7 +12,7 @@ const VALIDATEGITHUBACTIONS__VERIFY__STEP_MOCKS = [ VALIDATEGITHUBACTIONS__VERIFY__SETUP_NODE__STEP_MOCK, VALIDATEGITHUBACTIONS__VERIFY__VERIFY_JAVASCRIPT_ACTION_BUILDS__STEP_MOCK, VALIDATEGITHUBACTIONS__VERIFY__VALIDATE_ACTIONS_AND_WORKFLOWS__STEP_MOCK, -]; +] as const satisfies StepIdentifier[]; export { // eslint-disable-next-line import/prefer-default-export diff --git a/workflow_tests/mocks/verifyPodfileMocks.ts b/workflow_tests/mocks/verifyPodfileMocks.ts index 389140d935ec..6a2528f5cd9b 100644 --- a/workflow_tests/mocks/verifyPodfileMocks.ts +++ b/workflow_tests/mocks/verifyPodfileMocks.ts @@ -1,11 +1,16 @@ /* eslint-disable @typescript-eslint/naming-convention */ +import type {StepIdentifier} from '@kie/act-js/build/src/step-mocker/step-mocker.types'; import {createMockStep} from '../utils/utils'; // verify const VERIFYPODFILE__VERIFY__CHECKOUT__STEP_MOCK = createMockStep('Checkout', 'Checkout', 'VERIFY'); const VERIFYPODFILE__VERIFY__SETUP_NODE__STEP_MOCK = createMockStep('Setup Node', 'Setup Node', 'VERIFY', [], []); const VERIFYPODFILE__VERIFY__VERIFY_PODFILE__STEP_MOCK = createMockStep('Verify podfile', 'Verify podfile', 'VERIFY', [], []); -const VERIFYPODFILE__VERIFY__STEP_MOCKS = [VERIFYPODFILE__VERIFY__CHECKOUT__STEP_MOCK, VERIFYPODFILE__VERIFY__SETUP_NODE__STEP_MOCK, VERIFYPODFILE__VERIFY__VERIFY_PODFILE__STEP_MOCK]; +const VERIFYPODFILE__VERIFY__STEP_MOCKS = [ + VERIFYPODFILE__VERIFY__CHECKOUT__STEP_MOCK, + VERIFYPODFILE__VERIFY__SETUP_NODE__STEP_MOCK, + VERIFYPODFILE__VERIFY__VERIFY_PODFILE__STEP_MOCK, +] as const satisfies StepIdentifier[]; export { // eslint-disable-next-line import/prefer-default-export diff --git a/workflow_tests/mocks/verifySignedCommitsMocks.ts b/workflow_tests/mocks/verifySignedCommitsMocks.ts index ac9b42c8c92b..da199b572b07 100644 --- a/workflow_tests/mocks/verifySignedCommitsMocks.ts +++ b/workflow_tests/mocks/verifySignedCommitsMocks.ts @@ -1,4 +1,5 @@ /* eslint-disable @typescript-eslint/naming-convention */ +import type {StepIdentifier} from '@kie/act-js/build/src/step-mocker/step-mocker.types'; import {createMockStep} from '../utils/utils'; // verifysignedcommits @@ -9,7 +10,7 @@ const VERIFYSIGNEDCOMMITS__VERIFYSIGNEDCOMMITS__VERIFY_SIGNED_COMMITS__STEP_MOCK ['GITHUB_TOKEN'], [], ); -const VERIFYSIGNEDCOMMITS__VERIFYSIGNEDCOMMITS__STEP_MOCKS = [VERIFYSIGNEDCOMMITS__VERIFYSIGNEDCOMMITS__VERIFY_SIGNED_COMMITS__STEP_MOCK]; +const VERIFYSIGNEDCOMMITS__VERIFYSIGNEDCOMMITS__STEP_MOCKS = [VERIFYSIGNEDCOMMITS__VERIFYSIGNEDCOMMITS__VERIFY_SIGNED_COMMITS__STEP_MOCK] as const satisfies StepIdentifier[]; export { // eslint-disable-next-line import/prefer-default-export From fd2b2b5b6497c7f0ebb37eeb312d321044543743 Mon Sep 17 00:00:00 2001 From: Jakub Szymczak Date: Mon, 25 Mar 2024 10:36:32 +0100 Subject: [PATCH 09/11] fix pr comments --- workflow_tests/testBuild.test.ts | 4 +--- workflow_tests/validateGithubActions.test.ts | 3 +-- workflow_tests/verifyPodfile.test.ts | 3 +-- workflow_tests/verifySignedCommits.test.ts | 3 +-- 4 files changed, 4 insertions(+), 9 deletions(-) diff --git a/workflow_tests/testBuild.test.ts b/workflow_tests/testBuild.test.ts index 434cc60d649e..b041bd34d9bf 100644 --- a/workflow_tests/testBuild.test.ts +++ b/workflow_tests/testBuild.test.ts @@ -1,6 +1,4 @@ /* eslint-disable @typescript-eslint/naming-convention */ - -/* eslint-disable @typescript-eslint/require-await */ import {MockGithub} from '@kie/mock-github'; import path from 'path'; import assertions from './assertions/testBuildAssertions'; @@ -35,7 +33,7 @@ describe('test workflow testBuild', () => { MYAPP_UPLOAD_KEY_PASSWORD: 'dummy_myapp_upload_key_password', }; - beforeAll(async () => { + beforeAll(() => { // 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(); diff --git a/workflow_tests/validateGithubActions.test.ts b/workflow_tests/validateGithubActions.test.ts index b20e3996db13..5e1c4a30c282 100644 --- a/workflow_tests/validateGithubActions.test.ts +++ b/workflow_tests/validateGithubActions.test.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/require-await */ import {MockGithub} from '@kie/mock-github'; import path from 'path'; import assertions from './assertions/validateGithubActionsAssertions'; @@ -20,7 +19,7 @@ describe('test workflow validateGithubActions', () => { const githubToken = 'dummy_github_token'; const actor = 'Dummy Actor'; - beforeAll(async () => { + beforeAll(() => { // 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(); diff --git a/workflow_tests/verifyPodfile.test.ts b/workflow_tests/verifyPodfile.test.ts index 04ba6910b571..b9a29650a275 100644 --- a/workflow_tests/verifyPodfile.test.ts +++ b/workflow_tests/verifyPodfile.test.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/require-await */ import {MockGithub} from '@kie/mock-github'; import path from 'path'; import assertions from './assertions/verifyPodfileAssertions'; @@ -22,7 +21,7 @@ describe('test workflow verifyPodfile', () => { const actor = 'Dummy Actor'; const osbotifyActor = 'OSBotify'; - beforeAll(async () => { + beforeAll(() => { // 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(); diff --git a/workflow_tests/verifySignedCommits.test.ts b/workflow_tests/verifySignedCommits.test.ts index c1ff8ff6b01b..82d56b975932 100644 --- a/workflow_tests/verifySignedCommits.test.ts +++ b/workflow_tests/verifySignedCommits.test.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/require-await */ import {MockGithub} from '@kie/mock-github'; import path from 'path'; import assertions from './assertions/verifySignedCommitsAssertions'; @@ -21,7 +20,7 @@ describe('test workflow verifySignedCommits', () => { const githubToken = 'dummy_github_token'; const actor = 'Dummy Actor'; - beforeAll(async () => { + beforeAll(() => { // 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(); From 6df0fe83abfb09e8ddfb82d63c3ad0d646dfb1d9 Mon Sep 17 00:00:00 2001 From: Jakub Szymczak Date: Wed, 27 Mar 2024 16:35:43 +0100 Subject: [PATCH 10/11] fix type errors --- workflow_tests/assertions/testBuildAssertions.ts | 2 +- workflow_tests/assertions/validateGithubActionsAssertions.ts | 2 +- workflow_tests/assertions/verifyPodfileAssertions.ts | 2 +- workflow_tests/assertions/verifySignedCommitsAssertions.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/workflow_tests/assertions/testBuildAssertions.ts b/workflow_tests/assertions/testBuildAssertions.ts index 02e64fb83889..5fb0a8fd9342 100644 --- a/workflow_tests/assertions/testBuildAssertions.ts +++ b/workflow_tests/assertions/testBuildAssertions.ts @@ -397,7 +397,7 @@ function assertPostGithubCommentJobExecuted( }); } -export { +export default { assertValidateActorJobExecuted, assertGetBranchRefJobExecuted, assertAndroidJobExecuted, diff --git a/workflow_tests/assertions/validateGithubActionsAssertions.ts b/workflow_tests/assertions/validateGithubActionsAssertions.ts index 34d694111b1e..e9fd19ab5425 100644 --- a/workflow_tests/assertions/validateGithubActionsAssertions.ts +++ b/workflow_tests/assertions/validateGithubActionsAssertions.ts @@ -19,4 +19,4 @@ function assertVerifyJobExecuted(workflowResult: Step[], didExecute = true) { } // eslint-disable-next-line import/prefer-default-export -export {assertVerifyJobExecuted}; +export default {assertVerifyJobExecuted}; diff --git a/workflow_tests/assertions/verifyPodfileAssertions.ts b/workflow_tests/assertions/verifyPodfileAssertions.ts index c2e4a1d8f30e..d5bab06f4b7b 100644 --- a/workflow_tests/assertions/verifyPodfileAssertions.ts +++ b/workflow_tests/assertions/verifyPodfileAssertions.ts @@ -18,4 +18,4 @@ function assertVerifyJobExecuted(workflowResult: Step[], didExecute = true) { } // eslint-disable-next-line import/prefer-default-export -export {assertVerifyJobExecuted}; +export default {assertVerifyJobExecuted}; diff --git a/workflow_tests/assertions/verifySignedCommitsAssertions.ts b/workflow_tests/assertions/verifySignedCommitsAssertions.ts index 99b2e28eb582..8aaabafa9d9d 100644 --- a/workflow_tests/assertions/verifySignedCommitsAssertions.ts +++ b/workflow_tests/assertions/verifySignedCommitsAssertions.ts @@ -14,4 +14,4 @@ function assertVerifySignedCommitsJobExecuted(workflowResult: Step[], didExecute } // eslint-disable-next-line import/prefer-default-export -export {assertVerifySignedCommitsJobExecuted}; +export default {assertVerifySignedCommitsJobExecuted}; From 95c70e87f99164857aad6d07d175909c702162c1 Mon Sep 17 00:00:00 2001 From: Jakub Szymczak Date: Tue, 2 Apr 2024 12:36:55 +0200 Subject: [PATCH 11/11] fix pr comments --- workflow_tests/assertions/validateGithubActionsAssertions.ts | 1 - workflow_tests/assertions/verifyPodfileAssertions.ts | 1 - 2 files changed, 2 deletions(-) diff --git a/workflow_tests/assertions/validateGithubActionsAssertions.ts b/workflow_tests/assertions/validateGithubActionsAssertions.ts index e9fd19ab5425..89eb444299ed 100644 --- a/workflow_tests/assertions/validateGithubActionsAssertions.ts +++ b/workflow_tests/assertions/validateGithubActionsAssertions.ts @@ -18,5 +18,4 @@ function assertVerifyJobExecuted(workflowResult: Step[], didExecute = true) { }); } -// eslint-disable-next-line import/prefer-default-export export default {assertVerifyJobExecuted}; diff --git a/workflow_tests/assertions/verifyPodfileAssertions.ts b/workflow_tests/assertions/verifyPodfileAssertions.ts index d5bab06f4b7b..d837507ede1b 100644 --- a/workflow_tests/assertions/verifyPodfileAssertions.ts +++ b/workflow_tests/assertions/verifyPodfileAssertions.ts @@ -17,5 +17,4 @@ function assertVerifyJobExecuted(workflowResult: Step[], didExecute = true) { }); } -// eslint-disable-next-line import/prefer-default-export export default {assertVerifyJobExecuted};