diff --git a/.github/workflows/staging-deploy.yml b/.github/workflows/staging-deploy.yml index 5e12dc2..4a8443b 100644 --- a/.github/workflows/staging-deploy.yml +++ b/.github/workflows/staging-deploy.yml @@ -18,7 +18,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.8"] + python-version: ["3.12"] steps: - name: Checkout uses: actions/checkout@v4 diff --git a/app/Dockerfile b/app/Dockerfile index 7832b6e..d3b1373 100644 --- a/app/Dockerfile +++ b/app/Dockerfile @@ -1,16 +1,23 @@ -# Base image that bundles AWS Lambda Python 3.8 image with some middleware functions -# FROM base-eval-tmp -FROM ghcr.io/lambda-feedback/baseevalutionfunctionlayer:main-3.8 +# Base image that bundles the AWS Lambda Python image with the lambda-feedback middleware (app.handler) +FROM ghcr.io/lambda-feedback/baseevalutionfunctionlayer:main-3.12 + +# The 3.12 image is Amazon Linux 2023, which doesn't ship `find` (used below) +RUN dnf install -y findutils && dnf clean all WORKDIR /app +ENV PYTHONPATH=/app + # Copy and install any packages/modules needed for your evaluation script. COPY requirements.txt . RUN pip3 install -r requirements.txt +# The healthcheck command runs the pytest suite +RUN pip3 install pytest + # Copy the evaluation and testing scripts COPY evaluation.py ./app/ -COPY evaluation_test.py ./app/ +COPY evaluation_tests.py ./app/ # Copy Documentation COPY docs/dev.md ./app/docs/dev.md @@ -20,5 +27,6 @@ COPY docs/user.md ./app/docs/user.md RUN chmod 644 $(find . -type f) RUN chmod 755 $(find . -type d) -# The entrypoint for AWS is to invoke the handler function within the app package -CMD [ "/app/app.handler" ] +# The entrypoint for AWS is to invoke the handler function within the app package. +# Python 3.12's Lambda runtime imports this as a module name, so it can't be a path. +CMD [ "app.handler" ] diff --git a/app/evaluation_test.py b/app/evaluation_tests.py similarity index 100% rename from app/evaluation_test.py rename to app/evaluation_tests.py diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..589497f --- /dev/null +++ b/pytest.ini @@ -0,0 +1,4 @@ +[pytest] +# evaluation_tests.py is the name the base layer's healthcheck imports, so +# include it alongside pytest's default patterns. +python_files = test_*.py *_test.py *_tests.py diff --git a/readme.md b/readme.md index ea1e128..3856e27 100644 --- a/readme.md +++ b/readme.md @@ -28,7 +28,7 @@ app/ docs/ dev.md # Developer-facing documentation user.md # User-facing documentation - evaluation_test.py # Unittests for the main evaluation_function + evaluation_tests.py # Unittests for the main evaluation_function requirements.txt # List of packages needed for evaluation.py Dockerfile # For building the image to deploy to AWS @@ -59,7 +59,7 @@ config.json # Specifies the name of the evaluation function 4. You are now ready to start developing your function: - Edit the `app/evaluation.py` file, which ultimately gets called when the function is given the `eval` command - - Edit the `app/evaluation_test.py` file to add tests which get run: + - Edit the `app/evaluation_tests.py` file to add tests which get run: - Every time you commit to this repo, before the image is built and deployed - Whenever the `healthcheck` command is supplied to the deployed function - Edit the `app/docs/user.md` and `app/docs/dev.md` files to reflect your changes. These files are baked into the function's image and are made available using the `docs` command. This feature is used to display documentation on our [Documentation](https://lambda-feedback.github.io/Documentation/) website. @@ -91,7 +91,7 @@ Once the code passes all these tests, it will then be uploaded to AWS and will b ## Pre-requisites Although all programming can be done through the GitHub interface, it is recommended you do this locally on your machine. To do this, you must have installed: -- Python 3.8 or higher. +- Python 3.12 or higher. - GitHub Desktop or the `git` CLI.