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

Add DebugConfigurationProvider for debugging lambdas locally. #144

Merged
merged 6 commits into from
Nov 1, 2018

Conversation

mpiroc
Copy link
Contributor

@mpiroc mpiroc commented Oct 29, 2018

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Infrastructure (change which improves the lifecycle management (CI/CD, build, package, deploy, lint, etc) of the application, but does not change functionality.)
  • Technical debt (change which improves the maintainability of the codebase, but does not change functionality)
  • Testing (change which modifies or adds test coverage, but does not change functionality)
  • Documentation (change which modifies or adds documentation, but does not change functionality)

Description

Introduce a DebugConfigurationProvider that provides configurations for the built-in NodeJS debugger.

  • For each Lambda detected in template.y[a]ml, provide two configurations: One launch to invoke the function using SAM local and attach to the container, and one attach configuration to attach to an existing container.
  • For each launch configuration, add a corresponding "Debug ______ Locally" task, and invoke that task as a preLaunchTask from the launch configuration.

Known issues:

Motivation and Context

VS Code users configure their debugger using the file launch.json. When the user first creates launch.json we provide default configurations for each of the user's local lambda functions. Additionally, when the user decides to add another configuration, VS Code presents a list of presets that includes our configurations (among others).

The simplest end-to-end workflows are:

If the user has not previously set up their debug configurations.

  1. Create a lambda app using sam init, or bring your own. Open the root folder of the app in VS Code.
  2. Select the 'Debug' viewlet and click the 'configurations' button. When prompted to choose an environment, select 'Lambda'.
  3. Select the Lambda that you want to debug from the 'Debug' viewlet, set a breakpoint, and press F5.

If the user has already set up some debug configurations.

  1. Select the 'Debug' viewlet and click the 'Add Configuration' button. When prompted, select the configuration labeled Lambda: Invoke MyFunction locally.
  2. Select the Lambda that you want to debug from the 'Debug' viewlet, set a breakpoint, and press F5.

Related Issue(s)

#134.

Testing

Testing is currently (Oct 28) incomplete. This PR should not be merged until it is complete.

Screenshots (if appropriate)

Checklist

  • I have read the README document
  • I have read the CONTRIBUTING document
  • My code follows the code style of this project
  • I have added tests to cover my changes
  • All new and existing tests passed
  • A short description of the change has been added to the CHANGELOG

License

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@mpiroc mpiroc self-assigned this Oct 29, 2018
package.json Outdated Show resolved Hide resolved
Copy link
Contributor

@stevejroberts stevejroberts left a comment

Choose a reason for hiding this comment

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

LGTM so far, some minor questions and nits.

package.json Outdated Show resolved Hide resolved
src/shared/filesystem.ts Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
src/lambda/local/debugConfigurationProvider.ts Outdated Show resolved Hide resolved
src/lambda/local/debugConfigurationProvider.ts Outdated Show resolved Hide resolved
src/lambda/local/debugConfigurationProvider.ts Outdated Show resolved Hide resolved
src/lambda/local/debugConfigurationProvider.ts Outdated Show resolved Hide resolved
src/lambda/local/debugConfigurationProvider.ts Outdated Show resolved Hide resolved
src/lambda/local/debugConfigurationProvider.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@awschristou awschristou left a comment

Choose a reason for hiding this comment

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

The code changes look good up to this point. The build is failing though.
I'll wait to approve in case further code revisions are required.

Copy link
Contributor

@awschristou awschristou left a comment

Choose a reason for hiding this comment

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

It looks like some additional tests are coming to this PR. Not quite approved just yet then...

@codecov-io
Copy link

codecov-io commented Oct 31, 2018

Codecov Report

Merging #144 into develop will increase coverage by 3.5%.
The diff coverage is 89.51%.

Impacted file tree graph

@@            Coverage Diff             @@
##           develop     #144     +/-   ##
==========================================
+ Coverage    44.66%   48.17%   +3.5%     
==========================================
  Files           49       51      +2     
  Lines         1359     1476    +117     
  Branches       189      214     +25     
==========================================
+ Hits           607      711    +104     
- Misses         752      765     +13
Impacted Files Coverage Δ
src/extension.ts 0% <0%> (ø) ⬆️
src/shared/credentials/credentialsFile.ts 78.78% <100%> (+0.32%) ⬆️
src/shared/credentials/userCredentialsUtils.ts 88.09% <100%> (+0.29%) ⬆️
src/shared/settingsConfiguration.ts 92.3% <100%> (ø) ⬆️
src/shared/typescriptLambdaHandlerSearch.ts 99.08% <100%> (ø) ⬆️
src/shared/filesystemUtilities.ts 100% <100%> (ø)
src/shared/filesystem.ts 89.47% <86.04%> (-2.84%) ⬇️
src/lambda/local/debugConfigurationProvider.ts 90.47% <90.47%> (ø)
src/lambda/local/detectLocalLambdas.ts 93.75% <91.66%> (-2.09%) ⬇️
... and 2 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ce746c6...06c5de7. Read the comment docs.

@mpiroc mpiroc merged commit 81b13e1 into develop Nov 1, 2018
@mpiroc mpiroc deleted the pirocchi/launch branch November 1, 2018 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants