Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class PrepareDocGenerationState(
var zipFileLength: Long? = null
val nextState: SessionState
try {
val repoZipResult = config.repoContext.getProjectZip()
val repoZipResult = config.repoContext.getProjectZip(false)
val zipFileChecksum = repoZipResult.checksum
zipFileLength = repoZipResult.contentLength
val fileToUpload = repoZipResult.payload
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const val FEATURE_EVALUATION_PRODUCT_NAME = "FeatureDev"
const val FEATURE_NAME = "Amazon Q Developer Agent for software development"

@Suppress("MaxLineLength")
const val GENERATE_DEV_FILE_PROMPT = "generate a devfile in my repository. Note that you should only use devfile version 2.0.0 and the only supported command is test, so you should bundle all install, build and test commands in “test”. also you can use public.ecr.aws/aws-mde/universal-image:latest as universal image if you aren’t sure which image to use. here is an example for a node repository (but don't assume it's always a node project. look at the existing repository structure before generating the devfile): schemaVersion: 2.0.0 components: - name: dev container: image: public.ecr.aws/aws-mde/universal-image:latest commands: - id: test exec: component: dev commandLine: \"npm install && npm run build && npm run test\""
const val GENERATE_DEV_FILE_PROMPT = "generate a devfile in my repository. Note that you should only use devfile version 2.0.0 and the only supported commands are install, build and test (are all optional). so you may have to bundle some commands together using '&&'. also you can use \"public.ecr.aws/aws-mde/universal-image:latest\" as universal image if you aren’t sure which image to use. here is an example for a node repository (but don't assume it's always a node project. look at the existing repository structure before generating the devfile): schemaVersion: 2.0.0 components: - name: dev container: image: public.ecr.aws/aws-mde/universal-image:latest commands: - id: install exec: component: dev commandLine: \"npm install\" - id: build exec: component: dev commandLine: \"npm run build\" - id: test exec: component: dev commandLine: \"npm run test\""

// Max number of times a user can attempt to retry a code generation request if it fails
const val CODE_GENERATION_RETRY_LIMIT = 3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ class FeatureDevController(
return
}

session.preloader(message, messenger)
session.preloader(messenger)
broadcastQEvent(QFeatureEvent.INVOCATION)

when (session.sessionState.phase) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,9 @@ class FeatureDevSessionContextTest : FeatureDevTestBase(HeavyJavaCodeInsightTest

@Test
fun testWithInvalidFile() {
val txtFile = mock<VirtualFile>()
whenever(txtFile.extension).thenReturn("txt")
whenever(txtFile.path).thenReturn("file.txt")
assertFalse(featureDevSessionContext.isFileExtensionAllowed(txtFile))
val mediaFile = mock<VirtualFile>()
whenever(mediaFile.extension).thenReturn("mp4")
assertFalse(featureDevSessionContext.isFileExtensionAllowed(mediaFile))
}

@Test
Expand Down Expand Up @@ -96,10 +95,11 @@ class FeatureDevSessionContextTest : FeatureDevTestBase(HeavyJavaCodeInsightTest
"License.md",
"node_modules/express",
"build/outputs",
"dist/bundle.js"
"dist/bundle.js",
"gradle/wrapper/gradle-wrapper.jar",
)

val zipResult = featureDevSessionContext.getProjectZip()
val zipResult = featureDevSessionContext.getProjectZip(false)
val zipPath = zipResult.payload.path

val zippedFiles = mutableSetOf<String>()
Expand All @@ -120,6 +120,8 @@ class FeatureDevSessionContextTest : FeatureDevTestBase(HeavyJavaCodeInsightTest
"builder/GetTestBuilder.java",
"settings.gradle",
"build.gradle",
"gradle/wrapper/gradle-wrapper.jar",
".gitignore",
)

assertTrue(zippedFiles == expectedFiles)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class CodeWhispererProjectCodeScanTest : CodeWhispererCodeScanTestBase(PythonCod
private lateinit var testYaml: VirtualFile
private lateinit var helperPy: VirtualFile
private lateinit var testTf: VirtualFile
private lateinit var gitIgnore: VirtualFile

private lateinit var sessionConfigSpy: CodeScanSessionConfig
private lateinit var sessionConfigSpy2: CodeScanSessionConfig
Expand Down Expand Up @@ -63,9 +64,9 @@ class CodeWhispererProjectCodeScanTest : CodeWhispererCodeScanTestBase(PythonCod
fun `test createPayload`() {
val payload = sessionConfigSpy.createPayload()
assertNotNull(payload)
assertThat(payload.context.totalFiles).isEqualTo(10)
assertThat(payload.context.totalFiles).isEqualTo(11)

assertThat(payload.context.scannedFiles.size).isEqualTo(10)
assertThat(payload.context.scannedFiles.size).isEqualTo(11)
assertThat(payload.context.scannedFiles).contains(testYaml, testTf, readMeMd, utilsJs, utilsCs, testJson, testCs, helperPy, helperCs, helpGo)

assertThat(payload.context.srcPayloadSize).isEqualTo(totalSize)
Expand All @@ -80,12 +81,12 @@ class CodeWhispererProjectCodeScanTest : CodeWhispererCodeScanTestBase(PythonCod
filesInZip += 1
}

assertThat(filesInZip).isEqualTo(10)
assertThat(filesInZip).isEqualTo(11)
}

@Test
fun `getProjectPayloadMetadata()`() {
getProjectPayloadMetadata(sessionConfigSpy, 10, totalSize, this.totalLines, CodewhispererLanguage.Csharp)
getProjectPayloadMetadata(sessionConfigSpy, 11, totalSize, this.totalLines, CodewhispererLanguage.Csharp)
}

@Test
Expand All @@ -105,7 +106,7 @@ class CodeWhispererProjectCodeScanTest : CodeWhispererCodeScanTestBase(PythonCod

@Test
fun `e2e happy path integration test`() = runTest {
assertE2ERunsSuccessfully(sessionConfigSpy, project, totalLines, 10, totalSize, 1)
assertE2ERunsSuccessfully(sessionConfigSpy, project, totalLines, 11, totalSize, 1)
}

private fun setupCsharpProject() {
Expand Down Expand Up @@ -371,7 +372,10 @@ class CodeWhispererProjectCodeScanTest : CodeWhispererCodeScanTestBase(PythonCod

// Adding gitignore file and gitignore file member for testing.
// The tests include the markdown file but not these two files.
projectRule.fixture.addFileToProject("/.gitignore", "node_modules\n.idea\n.vscode\n.DS_Store").virtualFile
gitIgnore = projectRule.fixture.addFileToProject("/.gitignore", "node_modules\n.idea\n.vscode\n.DS_Store").virtualFile
totalSize += gitIgnore.length
totalLines += gitIgnore.toNioPath().toFile().readLines().size

projectRule.fixture.addFileToProject("/.idea/ref", "ref: refs/heads/main")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ class RepoSizeLimitError(override val message: String) : RuntimeException(), Rep
class FeatureDevSessionContext(val project: Project, val maxProjectSizeBytes: Long? = null) {
// TODO: Need to correct this class location in the modules going further to support both amazonq and codescan.

private val requiredFilesForExecution = setOf("gradle/wrapper/gradle-wrapper.jar")
private val additionalGitIgnoreRules = setOf(
".aws-sam",
".gem",
".git",
".gitignore",
".gradle",
".hg",
".idea",
Expand Down Expand Up @@ -136,6 +136,9 @@ class FeatureDevSessionContext(val project: Project, val maxProjectSizeBytes: Lo
suspend fun ignoreFile(file: VirtualFile): Boolean = ignoreFile(file.presentableUrl)

suspend fun ignoreFile(path: String): Boolean {
if (requiredFilesForExecution.any { path.endsWith(it) }) {
return false
}
// this method reads like something a JS dev would write and doesn't do what the author thinks
val deferredResults = ignorePatternsWithGitIgnore.map { pattern ->
withContext(coroutineContext) {
Expand Down
Loading