Skip to content

Commit 422fa1d

Browse files
committed
Merge branch 'master' into process/track
2 parents ec3abbf + 3d90772 commit 422fa1d

File tree

9 files changed

+105
-45
lines changed

9 files changed

+105
-45
lines changed

buildspec/linuxE2ETests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ phases:
3737
commands:
3838
- export HOME=/home/codebuild-user
3939
# Ignore failure until throttling issues are fixed.
40-
- xvfb-run npm run testE2E
40+
- xvfb-run npm run testE2E; npm run mergeReports -- "$?"
4141
- VCS_COMMIT_ID="${CODEBUILD_RESOLVED_SOURCE_VERSION}"
4242
- CI_BUILD_URL=$(echo $CODEBUILD_BUILD_URL | sed 's/#/%23/g')
4343
- CI_BUILD_ID="${CODEBUILD_BUILD_ID}"

buildspec/linuxIntegrationTests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ phases:
9292
build:
9393
commands:
9494
- export HOME=/home/codebuild-user
95-
- xvfb-run npm run testInteg
95+
- xvfb-run npm run testInteg; npm run mergeReports -- "$?"
9696
- VCS_COMMIT_ID="${CODEBUILD_RESOLVED_SOURCE_VERSION}"
9797
- CI_BUILD_URL=$(echo $CODEBUILD_BUILD_URL | sed 's/#/%23/g')
9898
- CI_BUILD_ID="${CODEBUILD_BUILD_ID}"

buildspec/linuxTests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ phases:
4141
# Ensure that "foo | run_and_report" fails correctly.
4242
set -o pipefail
4343
. buildspec/shared/common.sh
44-
2>&1 xvfb-run npm test --silent | run_and_report 2 \
44+
{ 2>&1 xvfb-run npm test --silent; npm run mergeReports -- "$?"; } | run_and_report 2 \
4545
'rejected promise not handled' \
4646
'This typically indicates a bug. Read https://developer.mozilla.org/docs/Web/JavaScript/Guide/Using_promises#error_handling'
4747
}

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@
3636
"lintfix": "eslint -c .eslintrc.js --ignore-path .gitignore --ignore-pattern '**/*.json' --ignore-pattern '**/*.gen.ts' --ignore-pattern '**/types/*.d.ts' --ignore-pattern '**/src/testFixtures/**' --ignore-pattern '**/resources/js/graphStateMachine.js' --fix --ext .ts packages plugins",
3737
"clean": "npm run clean -w packages/ -w plugins/",
3838
"reset": "npm run clean && ts-node ./scripts/clean.ts node_modules && npm install",
39-
"generateNonCodeFiles": "npm run generateNonCodeFiles -w packages/ --if-present"
39+
"generateNonCodeFiles": "npm run generateNonCodeFiles -w packages/ --if-present",
40+
"mergeReports": "ts-node ./scripts/mergeReports.ts"
4041
},
4142
"devDependencies": {
4243
"@aws-toolkits/telemetry": "^1.0.289",

packages/core/src/amazonqGumby/chat/controller/controller.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ import {
5050
CodeTransformJavaTargetVersionsAllowed,
5151
CodeTransformJavaSourceVersionsAllowed,
5252
} from '../../../shared/telemetry/telemetry'
53-
import { MetadataResult } from '../../../shared/telemetry/telemetryClient'
5453
import { CodeTransformTelemetryState } from '../../telemetry/codeTransformTelemetryState'
5554
import DependencyVersions from '../../models/dependencies'
5655
import { getStringHash } from '../../../shared/utilities/textUtilities'
@@ -364,15 +363,16 @@ export class GumbyController {
364363
await this.handleUserLanguageUpgradeProjectChoice(message)
365364
break
366365
case ButtonActions.CANCEL_TRANSFORMATION_FORM:
367-
telemetry.codeTransform_submitSelection.emit({
368-
codeTransformSessionId: CodeTransformTelemetryState.instance.getSessionId(),
369-
userChoice: 'Cancel',
370-
result: MetadataResult.Pass,
371-
})
372-
this.transformationFinished({
373-
message: CodeWhispererConstants.jobCancelledChatMessage,
374-
tabID: message.tabID,
375-
includeStartNewTransformationButton: true,
366+
telemetry.codeTransform_submitSelection.run(() => {
367+
telemetry.record({
368+
codeTransformSessionId: CodeTransformTelemetryState.instance.getSessionId(),
369+
userChoice: 'Cancel',
370+
})
371+
this.transformationFinished({
372+
message: CodeWhispererConstants.jobCancelledChatMessage,
373+
tabID: message.tabID,
374+
includeStartNewTransformationButton: true,
375+
})
376376
})
377377
break
378378
case ButtonActions.CONFIRM_SKIP_TESTS_FORM:

packages/core/src/codewhisperer/service/transformByQ/transformationResultsViewProvider.ts

Lines changed: 16 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import { ExportResultArchiveStructure, downloadExportResultArchive } from '../..
2121
import { getLogger } from '../../../shared/logger'
2222
import { telemetry } from '../../../shared/telemetry/telemetry'
2323
import { CodeTransformTelemetryState } from '../../../amazonqGumby/telemetry/codeTransformTelemetryState'
24-
import { MetadataResult } from '../../../shared/telemetry/telemetryClient'
2524
import * as CodeWhispererConstants from '../../models/constants'
2625
import { createCodeWhispererChatStreamingClient } from '../../../shared/clients/codewhispererChatClient'
2726
import { ChatSessionManager } from '../../../amazonqGumby/chat/storages/chatSession'
@@ -532,11 +531,13 @@ export class ProposedTransformationExplorer {
532531
})
533532

534533
vscode.commands.registerCommand('aws.amazonq.transformationHub.reviewChanges.acceptChanges', async () => {
535-
diffModel.saveChanges()
536-
telemetry.codeTransform_submitSelection.emit({
537-
codeTransformSessionId: CodeTransformTelemetryState.instance.getSessionId(),
538-
codeTransformJobId: transformByQState.getJobId(),
539-
userChoice: `acceptChanges-${patchFilesDescriptions?.content[diffModel.currentPatchIndex].name}`,
534+
telemetry.codeTransform_submitSelection.run(() => {
535+
diffModel.saveChanges()
536+
telemetry.record({
537+
codeTransformSessionId: CodeTransformTelemetryState.instance.getSessionId(),
538+
codeTransformJobId: transformByQState.getJobId(),
539+
userChoice: `acceptChanges-${patchFilesDescriptions?.content[diffModel.currentPatchIndex].name}`,
540+
})
540541
})
541542
if (transformByQState.getMultipleDiffs()) {
542543
void vscode.window.showInformationMessage(
@@ -580,35 +581,21 @@ export class ProposedTransformationExplorer {
580581
// All patches have been applied, reset the state
581582
await reset()
582583
}
583-
584-
telemetry.codeTransform_viewArtifact.emit({
585-
codeTransformArtifactType: 'ClientInstructions',
586-
codeTransformVCSViewerSrcComponents: 'toastNotification',
587-
codeTransformSessionId: CodeTransformTelemetryState.instance.getSessionId(),
588-
codeTransformJobId: transformByQState.getJobId(),
589-
codeTransformStatus: transformByQState.getStatus(),
590-
userChoice: 'Submit',
591-
result: MetadataResult.Pass,
592-
})
593584
})
594585

595586
vscode.commands.registerCommand('aws.amazonq.transformationHub.reviewChanges.rejectChanges', async () => {
596-
diffModel.rejectChanges()
597-
await reset()
598-
587+
await telemetry.codeTransform_submitSelection.run(async () => {
588+
diffModel.rejectChanges()
589+
await reset()
590+
telemetry.record({
591+
codeTransformSessionId: CodeTransformTelemetryState.instance.getSessionId(),
592+
codeTransformJobId: transformByQState.getJobId(),
593+
userChoice: 'rejectChanges',
594+
})
595+
})
599596
transformByQState.getChatControllers()?.transformationFinished.fire({
600597
tabID: ChatSessionManager.Instance.getSession().tabID,
601598
})
602-
603-
telemetry.codeTransform_viewArtifact.emit({
604-
codeTransformArtifactType: 'ClientInstructions',
605-
codeTransformVCSViewerSrcComponents: 'toastNotification',
606-
codeTransformSessionId: CodeTransformTelemetryState.instance.getSessionId(),
607-
codeTransformJobId: transformByQState.getJobId(),
608-
codeTransformStatus: transformByQState.getStatus(),
609-
userChoice: 'Cancel',
610-
result: MetadataResult.Pass,
611-
})
612599
})
613600
}
614601
}

packages/core/src/test/techdebt.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,6 @@ describe('tech debt', function () {
4646
// Monitor telemtry to determine removal or snooze
4747
// toolkit_showNotification.id = sessionSeparation
4848
// auth_modifyConnection.action = deleteProfile OR auth_modifyConnection.source contains CodeCatalyst
49-
fixByDate('2025-01-06', 'Remove the edge case code from the commit that this test is a part of.')
49+
fixByDate('2025-06-06', 'Remove the edge case code from the commit that this test is a part of.')
5050
})
5151
})

packages/core/src/test/testRunner.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ export async function runTests(
6565
}
6666

6767
const root = getRoot()
68-
const outputFile = path.resolve(root, '../../', '.test-reports', 'report.xml')
68+
// output the report to the individual package
69+
const outputFile = path.resolve(root, '.test-reports', 'report.xml')
6970
const colorOutput = !process.env['AWS_TOOLKIT_TEST_NO_COLOR']
7071

7172
// Create the mocha test

scripts/mergeReports.ts

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/*!
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
import * as fs from 'fs'
7+
import * as path from 'path'
8+
import * as xml2js from 'xml2js'
9+
10+
/**
11+
* Merge all of the packages/ test reports into a single directory
12+
*/
13+
async function mergeReports() {
14+
console.log('Merging test reports')
15+
16+
const packagesDir = `${__dirname}/../packages`
17+
18+
// Get all packages/* directories
19+
const packageDirs = fs.readdirSync(packagesDir).map((dir) => path.join(packagesDir, dir))
20+
21+
// Find report.xml files in .test-reports subdirectories
22+
const testReports = packageDirs
23+
.map((dir) => `${dir}/.test-reports/report.xml`)
24+
.filter((file) => fs.existsSync(file))
25+
26+
const mergedReport = {
27+
testsuites: {
28+
testsuite: [],
29+
},
30+
}
31+
32+
// Collect all test reports into a single merged test report object
33+
for (const file of testReports) {
34+
const content = fs.readFileSync(file)
35+
const result: { testsuites: { testsuite: [] } } = await xml2js.parseStringPromise(content)
36+
if (result.testsuites && result.testsuites.testsuite) {
37+
mergedReport.testsuites.testsuite.push(...result.testsuites.testsuite)
38+
}
39+
}
40+
41+
const builder = new xml2js.Builder()
42+
const xml = builder.buildObject(mergedReport)
43+
44+
/**
45+
* Create the new test reports directory and write the test report
46+
*/
47+
const reportsDir = path.join(__dirname, '..', '.test-reports')
48+
49+
// Create reports directory if it doesn't exist
50+
if (!fs.existsSync(reportsDir)) {
51+
fs.mkdirSync(reportsDir, { recursive: true })
52+
}
53+
54+
fs.writeFileSync(`${reportsDir}/report.xml`, xml)
55+
56+
const exitCodeArg = process.argv[2]
57+
if (exitCodeArg) {
58+
/**
59+
* Retrieves the exit code from the previous test run execution.
60+
*
61+
* This allows us to:
62+
* 1. Merge and upload test reports regardless of the test execution status
63+
* 2. Preserve the original test run exit code
64+
* 3. Report the test status back to CI
65+
*/
66+
const exitCode = parseInt(exitCodeArg || '0', 10)
67+
process.exit(exitCode)
68+
}
69+
}
70+
71+
mergeReports()

0 commit comments

Comments
 (0)