Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: change scope of change detection for python layers #7545

Merged
merged 1 commit into from
Jun 18, 2021
Merged
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 @@ -21,6 +21,8 @@ const layerResourceGlobs = [parametersFileName, `*${cfnTemplateSuffix}`];
const libPathName = 'lib';
const optPathName = 'opt';
const packageJson = 'package.json';
const pipfile = 'Pipfile';
const pipfileLock = 'Pipfile.lock';

export interface LayerInputParams {
layerPermissions?: PermissionEnum[];
Expand Down Expand Up @@ -343,7 +345,28 @@ const getLayerGlobs = async (

result.push(...contentFilePaths);
} else if (runtimeId === 'python') {
// No special treatment needed for python yet.
// Add to hashable files/folders
const pipfileFilePath = path.join(layerCodePath, pipfile);

if (fs.existsSync(pipfileFilePath)) {
result.push(path.join(libPathName, layerExecutablePath, pipfile));
}

// If lock file is present, add to hashable files/folders
const pipfileLockFilePath = path.join(layerCodePath, pipfileLock);

if (fs.existsSync(pipfileLockFilePath)) {
result.push(path.join(libPathName, layerExecutablePath, pipfileLockFilePath));
}

// Add layer direct content from lib/python and exclude well known files from list.
// files must be relative to resource folder as that will be used as a base path for hashing.
const contentFilePaths = await globby([path.join(libPathName, layerExecutablePath, '**', '*')], {
cwd: resourcePath,
ignore: ['lib', pipfile, pipfileLock].map(name => path.join(libPathName, layerExecutablePath, name)),
});

result.push(...contentFilePaths);
} else {
const error = new Error(`Unsupported layer runtime: ${runtimeId} for resource: ${resourceName}`);
error.stack = undefined;
Expand Down