-
Notifications
You must be signed in to change notification settings - Fork 3k
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] Migrate workflow_tests, adjust utils migration #38363
Merged
roryabraham
merged 17 commits into
Expensify:main
from
software-mansion-labs:ts-migration/32051-23055-tests
Mar 23, 2024
Merged
Changes from 13 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
b5c0c4f
migrate lint.test, update utils wip
BrtqKr 24045f7
update utils
BrtqKr 4a12bce
migrate lint.test
BrtqKr b6990cc
Merge remote-tracking branch 'origin/ts-migration/utils' into ts-migr…
BrtqKr cd33641
adjust utils, finishReleaseCycle wip
BrtqKr 00ca25a
add module augmentation, correct types
BrtqKr 24281bd
cleanup
BrtqKr efebcca
migrate deployBlocker test
BrtqKr e358e84
cleanup
BrtqKr 711e626
migrate deploy test
BrtqKr debaf2f
migrate createNewVersion test
BrtqKr f079ce3
Merge remote-tracking branch 'origin/ts-migration/utils' into ts-migr…
BrtqKr fa3a11f
Merge remote-tracking branch 'origin/main' into ts-migration/32051-23…
BrtqKr f3ef5c0
review fixes
BrtqKr ae1e359
review fixes
BrtqKr 08ca248
Merge remote-tracking branch 'origin/main' into ts-migration/32051-23…
BrtqKr 448af1f
cleanup
BrtqKr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'>; | ||
} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/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 mocks from './mocks/finishReleaseCycleMocks'; | ||||||
import ExtendedAct from './utils/ExtendedAct'; | ||||||
import type {MockJob} 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 +17,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 +51,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 +72,7 @@ describe('test workflow finishReleaseCycle', () => { | |||||
updateProduction: mocks.FINISHRELEASECYCLE__UPDATEPRODUCTION__STEP_MOCKS, | ||||||
updateStaging: mocks.FINISHRELEASECYCLE__UPDATESTAGING__STEP_MOCKS, | ||||||
}; | ||||||
const testMockJobs = { | ||||||
const testMockJobs: Record<string, MockJob> = { | ||||||
createNewPatchVersion: { | ||||||
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
|
||||||
steps: mocks.FINISHRELEASECYCLE__CREATENEWPATCHVERSION__STEP_MOCKS, | ||||||
outputs: { | ||||||
|
@@ -96,7 +97,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 +144,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 +191,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( | ||||||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Why is this change necessary?
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.
some of the steps are passing additional data and since
StepIdentifier
is defined under the hood asexport declare type StepIdentifier = StepIdentifierUsingName | StepIdentifierUsingId | StepIdentifierUsingUses | StepIdentifierUsingRun | StepIdentifierUsingIndex | StepIdentifierUsingBefore | StepIdentifierUsingAfter;
those steps had more restrictive subtypes of
StepIdentifier
assigned to them, so to avoid changing the content I made the type a tiny bit more general on the module level