-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[No QA][TS migration] Restore migrate workflow_tests, adjust utils migration #38934
Changes from 4 commits
0681305
657afa1
0af7587
5288c20
2242025
bf03125
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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'>; | ||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,12 +1,13 @@ | ||||||
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; | ||||||
import {MockGithub} from '@kie/mock-github'; | ||||||
import path from 'path'; | ||||||
import assertions from './assertions/deployAssertions'; | ||||||
import * as mocks from './mocks/deployMocks'; | ||||||
import ExtendedAct from './utils/ExtendedAct'; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Merge with |
||||||
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), | ||||||
{ | ||||||
|
@@ -16,15 +17,15 @@ const FILES_TO_COPY_INTO_TEST_REPO = [ | |||||
]; | ||||||
|
||||||
describe('test workflow deploy', () => { | ||||||
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(); | ||||||
}); | ||||||
|
||||||
beforeEach(async () => { | ||||||
// create a local repository and copy required files | ||||||
mockGithub = new kieMockGithub.MockGithub({ | ||||||
mockGithub = new MockGithub({ | ||||||
repo: { | ||||||
testDeployWorkflowRepo: { | ||||||
files: FILES_TO_COPY_INTO_TEST_REPO, | ||||||
|
@@ -48,7 +49,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( | ||||||
|
@@ -75,7 +76,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( | ||||||
|
@@ -102,7 +103,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( | ||||||
|
@@ -130,7 +131,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 = { | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,12 +1,14 @@ | ||||||
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; | ||||||
/* eslint-disable @typescript-eslint/naming-convention */ | ||||||
import {MockGithub} from '@kie/mock-github'; | ||||||
import path from 'path'; | ||||||
import assertions from './assertions/deployBlockerAssertions'; | ||||||
import * as mocks from './mocks/deployBlockerMocks'; | ||||||
import ExtendedAct from './utils/ExtendedAct'; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Merge with |
||||||
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), | ||||||
{ | ||||||
|
@@ -23,15 +25,15 @@ describe('test workflow deployBlocker', () => { | |||||
SLACK_WEBHOOK: 'dummy_slack_webhook', | ||||||
}; | ||||||
|
||||||
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(); | ||||||
}); | ||||||
|
||||||
beforeEach(async () => { | ||||||
// create a local repository and copy required files | ||||||
mockGithub = new kieMockGithub.MockGithub({ | ||||||
mockGithub = new MockGithub({ | ||||||
repo: { | ||||||
testDeployBlockerWorkflowRepo: { | ||||||
files: FILES_TO_COPY_INTO_TEST_REPO, | ||||||
|
@@ -64,7 +66,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, {}, {}); | ||||||
|
@@ -90,7 +92,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, {}, {}); | ||||||
|
@@ -130,7 +132,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, {}, {}); | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,12 +1,14 @@ | ||||||
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; | ||||||
import {MockGithub} from '@kie/mock-github'; | ||||||
import path from 'path'; | ||||||
import assertions from './assertions/finishReleaseCycleAssertions'; | ||||||
import * as mocks from './mocks/finishReleaseCycleMocks'; | ||||||
import ExtendedAct from './utils/ExtendedAct'; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Merge with |
||||||
import type {MockJobs} from './utils/JobMocker'; | ||||||
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), | ||||||
{ | ||||||
|
@@ -16,15 +18,15 @@ const FILES_TO_COPY_INTO_TEST_REPO = [ | |||||
]; | ||||||
|
||||||
describe('test workflow finishReleaseCycle', () => { | ||||||
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(); | ||||||
}); | ||||||
|
||||||
beforeEach(async () => { | ||||||
// create a local repository and copy required files | ||||||
mockGithub = new kieMockGithub.MockGithub({ | ||||||
mockGithub = new MockGithub({ | ||||||
repo: { | ||||||
testFinishReleaseCycleWorkflowRepo: { | ||||||
files: FILES_TO_COPY_INTO_TEST_REPO, | ||||||
|
@@ -50,7 +52,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( | ||||||
|
@@ -71,7 +73,7 @@ describe('test workflow finishReleaseCycle', () => { | |||||
updateProduction: mocks.FINISHRELEASECYCLE__UPDATEPRODUCTION__STEP_MOCKS, | ||||||
updateStaging: mocks.FINISHRELEASECYCLE__UPDATESTAGING__STEP_MOCKS, | ||||||
}; | ||||||
const testMockJobs = { | ||||||
const testMockJobs: MockJobs = { | ||||||
createNewPatchVersion: { | ||||||
steps: mocks.FINISHRELEASECYCLE__CREATENEWPATCHVERSION__STEP_MOCKS, | ||||||
outputs: { | ||||||
|
@@ -96,7 +98,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( | ||||||
|
@@ -143,7 +145,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( | ||||||
|
@@ -190,7 +192,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( | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Merge with
main
first