-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Run tests in an environment which also includes layers #900
Comments
It seems like some packagers provide a native way of specifying "dev" dependencies, for example pipenv and npm. Perhaps we could add a new command |
thanks @billyshambrook , this feature would precisely help with my use case. https://stackoverflow.com/questions/70253939/running-tests-pytest-in-ci-gitlab-ci-kubernetes-runner-for-aws-lambda-w-lay Team - thoughts on prioritizing this anytime soon? |
What is the status on this? |
So I'm pretty new to python and especially testing in python, but after many questions posed to gpt I think I have a working solution / workaround. I have no idea if this is best practice or not but it's all I could get to work: Create a # conftest.py
import sys
import os
sys.path.append(f"{os.getcwd()}/your/path/to/layers") After creating that file and adding the path to where I'm storing my layers, I was able to test my code as I would expect: Additional context from the convo w/ gpt if you're interested:
Cheers 🍻 |
Describe your idea/feature/enhancement
AWS Lambda Layers now make it possible to package a collection of dependencies together and can be shared across multiple Lambda Functions. AWS Lambda Layers can include language specific libraries, which the function will import to use.
This can break unit-tests written for Lambda Functions, as there may be imports that are provided via a Lambda Layer instead of via a build manifest (e.g.
requirements.txt
).Therefore, we need a way to execute unit-tests within the same environment as when you run
sam local invoke
.This problem also exists for other CI related checks like linting.
Additional Details
When you run unit-tests, linters etc, these may depend on additional build dependencies that you only need when running the checks but don't want in the final deploy, for example
py.test
. This would require some way of providing additional dependencies to the docker container that is used when running the checks.The text was updated successfully, but these errors were encountered: