diff --git a/.github/workflows/test-on-push-and-pr.yml b/.github/workflows/test-on-push-and-pr.yml index fe17cda..e6982c1 100644 --- a/.github/workflows/test-on-push-and-pr.yml +++ b/.github/workflows/test-on-push-and-pr.yml @@ -17,6 +17,6 @@ jobs: - name: Set up python uses: actions/setup-python@v2 with: - python-version: '3.8' + python-version: '3.11' - name: Run 'pr' target run: make pr diff --git a/Makefile b/Makefile index ab2ba46..b230ce4 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,7 @@ setup-codebuild-agent: .PHONY: test-smoke test-smoke: setup-codebuild-agent - CODEBUILD_IMAGE_TAG=codebuild-agent tests/integration/codebuild-local/test_one.sh tests/integration/codebuild/buildspec.os.alpine.yml alpine 3.15 3.9 + CODEBUILD_IMAGE_TAG=codebuild-agent tests/integration/codebuild-local/test_one.sh tests/integration/codebuild/buildspec.os.alpine.yml alpine 3.15 3.11 .PHONY: test-integ test-integ: setup-codebuild-agent diff --git a/README.md b/README.md index b8d79d5..8c83f34 100644 --- a/README.md +++ b/README.md @@ -5,12 +5,12 @@ We have open-sourced a set of software packages, Runtime Interface Clients (RIC) base images to be Lambda compatible. The Lambda Runtime Interface Client is a lightweight interface that allows your runtime to receive requests from and send requests to the Lambda service. -The Lambda Python Runtime Interface Client is vended through [pip](https://pypi.org/project/awslambdaric). +The Lambda Python Runtime Interface Client is vended through [pip](https://pypi.org/project/awslambdaric). You can include this package in your preferred base image to make that base image Lambda compatible. ## Requirements The Python Runtime Interface Client package currently supports Python versions: - - 3.7.x up to and including 3.9.x + - 3.7.x up to and including 3.11.x ## Usage @@ -104,18 +104,18 @@ def handler(event, context): ### Local Testing -To make it easy to locally test Lambda functions packaged as container images we open-sourced a lightweight web-server, Lambda Runtime Interface Emulator (RIE), which allows your function packaged as a container image to accept HTTP requests. You can install the [AWS Lambda Runtime Interface Emulator](https://github.com/aws/aws-lambda-runtime-interface-emulator) on your local machine to test your function. Then when you run the image function, you set the entrypoint to be the emulator. +To make it easy to locally test Lambda functions packaged as container images we open-sourced a lightweight web-server, Lambda Runtime Interface Emulator (RIE), which allows your function packaged as a container image to accept HTTP requests. You can install the [AWS Lambda Runtime Interface Emulator](https://github.com/aws/aws-lambda-runtime-interface-emulator) on your local machine to test your function. Then when you run the image function, you set the entrypoint to be the emulator. *To install the emulator and test your Lambda function* -1) From your project directory, run the following command to download the RIE from GitHub and install it on your local machine. +1) From your project directory, run the following command to download the RIE from GitHub and install it on your local machine. ```shell script mkdir -p ~/.aws-lambda-rie && \ curl -Lo ~/.aws-lambda-rie/aws-lambda-rie https://github.com/aws/aws-lambda-runtime-interface-emulator/releases/latest/download/aws-lambda-rie && \ chmod +x ~/.aws-lambda-rie/aws-lambda-rie ``` -2) Run your Lambda image function using the docker run command. +2) Run your Lambda image function using the docker run command. ```shell script docker run -d -v ~/.aws-lambda-rie:/aws-lambda -p 9000:8080 \ @@ -124,9 +124,9 @@ docker run -d -v ~/.aws-lambda-rie:/aws-lambda -p 9000:8080 \ /usr/local/bin/python -m awslambdaric app.handler ``` -This runs the image as a container and starts up an endpoint locally at `http://localhost:9000/2015-03-31/functions/function/invocations`. +This runs the image as a container and starts up an endpoint locally at `http://localhost:9000/2015-03-31/functions/function/invocations`. -3) Post an event to the following endpoint using a curl command: +3) Post an event to the following endpoint using a curl command: ```shell script curl -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{}' @@ -175,4 +175,4 @@ If you discover a potential security issue in this project we ask that you notif ## License -This project is licensed under the Apache-2.0 License. \ No newline at end of file +This project is licensed under the Apache-2.0 License. diff --git a/setup.py b/setup.py index a005074..edbd8d8 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,9 @@ import os import platform from subprocess import check_call, check_output + from setuptools import Extension, find_packages, setup + from awslambdaric import __version__ @@ -88,6 +90,8 @@ def read_requirements(req="base.txt"): "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", "License :: OSI Approved :: Apache Software License", "Operating System :: OS Independent", ], diff --git a/tests/integration/codebuild/buildspec.os.alpine.yml b/tests/integration/codebuild/buildspec.os.alpine.yml index f938447..eba1d14 100644 --- a/tests/integration/codebuild/buildspec.os.alpine.yml +++ b/tests/integration/codebuild/buildspec.os.alpine.yml @@ -22,6 +22,8 @@ batch: - "3.7" - "3.8" - "3.9" + - "3.10" + - "3.11" phases: pre_build: commands: diff --git a/tests/integration/codebuild/buildspec.os.amazonlinux.1.yml b/tests/integration/codebuild/buildspec.os.amazonlinux.1.yml index a5cd1bc..5ec01d2 100644 --- a/tests/integration/codebuild/buildspec.os.amazonlinux.1.yml +++ b/tests/integration/codebuild/buildspec.os.amazonlinux.1.yml @@ -20,6 +20,8 @@ batch: - "3.7" - "3.8" - "3.9" + - "3.10" + - "3.11" phases: pre_build: commands: @@ -98,4 +100,4 @@ phases: - docker rm --force "${TEST_NAME}-app" || true - docker stop "${TEST_NAME}-tester" || true - docker rm --force "${TEST_NAME}-tester" || true - - docker network rm "${TEST_NAME}-network" || true \ No newline at end of file + - docker network rm "${TEST_NAME}-network" || true diff --git a/tests/integration/codebuild/buildspec.os.amazonlinux.2.yml b/tests/integration/codebuild/buildspec.os.amazonlinux.2.yml index 4ce4b1f..18cabc9 100644 --- a/tests/integration/codebuild/buildspec.os.amazonlinux.2.yml +++ b/tests/integration/codebuild/buildspec.os.amazonlinux.2.yml @@ -20,6 +20,8 @@ batch: - "3.7" - "3.8" - "3.9" + - "3.10" + - "3.11" phases: pre_build: commands: @@ -107,4 +109,4 @@ phases: - docker rm --force "${TEST_NAME}-app" || true - docker stop "${TEST_NAME}-tester" || true - docker rm --force "${TEST_NAME}-tester" || true - - docker network rm "${TEST_NAME}-network" || true \ No newline at end of file + - docker network rm "${TEST_NAME}-network" || true diff --git a/tests/integration/codebuild/buildspec.os.centos.yml b/tests/integration/codebuild/buildspec.os.centos.yml index 900860e..f993c7d 100644 --- a/tests/integration/codebuild/buildspec.os.centos.yml +++ b/tests/integration/codebuild/buildspec.os.centos.yml @@ -20,6 +20,8 @@ batch: - "3.7" - "3.8" - "3.9" + - "3.10" + - "3.11" phases: pre_build: commands: @@ -107,4 +109,4 @@ phases: - docker rm --force "${TEST_NAME}-app" || true - docker stop "${TEST_NAME}-tester" || true - docker rm --force "${TEST_NAME}-tester" || true - - docker network rm "${TEST_NAME}-network" || true \ No newline at end of file + - docker network rm "${TEST_NAME}-network" || true diff --git a/tests/integration/codebuild/buildspec.os.debian.yml b/tests/integration/codebuild/buildspec.os.debian.yml index a9187f5..48305bb 100644 --- a/tests/integration/codebuild/buildspec.os.debian.yml +++ b/tests/integration/codebuild/buildspec.os.debian.yml @@ -21,6 +21,8 @@ batch: - "3.7" - "3.8" - "3.9" + - "3.10" + - "3.11" phases: pre_build: commands: @@ -110,4 +112,4 @@ phases: - docker rm --force "${TEST_NAME}-app" || true - docker stop "${TEST_NAME}-tester" || true - docker rm --force "${TEST_NAME}-tester" || true - - docker network rm "${TEST_NAME}-network" || true \ No newline at end of file + - docker network rm "${TEST_NAME}-network" || true diff --git a/tests/integration/codebuild/buildspec.os.ubuntu.yml b/tests/integration/codebuild/buildspec.os.ubuntu.yml index 8a882a8..7c66865 100644 --- a/tests/integration/codebuild/buildspec.os.ubuntu.yml +++ b/tests/integration/codebuild/buildspec.os.ubuntu.yml @@ -21,6 +21,8 @@ batch: - "3.7" - "3.8" - "3.9" + - "3.10" + - "3.11" phases: pre_build: commands: @@ -108,4 +110,4 @@ phases: - docker rm --force "${TEST_NAME}-app" || true - docker stop "${TEST_NAME}-tester" || true - docker rm --force "${TEST_NAME}-tester" || true - - docker network rm "${TEST_NAME}-network" || true \ No newline at end of file + - docker network rm "${TEST_NAME}-network" || true diff --git a/tests/test_bootstrap.py b/tests/test_bootstrap.py index 777625e..5c6a08c 100644 --- a/tests/test_bootstrap.py +++ b/tests/test_bootstrap.py @@ -585,10 +585,10 @@ def raise_exception_handler(json_input, lambda_context): self.assertEqual(mock_stdout.getvalue(), error_logs) - @patch("sys.stdout", new_callable=StringIO) @patch("importlib.import_module") + @patch("sys.stdout", new_callable=StringIO) def test_handle_event_request_fault_exception_logging_syntax_error( - self, mock_import_module, mock_stdout + self, mock_stdout, mock_import_module ): try: eval("-") @@ -616,10 +616,17 @@ def test_handle_event_request_fault_exception_logging_syntax_error( sys.stderr.write(mock_stdout.getvalue()) - error_logs = ( - "[ERROR] Runtime.UserCodeSyntaxError: Syntax error in module 'a': " - "unexpected EOF while parsing (, line 1)\r" - ) + if sys.version_info < (3, 10): + error_logs = ( + "[ERROR] Runtime.UserCodeSyntaxError: Syntax error in module 'a': " + "unexpected EOF while parsing (, line 1)\r" + ) + else: + error_logs = ( + "[ERROR] Runtime.UserCodeSyntaxError: Syntax error in module 'a': " + "invalid syntax (, line 1)\r" + ) + error_logs += "Traceback (most recent call last):\r" error_logs += '  File "" Line 1\r' error_logs += "    -\n"