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

Feature request: Run Node tests as part of sam build #7348

Open
saraiyakush opened this issue Aug 13, 2024 · 2 comments
Open

Feature request: Run Node tests as part of sam build #7348

saraiyakush opened this issue Aug 13, 2024 · 2 comments
Labels
contributors/welcome Contributors are welcome to work on this type/feature Feature request

Comments

@saraiyakush
Copy link

Describe your idea/feature/enhancement

The sam build command should run tests as well for Node runtime, just like it does for Java runtime.

Proposal

Include one more step below in the npm builder to run any available tests. One way to do this is to include a step that runs npm run test command, which will eventually run the command as specified in the package.json.

~ sam build
Starting Build use cache
Manifest file is changed (new hash: 64859513bdbd90c2fad6e086b18218ab) or dependency folder (.aws-sam/deps/6b249e35-3277-4962-a9f6-31718d68bd22) is
missing for (HelloWorldFunction), downloading dependencies and copying/building source
Building codeuri: /Users/kush.saraiya/Documents/Workspace/Personal/sample-sam-app/hello-world runtime: nodejs20.x metadata: {} architecture: x86_64
functions: HelloWorldFunction
 Running NodejsNpmBuilder:NpmPack
 Running NodejsNpmBuilder:CopyNpmrcAndLockfile
 Running NodejsNpmBuilder:CopySource
 Running NodejsNpmBuilder:NpmInstall
 Running NodejsNpmBuilder:CleanUp
 Running NodejsNpmBuilder:CopyDependencies
 Running NodejsNpmBuilder:CleanUpNpmrc
 Running NodejsNpmBuilder:LockfileCleanUp
 Running NodejsNpmBuilder:LockfileCleanUp

Build Succeeded

Things to consider:

  1. Will this require any updates to the SAM Spec - No

Additional Details

I came across this limitation where I was maintaining two SAM projects - one with Java and one with Node. We used sam build in our pipeline for both of them and I noticed that the sam build command ran the Java unit tests but not for Node. I think this will be a great feature to be added.

I am very much interested to work on this feature and can open a PR if you think this is worth it.

@saraiyakush saraiyakush added stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. type/feature Feature request labels Aug 13, 2024
@hawflau
Copy link
Contributor

hawflau commented Aug 13, 2024

Hey @saraiyakush thanks for raising the feature request. Your proposal makes sense and I think it's a good feature to add. Feel free to raise a PR. We will review it when it's ready!

FYI the underlying build workflow is powered by AWS Lambda Builders - https://github.com/aws/aws-lambda-builders. I think your change will likely be made in Lambda Builders

@hawflau hawflau added contributors/welcome Contributors are welcome to work on this and removed stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. labels Aug 13, 2024
@saraiyakush
Copy link
Author

Opened the PR aws/aws-lambda-builders#681

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributors/welcome Contributors are welcome to work on this type/feature Feature request
Projects
None yet
Development

No branches or pull requests

2 participants