Skip to content

Commit 8902746

Browse files
authored
CI: fix python2.7 setup #1478
- Pip2 and Python27 are no longer available (end-of-life) in the standard repo in the CodeBuild 5.0 image, so add workarounds to install them. - Python 2.7 is in the `Universe` repository. - Pip2 is not, install it with their install script. ref aws/aws-toolkit-jetbrains#2366
1 parent a3bb9ae commit 8902746

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/integrationTest/sam.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import * as assert from 'assert'
77
import { Runtime } from 'aws-sdk/clients/lambda'
88
import { mkdirpSync, mkdtemp, removeSync } from 'fs-extra'
9+
import * as fs from 'fs-extra'
910
import * as path from 'path'
1011
import * as vscode from 'vscode'
1112
import { getDependencyManager } from '../../src/lambda/models/samLambdaRuntime'
@@ -299,6 +300,20 @@ describe('SAM Integration Tests', async function () {
299300
let appPath: string
300301
let cfnTemplatePath: string
301302

303+
/**
304+
* TEMPORARY hack for python2.7
305+
* see https://github.com/aws/aws-toolkit-vscode/pull/1478
306+
*/
307+
function fixPython27Dockerfile(dir: string) {
308+
const dockerfile = path.join(dir, samApplicationName, 'hello_world/Dockerfile')
309+
const text = fs.readFileSync(dockerfile, { encoding: 'utf-8' })
310+
const text2 = text.replace(
311+
'https://bootstrap.pypa.io/get-pip.py',
312+
'https://bootstrap.pypa.io/2.7/get-pip.py'
313+
)
314+
fs.writeFileSync(dockerfile, text2, { encoding: 'utf-8' })
315+
}
316+
302317
before(async function () {
303318
testDir = await mkdtemp(path.join(runtimeTestRoot, 'samapp-'))
304319
log(`testDir: ${testDir}`)
@@ -307,6 +322,9 @@ describe('SAM Integration Tests', async function () {
307322
appPath = path.join(testDir, samApplicationName, scenario.path)
308323
cfnTemplatePath = path.join(testDir, samApplicationName, 'template.yaml')
309324
assert.ok(await fileExists(cfnTemplatePath), `Expected SAM template to exist at ${cfnTemplatePath}`)
325+
if (scenario.baseImage && scenario.runtime === 'python2.7') {
326+
fixPython27Dockerfile(testDir)
327+
}
310328
samAppCodeUri = await openSamAppFile(appPath)
311329
})
312330

0 commit comments

Comments
 (0)