Skip to content

Commit

Permalink
allow only skip unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
David Hasani committed Sep 19, 2024
1 parent 77f58b5 commit ebc79cf
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 31 deletions.
11 changes: 5 additions & 6 deletions packages/core/src/amazonqGumby/chat/controller/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,12 +342,11 @@ export class GumbyController {

private async handleSkipTestsSelection(message: any) {
const skipTestsSelection = message.formSelectedValues['GumbyTransformSkipTestsForm']
if (skipTestsSelection === CodeWhispererConstants.skipIntegrationTestsMessage) {
transformByQState.setCustomBuildCommand(CodeWhispererConstants.skipIntegrationTestsBuildCommand)
} else if (skipTestsSelection === CodeWhispererConstants.skipAllTestsMessage) {
transformByQState.setCustomBuildCommand(CodeWhispererConstants.skipAllTestsBuildCommand)
} else {
transformByQState.setCustomBuildCommand(CodeWhispererConstants.doNotSkipTestsBuildCommand)
// one of these must be true
if (skipTestsSelection === CodeWhispererConstants.skipUnitTestsMessage) {
transformByQState.setCustomBuildCommand(CodeWhispererConstants.skipUnitTestsBuildCommand)
} else if (skipTestsSelection === CodeWhispererConstants.doNotSkipUnitTestsMessage) {
transformByQState.setCustomBuildCommand(CodeWhispererConstants.doNotSkipUnitTestsBuildCommand)
}
telemetry.codeTransform_submitSelection.emit({
codeTransformSessionId: CodeTransformTelemetryState.instance.getSessionId(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,28 +114,24 @@ export class Messenger {
formItems.push({
id: 'GumbyTransformSkipTestsForm',
type: 'select',
title: CodeWhispererConstants.skipTestsFormTitle,
title: CodeWhispererConstants.skipUnitTestsFormTitle,
mandatory: true,
options: [
{
value: CodeWhispererConstants.doNotSkipTestsMessage,
label: CodeWhispererConstants.doNotSkipTestsMessage,
value: CodeWhispererConstants.doNotSkipUnitTestsMessage,
label: CodeWhispererConstants.doNotSkipUnitTestsMessage,
},
{
value: CodeWhispererConstants.skipIntegrationTestsMessage,
label: CodeWhispererConstants.skipIntegrationTestsMessage,
},
{
value: CodeWhispererConstants.skipAllTestsMessage,
label: CodeWhispererConstants.skipAllTestsMessage,
value: CodeWhispererConstants.skipUnitTestsMessage,
label: CodeWhispererConstants.skipUnitTestsMessage,
},
],
})

this.dispatcher.sendAsyncEventProgress(
new AsyncEventProgressMessage(tabID, {
inProgress: true,
message: CodeWhispererConstants.skipTestsFormMessage,
message: CodeWhispererConstants.skipUnitTestsFormMessage,
})
)

Expand Down Expand Up @@ -467,8 +463,8 @@ export class Messenger {
public sendSkipTestsSelectionMessage(skipTestsSelection: string, tabID: string) {
// just for correct grammar
let skipTestsText = skipTestsSelection
if (skipTestsText === CodeWhispererConstants.doNotSkipTestsMessage) {
skipTestsText = 'not skip tests'
if (skipTestsText === CodeWhispererConstants.doNotSkipUnitTestsMessage) {
skipTestsText = 'not skip unit tests'
}
const message = `Ok, I will ${skipTestsText.toLowerCase()} when building your project.`
this.dispatcher.sendChatMessage(new ChatMessage({ message, messageType: 'prompt' }, tabID))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ export async function preTransformationUploadCode() {
telemetry.record({ codeTransformSessionId: CodeTransformTelemetryState.instance.getSessionId() })

const transformZipManifest = new ZipManifest()
// if the user chose to skip tests, add the flag here
// if the user chose to skip unit tests, add the custom build command here
transformZipManifest.customBuildCommand = transformByQState.getCustomBuildCommand()
const zipCodeResult = await zipCode({
dependenciesFolder: transformByQState.getDependencyFolderInfo()!,
Expand Down
18 changes: 7 additions & 11 deletions packages/core/src/codewhisperer/models/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -632,22 +632,18 @@ export const chooseSourceVersionFormTitle = 'Choose the source code version'

export const chooseTargetVersionFormTitle = 'Choose the target code version'

export const skipTestsFormTitle = 'Choose to skip tests'
export const skipUnitTestsFormTitle = 'Choose to skip unit tests'

export const skipTestsFormMessage =
"Amazon Q uses 'mvn verify' to build your project. You can skip running tests to reduce the build time."
export const skipUnitTestsFormMessage =
'I will build your app using `mvn test` by default. If you would like to skip running unit tests to reduce build time, I will use `mvn test-compile`.'

export const doNotSkipTestsMessage = 'Do not skip tests'
export const doNotSkipUnitTestsMessage = 'Do not skip unit tests'

export const doNotSkipTestsBuildCommand = 'verify'
export const doNotSkipUnitTestsBuildCommand = 'test'

export const skipIntegrationTestsMessage = 'Skip integration tests'
export const skipUnitTestsMessage = 'Skip unit tests'

export const skipIntegrationTestsBuildCommand = 'test'

export const skipAllTestsMessage = 'Skip all tests'

export const skipAllTestsBuildCommand = 'test-compile'
export const skipUnitTestsBuildCommand = 'test-compile'

export const planTitle = 'Code Transformation plan by Amazon Q'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ describe('transformByQ', function () {
assert.deepStrictEqual(actual, expected)
})

it(`WHEN zip created THEN manifest.json contains -DskipTests flag`, async function () {
it(`WHEN zip created THEN manifest.json contains test-compile custom build command`, async function () {
const tempFileName = `testfile-${globals.clock.Date.now()}.zip`
transformByQState.setProjectPath(tempDir)
const transformManifest = new ZipManifest()
Expand Down

0 comments on commit ebc79cf

Please sign in to comment.