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
21 changes: 21 additions & 0 deletions buildspec/linuxIntegrationTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,27 @@ phases:
# Ensure that "docker" group has permissions to the socket.
# - chown codebuild-user /var/run/docker.sock
- chmod 666 /var/run/docker.sock
# Pull Docker Images for SAM tests
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea!!


# Nodejs
- |
docker pull public.ecr.aws/sam/build-nodejs18.x:latest
docker pull public.ecr.aws/sam/build-nodejs20.x:latest
docker pull public.ecr.aws/sam/build-nodejs22.x:latest
# Java
- |
docker pull public.ecr.aws/sam/build-java8.al2:latest
docker pull public.ecr.aws/sam/build-java11:latest
docker pull public.ecr.aws/sam/build-java17:latest
# Python
- |
docker pull public.ecr.aws/sam/build-python3.10:latest
docker pull public.ecr.aws/sam/build-python3.11:latest
docker pull public.ecr.aws/sam/build-python3.12:latest
docker pull public.ecr.aws/sam/build-python3.13:latest
# Dotnet
- |
docker pull public.ecr.aws/sam/build-dotnet6:latest

pre_build:
commands:
Expand Down
335 changes: 92 additions & 243 deletions packages/core/src/testInteg/sam.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,262 +46,111 @@ const noDebugSessionInterval: number = 100
/** Go can't handle API tests yet */
const skipLanguagesOnApi = ['go']

interface TestScenario {
displayName: string
runtime: Runtime
baseImage?: string
interface TestScenarioDefaults {
path: string
debugSessionType: string
language: Language
dependencyManager: DependencyManager
/** Minimum vscode version required by the relevant third-party extension. */
vscodeMinimum: string
}
type TestScenario = {
displayName: string
runtime: Runtime
baseImage?: string
} & TestScenarioDefaults

const nodeDefaults = {
path: 'hello-world/app.mjs',
debugSessionType: 'pwa-node',
dependencyManager: 'npm' as DependencyManager,
language: 'javascript' as Language,
vscodeMinimum: '1.50.0',
}
// https://github.com/microsoft/vscode-python/blob/main/package.json
const pythonDefaults = {
path: 'hello_world/app.py',
debugSessionType: 'python',
dependencyManager: 'pip' as DependencyManager,
language: 'python' as Language,
vscodeMinimum: '1.77.0',
}

const javaDefaults = {
path: 'HelloWorldFunction/src/main/java/helloworld/App.java',
debugSessionType: 'java',
dependencyManager: 'gradle' as DependencyManager,
language: 'java' as Language,
vscodeMinimum: '1.50.0',
}

const dotnetDefaults = {
path: 'src/HelloWorld/Function.cs',
debugSessionType: 'coreclr',
language: 'csharp' as Language,
dependencyManager: 'cli-package' as DependencyManager,
vscodeMinimum: '1.80.0',
}

const defaults: Record<Runtime, TestScenarioDefaults> = {
nodejs: nodeDefaults,
java: javaDefaults,
python: pythonDefaults,
dotnet: dotnetDefaults,
}

function generateScenario(
runtime: Runtime,
version: string,
options: Partial<TestScenario & { sourceTag: string }> = {},
fromImage: boolean = false
): TestScenario {
if (fromImage && !options.baseImage) {
throw new Error('baseImage property must be specified when testing from image')
}
const { sourceTag, ...defaultOverride } = options
const source = `(${options.sourceTag ? `${options.sourceTag} ` : ''}${fromImage ? 'Image' : 'ZIP'})`
const fullName = `${runtime}${version}`
return {
runtime: fullName,
displayName: `${fullName} ${source}`,
...defaults[runtime],
...defaultOverride,
}
}
// When testing additional runtimes, consider pulling the docker container in buildspec\linuxIntegrationTests.yml
// to reduce the chance of automated tests timing out.

const scenarios: TestScenario[] = [
// zips
{
runtime: 'nodejs18.x',
displayName: 'nodejs18.x (ZIP)',
path: 'hello-world/app.mjs',
debugSessionType: 'pwa-node',
language: 'javascript',
dependencyManager: 'npm',
vscodeMinimum: '1.50.0',
},
{
runtime: 'nodejs20.x',
displayName: 'nodejs20.x (ZIP)',
path: 'hello-world/app.mjs',
debugSessionType: 'pwa-node',
language: 'javascript',
dependencyManager: 'npm',
vscodeMinimum: '1.50.0',
},
{
runtime: 'nodejs22.x',
displayName: 'nodejs22.x (ZIP)',
path: 'hello-world/app.mjs',
debugSessionType: 'pwa-node',
language: 'javascript',
dependencyManager: 'npm',
vscodeMinimum: '1.78.0',
},
{
runtime: 'python3.10',
displayName: 'python 3.10 (ZIP)',
path: 'hello_world/app.py',
debugSessionType: 'python',
language: 'python',
dependencyManager: 'pip',
// https://github.com/microsoft/vscode-python/blob/main/package.json
vscodeMinimum: '1.77.0',
},
{
runtime: 'python3.11',
displayName: 'python 3.11 (ZIP)',
path: 'hello_world/app.py',
debugSessionType: 'python',
language: 'python',
dependencyManager: 'pip',
// https://github.com/microsoft/vscode-python/blob/main/package.json
vscodeMinimum: '1.78.0',
},
{
runtime: 'python3.12',
displayName: 'python 3.12 (ZIP)',
path: 'hello_world/app.py',
debugSessionType: 'python',
language: 'python',
dependencyManager: 'pip',
// https://github.com/microsoft/vscode-python/blob/main/package.json
vscodeMinimum: '1.78.0',
},
{
runtime: 'python3.13',
displayName: 'python 3.13 (ZIP)',
path: 'hello_world/app.py',
debugSessionType: 'python',
language: 'python',
dependencyManager: 'pip',
// https://github.com/microsoft/vscode-python/blob/main/package.json
vscodeMinimum: '1.78.0',
},
{
runtime: 'dotnet6',
displayName: 'dotnet6 (ZIP)',
path: 'src/HelloWorld/Function.cs',
debugSessionType: 'coreclr',
language: 'csharp',
dependencyManager: 'cli-package',
vscodeMinimum: '1.80.0',
},
{
runtime: 'java8.al2',
displayName: 'java8.al2 (Maven ZIP)',
path: 'HelloWorldFunction/src/main/java/helloworld/App.java',
debugSessionType: 'java',
language: 'java',
dependencyManager: 'maven',
vscodeMinimum: '1.50.0',
},
{
runtime: 'java11',
displayName: 'java11 (Gradle ZIP)',
path: 'HelloWorldFunction/src/main/java/helloworld/App.java',
debugSessionType: 'java',
language: 'java',
dependencyManager: 'gradle',
vscodeMinimum: '1.50.0',
},
{
runtime: 'java17',
displayName: 'java11 (Gradle ZIP)',
path: 'HelloWorldFunction/src/main/java/helloworld/App.java',
debugSessionType: 'java',
language: 'java',
dependencyManager: 'gradle',
vscodeMinimum: '1.50.0',
},
// {
// runtime: 'go1.x',
// displayName: 'go1.x (ZIP)',
// path: 'hello-world/main.go',
// debugSessionType: 'delve',
// language: 'go',
// dependencyManager: 'mod',
// // https://github.com/golang/vscode-go/blob/master/package.json
// vscodeMinimum: '1.67.0',
// },

generateScenario('nodejs', '18.x'),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A benefit of the old code is that it was "flat" data that did not require inspecting any logic. Copy-pasting can be very costly for logic, but for data, especially data contained in one place (this file) it can be a useful tradeoff.

However, your new code is certainly easier to read at a glance.

generateScenario('nodejs', '20.x'),
generateScenario('nodejs', '22.x', { vscodeMinimum: '1.78.0' }),
generateScenario('python', '3.10'),
generateScenario('python', '3.11', { vscodeMinimum: '1.78.0' }),
generateScenario('python', '3.12', { vscodeMinimum: '1.78.0' }),
generateScenario('python', '3.13', { vscodeMinimum: '1.78.0' }),
generateScenario('dotnet', '6'),
generateScenario('java', '8.al2', { sourceTag: 'Maven', dependencyManager: 'maven' }),
generateScenario('java', '11', { sourceTag: 'Gradle' }),
generateScenario('java', '17', { sourceTag: 'Gradle' }),
// images
{
runtime: 'nodejs18.x',
displayName: 'nodejs18.x (Image)',
baseImage: 'amazon/nodejs18.x-base',
path: 'hello-world/app.mjs',
debugSessionType: 'pwa-node',
language: 'javascript',
dependencyManager: 'npm',
vscodeMinimum: '1.50.0',
},
{
runtime: 'nodejs20.x',
displayName: 'nodejs20.x (Image)',
baseImage: 'amazon/nodejs20.x-base',
path: 'hello-world/app.mjs',
debugSessionType: 'pwa-node',
language: 'javascript',
dependencyManager: 'npm',
vscodeMinimum: '1.50.0',
},
{
runtime: 'nodejs22.x',
displayName: 'nodejs22.x (Image)',
baseImage: 'amazon/nodejs22.x-base',
path: 'hello-world/app.mjs',
debugSessionType: 'pwa-node',
language: 'javascript',
dependencyManager: 'npm',
vscodeMinimum: '1.78.0',
},
{
runtime: 'python3.10',
displayName: 'python 3.10 (ZIP)',
baseImage: 'amazon/python3.10-base',
path: 'hello_world/app.py',
debugSessionType: 'python',
language: 'python',
dependencyManager: 'pip',
// https://github.com/microsoft/vscode-python/blob/main/package.json
vscodeMinimum: '1.77.0',
},
{
runtime: 'python3.11',
displayName: 'python 3.11 (ZIP)',
baseImage: 'amazon/python3.11-base',
path: 'hello_world/app.py',
debugSessionType: 'python',
language: 'python',
dependencyManager: 'pip',
// https://github.com/microsoft/vscode-python/blob/main/package.json
vscodeMinimum: '1.78.0',
},
{
runtime: 'python3.12',
displayName: 'python 3.12 (ZIP)',
baseImage: 'amazon/python3.12-base',
path: 'hello_world/app.py',
debugSessionType: 'python',
language: 'python',
dependencyManager: 'pip',
// https://github.com/microsoft/vscode-python/blob/main/package.json
vscodeMinimum: '1.78.0',
},
{
runtime: 'python3.13',
displayName: 'python 3.13 (ZIP)',
baseImage: 'amazon/python3.13-base',
path: 'hello_world/app.py',
debugSessionType: 'python',
language: 'python',
dependencyManager: 'pip',
// https://github.com/microsoft/vscode-python/blob/main/package.json
vscodeMinimum: '1.78.0',
},
// {
// runtime: 'go1.x',
// displayName: 'go1.x (Image)',
// baseImage: 'amazon/go1.x-base',
// path: 'hello-world/main.go',
// debugSessionType: 'delve',
// language: 'go',
// dependencyManager: 'mod',
// // https://github.com/golang/vscode-go/blob/master/package.json
// vscodeMinimum: '1.67.0',
// },
{
runtime: 'java8.al2',
displayName: 'java8.al2 (Gradle Image)',
path: 'HelloWorldFunction/src/main/java/helloworld/App.java',
baseImage: 'amazon/java8.al2-base',
debugSessionType: 'java',
language: 'java',
dependencyManager: 'gradle',
vscodeMinimum: '1.50.0',
},
{
runtime: 'java11',
displayName: 'java11 (Maven Image)',
path: 'HelloWorldFunction/src/main/java/helloworld/App.java',
baseImage: 'amazon/java11-base',
debugSessionType: 'java',
language: 'java',
dependencyManager: 'maven',
vscodeMinimum: '1.50.0',
},
{
runtime: 'java17',
displayName: 'java17 (Maven Image)',
path: 'HelloWorldFunction/src/main/java/helloworld/App.java',
baseImage: 'amazon/java17-base',
debugSessionType: 'java',
language: 'java',
dependencyManager: 'maven',
vscodeMinimum: '1.50.0',
},
{
runtime: 'dotnet6',
displayName: 'dotnet6 (Image)',
path: 'src/HelloWorld/Function.cs',
baseImage: 'amazon/dotnet6-base',
debugSessionType: 'coreclr',
language: 'csharp',
dependencyManager: 'cli-package',
vscodeMinimum: '1.80.0',
},
generateScenario('nodejs', '18.x', { baseImage: 'amazon/nodejs18.x-base' }, true),
generateScenario('nodejs', '20.x', { baseImage: 'amazon/nodejs20.x-base' }, true),
generateScenario('nodejs', '22.x', { baseImage: 'amazon/nodejs22.x-base', vscodeMinimum: '1.78.0' }, true),
generateScenario('python', '3.10', { baseImage: 'amazon/python3.10-base' }, true),
generateScenario('python', '3.11', { baseImage: 'amazon/python3.11-base', vscodeMinimum: '1.78.0' }, true),
generateScenario('python', '3.12', { baseImage: 'amazon/python3.12-base', vscodeMinimum: '1.78.0' }, true),
generateScenario('python', '3.13', { baseImage: 'amazon/python3.13-base', vscodeMinimum: '1.78.0' }, true),
generateScenario('dotnet', '6', { baseImage: 'amazon/dotnet6-base' }, true),
generateScenario(
'java',
'.al2',
{ baseImage: 'amazon/java8.al2-base', sourceTag: 'Maven', dependencyManager: 'maven' },
true
),
generateScenario('java', '11', { baseImage: 'amazon/java11-base', sourceTag: 'Gradle' }, true),
generateScenario('java', '17', { baseImage: 'amazon/java17-base', sourceTag: 'Gradle' }, true),
]

async function openSamAppFile(applicationPath: string): Promise<vscode.Uri> {
Expand Down
Loading