From 8481d29526dd43280f90470a0bc758f464647041 Mon Sep 17 00:00:00 2001 From: Anton Pirker Date: Fri, 1 Apr 2022 14:01:32 +0200 Subject: [PATCH 01/15] ci(ci): Cleanup --- .github/workflows/ci.yml | 104 ++++++++++++++++++++------------------- 1 file changed, 53 insertions(+), 51 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8850aaddc7..c186a2d096 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -name: ci +name: CI on: push: @@ -9,54 +9,10 @@ on: pull_request: jobs: - dist: - name: distribution packages - timeout-minutes: 10 - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 - - uses: actions/setup-python@v2 - with: - python-version: 3.9 - - - run: | - pip install virtualenv - make aws-lambda-layer-build - - - uses: actions/upload-artifact@v2 - with: - name: ${{ github.sha }} - path: | - dist/* - dist-serverless/* - - docs: - timeout-minutes: 10 - name: build documentation - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 - - uses: actions/setup-python@v2 - with: - python-version: 3.9 - - - run: | - pip install virtualenv - make apidocs - cd docs/_build && zip -r gh-pages ./ - - - uses: actions/upload-artifact@v2 - with: - name: ${{ github.sha }} - path: docs/_build/gh-pages.zip - lint: - timeout-minutes: 10 + name: Lint Sources runs-on: ubuntu-latest + timeout-minutes: 10 steps: - uses: actions/checkout@v2 @@ -69,9 +25,10 @@ jobs: tox -e linters test: - continue-on-error: true - timeout-minutes: 45 + name: Run Tests runs-on: ${{ matrix.linux-version }} + timeout-minutes: 45 + continue-on-error: true strategy: matrix: linux-version: [ubuntu-latest] @@ -125,7 +82,7 @@ jobs: with: python-version: ${{ matrix.python-version }} - - name: setup + - name: Setup Test Env env: PGHOST: localhost PGPASSWORD: sentry @@ -134,7 +91,7 @@ jobs: psql -c 'create database test_travis_ci_test;' -U postgres pip install codecov tox - - name: run tests + - name: Run Tests env: CI_PYTHON_VERSION: ${{ matrix.python-version }} timeout-minutes: 45 @@ -144,3 +101,48 @@ jobs: coverage combine .coverage* coverage xml -i codecov --file coverage.xml + + dist: + name: Build AWS Lambda Layer + runs-on: ubuntu-latest + timeout-minutes: 10 + + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + - uses: actions/setup-python@v2 + with: + python-version: 3.9 + + - run: | + pip install virtualenv + make aws-lambda-layer-build + + - uses: actions/upload-artifact@v2 + with: + name: ${{ github.sha }} + path: | + dist/* + dist-serverless/* + + docs: + name: Build SDK API Doc + runs-on: ubuntu-latest + timeout-minutes: 10 + + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + - uses: actions/setup-python@v2 + with: + python-version: 3.9 + + - run: | + pip install virtualenv + make apidocs + cd docs/_build && zip -r gh-pages ./ + + - uses: actions/upload-artifact@v2 + with: + name: ${{ github.sha }} + path: docs/_build/gh-pages.zip From 75ed77abb17c1af2ed30384b0103df36e4d0d8db Mon Sep 17 00:00:00 2001 From: Anton Pirker Date: Fri, 1 Apr 2022 14:24:43 +0200 Subject: [PATCH 02/15] ci(lambda-extension): Use new GitHub action for creating zip. --- .github/workflows/ci.yml | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c186a2d096..d3b784b726 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -118,12 +118,22 @@ jobs: pip install virtualenv make aws-lambda-layer-build - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v3 with: - name: ${{ github.sha }} + name: prepared-lambda-layer-${{ github.sha }} path: | dist/* - dist-serverless/* + + - uses: getsentry/action-build-aws-lambda-extension@v1 + with: + artifact_name: prepared-lambda-layer-${{ github.sha }} + zip_file_name: sentry-python-serverless-X.X.X.zip + + - name: Upload Zip + uses: actions/upload-artifact@v3 + with: + name: ${{ github.sha }} + path: sentry-python-serverless-X.X.X.zip docs: name: Build SDK API Doc From 9652e1d506ac251e84444c6e1b0fd36fa80a58c2 Mon Sep 17 00:00:00 2001 From: Anton Pirker Date: Tue, 5 Apr 2022 12:38:59 +0200 Subject: [PATCH 03/15] Renamed function --- scripts/build_awslambda_layer.py | 4 ++-- tests/integrations/aws_lambda/client.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/build_awslambda_layer.py b/scripts/build_awslambda_layer.py index 1fda06e79f..5f571d04a1 100644 --- a/scripts/build_awslambda_layer.py +++ b/scripts/build_awslambda_layer.py @@ -89,7 +89,7 @@ def get_relative_path_of( # Placing the Sentry package in `/python` avoids # creating a directory for a specific version. For more information, see # https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html#configuration-layers-path -def build_packaged_zip( +def build_layer_dir( dist_rel_path="dist", # type: str dest_zip_filename=f"sentry-python-serverless-{SDK_VERSION}.zip", # type: str pkg_parent_dir="python", # type: str @@ -114,4 +114,4 @@ def build_packaged_zip( if __name__ == "__main__": - build_packaged_zip() + build_layer_dir() diff --git a/tests/integrations/aws_lambda/client.py b/tests/integrations/aws_lambda/client.py index 784a4a9006..6fd53641f0 100644 --- a/tests/integrations/aws_lambda/client.py +++ b/tests/integrations/aws_lambda/client.py @@ -26,10 +26,10 @@ def build_no_code_serverless_function_and_layer( that uses that layer """ from scripts.build_awslambda_layer import ( - build_packaged_zip, + build_layer_dir, ) - build_packaged_zip(dest_abs_path=tmpdir, dest_zip_filename="serverless-ball.zip") + build_layer_dir(dest_abs_path=tmpdir, dest_zip_filename="serverless-ball.zip") with open(os.path.join(tmpdir, "serverless-ball.zip"), "rb") as serverless_zip: response = client.publish_layer_version( From 9f3098c05914c04828e679851b4d05a97eeadd7a Mon Sep 17 00:00:00 2001 From: Anton Pirker Date: Tue, 5 Apr 2022 12:40:23 +0200 Subject: [PATCH 04/15] Removed zip functionality --- scripts/build_awslambda_layer.py | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/scripts/build_awslambda_layer.py b/scripts/build_awslambda_layer.py index 5f571d04a1..ef28ddb983 100644 --- a/scripts/build_awslambda_layer.py +++ b/scripts/build_awslambda_layer.py @@ -60,24 +60,6 @@ def create_init_serverless_sdk_package(self): "scripts/init_serverless_sdk.py", f"{serverless_sdk_path}/__init__.py" ) - def zip( - self, filename # type: str - ): - # type: (...) -> None - subprocess.run( - [ - "zip", - "-q", # Quiet - "-x", # Exclude files - "**/__pycache__/*", # Files to be excluded - "-r", # Recurse paths - filename, # Output filename - self.pkg_parent_dir, # Files to be zipped - ], - cwd=self.base_dir, - check=True, # Raises CalledProcessError if exit status is non-zero - ) - def get_relative_path_of( self, subfile # type: str ): @@ -105,7 +87,6 @@ def build_layer_dir( package_builder.make_directories() package_builder.install_python_binaries() package_builder.create_init_serverless_sdk_package() - package_builder.zip(dest_zip_filename) if not os.path.exists(dist_rel_path): os.makedirs(dist_rel_path) shutil.copy( From c029e1c665db25baa2cb02d3ce7bad2d1c7a824f Mon Sep 17 00:00:00 2001 From: Anton Pirker Date: Tue, 5 Apr 2022 12:43:14 +0200 Subject: [PATCH 05/15] Removed zip file parameter --- scripts/build_awslambda_layer.py | 4 ---- tests/integrations/aws_lambda/client.py | 6 ++---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/scripts/build_awslambda_layer.py b/scripts/build_awslambda_layer.py index ef28ddb983..7f1bade873 100644 --- a/scripts/build_awslambda_layer.py +++ b/scripts/build_awslambda_layer.py @@ -73,7 +73,6 @@ def get_relative_path_of( # https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html#configuration-layers-path def build_layer_dir( dist_rel_path="dist", # type: str - dest_zip_filename=f"sentry-python-serverless-{SDK_VERSION}.zip", # type: str pkg_parent_dir="python", # type: str dest_abs_path=None, # type: Union[str, None] ): @@ -89,9 +88,6 @@ def build_layer_dir( package_builder.create_init_serverless_sdk_package() if not os.path.exists(dist_rel_path): os.makedirs(dist_rel_path) - shutil.copy( - package_builder.get_relative_path_of(dest_zip_filename), dest_abs_path - ) if __name__ == "__main__": diff --git a/tests/integrations/aws_lambda/client.py b/tests/integrations/aws_lambda/client.py index 6fd53641f0..fcaa5c5799 100644 --- a/tests/integrations/aws_lambda/client.py +++ b/tests/integrations/aws_lambda/client.py @@ -25,11 +25,9 @@ def build_no_code_serverless_function_and_layer( sdk by creating a layer containing the Python-sdk, and then creating a func that uses that layer """ - from scripts.build_awslambda_layer import ( - build_layer_dir, - ) + from scripts.build_awslambda_layer import build_layer_dir - build_layer_dir(dest_abs_path=tmpdir, dest_zip_filename="serverless-ball.zip") + build_layer_dir(dest_abs_path=tmpdir) with open(os.path.join(tmpdir, "serverless-ball.zip"), "rb") as serverless_zip: response = client.publish_layer_version( From 9ce76994cf9e57edafd10940b637ee00846e5590 Mon Sep 17 00:00:00 2001 From: Anton Pirker Date: Tue, 5 Apr 2022 13:49:37 +0200 Subject: [PATCH 06/15] Refactored layer directory generation. --- scripts/build_awslambda_layer.py | 59 ++++++++++---------------------- 1 file changed, 18 insertions(+), 41 deletions(-) diff --git a/scripts/build_awslambda_layer.py b/scripts/build_awslambda_layer.py index 7f1bade873..9c5274c745 100644 --- a/scripts/build_awslambda_layer.py +++ b/scripts/build_awslambda_layer.py @@ -1,36 +1,33 @@ import os +import shutil import subprocess import tempfile -import shutil from sentry_sdk.consts import VERSION as SDK_VERSION -from sentry_sdk._types import MYPY -if MYPY: - from typing import Union +DIST_PATH = ( + "dist" # created by "make dist, that is called by make aws-lambda-layer-build" +) +PYTHON_SITE_PACKAGES = "python" # see https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html#configuration-layers-path -class PackageBuilder: +class LayerBuilder: def __init__( self, base_dir, # type: str - pkg_parent_dir, # type: str - dist_rel_path, # type: str ): # type: (...) -> None self.base_dir = base_dir - self.pkg_parent_dir = pkg_parent_dir - self.dist_rel_path = dist_rel_path - self.packages_dir = self.get_relative_path_of(pkg_parent_dir) + self.python_site_packages = os.path.join(self.base_dir, PYTHON_SITE_PACKAGES) def make_directories(self): # type: (...) -> None - os.makedirs(self.packages_dir) + os.makedirs(self.python_site_packages) def install_python_binaries(self): # type: (...) -> None wheels_filepath = os.path.join( - self.dist_rel_path, f"sentry_sdk-{SDK_VERSION}-py2.py3-none-any.whl" + DIST_PATH, f"sentry_sdk-{SDK_VERSION}-py2.py3-none-any.whl" ) subprocess.run( [ @@ -40,7 +37,7 @@ def install_python_binaries(self): "-q", # Quiet wheels_filepath, # Copied to the target directory before installation "-t", # Target directory flag - self.packages_dir, + self.python_site_packages, ], check=True, ) @@ -52,7 +49,8 @@ def create_init_serverless_sdk_package(self): sentry-python-serverless zip """ serverless_sdk_path = ( - f"{self.packages_dir}/sentry_sdk/" f"integrations/init_serverless_sdk" + f"{self.python_site_packages}/sentry_sdk/" + f"integrations/init_serverless_sdk" ) if not os.path.exists(serverless_sdk_path): os.makedirs(serverless_sdk_path) @@ -60,34 +58,13 @@ def create_init_serverless_sdk_package(self): "scripts/init_serverless_sdk.py", f"{serverless_sdk_path}/__init__.py" ) - def get_relative_path_of( - self, subfile # type: str - ): - # type: (...) -> str - return os.path.join(self.base_dir, subfile) - -# Ref to `pkg_parent_dir` Top directory in the ZIP file. -# Placing the Sentry package in `/python` avoids -# creating a directory for a specific version. For more information, see -# https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html#configuration-layers-path -def build_layer_dir( - dist_rel_path="dist", # type: str - pkg_parent_dir="python", # type: str - dest_abs_path=None, # type: Union[str, None] -): - # type: (...) -> None - if dest_abs_path is None: - dest_abs_path = os.path.abspath( - os.path.join(os.path.dirname(__file__), "..", dist_rel_path) - ) - with tempfile.TemporaryDirectory() as tmp_dir: - package_builder = PackageBuilder(tmp_dir, pkg_parent_dir, dist_rel_path) - package_builder.make_directories() - package_builder.install_python_binaries() - package_builder.create_init_serverless_sdk_package() - if not os.path.exists(dist_rel_path): - os.makedirs(dist_rel_path) +def build_layer_dir(): + with tempfile.TemporaryDirectory() as base_dir: + layer_builder = LayerBuilder(base_dir) + layer_builder.make_directories() + layer_builder.install_python_binaries() + layer_builder.create_init_serverless_sdk_package() if __name__ == "__main__": From 10d28857514285fbd0ca8279e7fabd41a03f1730 Mon Sep 17 00:00:00 2001 From: Anton Pirker Date: Tue, 5 Apr 2022 14:19:26 +0200 Subject: [PATCH 07/15] Cleanup --- .github/workflows/ci.yml | 2 ++ scripts/build_awslambda_layer.py | 20 ++++++++++++-------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d3b784b726..4d7b1323cf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -117,12 +117,14 @@ jobs: - run: | pip install virtualenv make aws-lambda-layer-build + # TODO: xxx !!! rename to make aws-lambda-layer - uses: actions/upload-artifact@v3 with: name: prepared-lambda-layer-${{ github.sha }} path: | dist/* + # TODO: xxx !!! MAKE SURE TO PICK UP DIST FOLDER FROM make aws-lambda-layer-build - uses: getsentry/action-build-aws-lambda-extension@v1 with: diff --git a/scripts/build_awslambda_layer.py b/scripts/build_awslambda_layer.py index 9c5274c745..754cafae65 100644 --- a/scripts/build_awslambda_layer.py +++ b/scripts/build_awslambda_layer.py @@ -24,19 +24,20 @@ def make_directories(self): # type: (...) -> None os.makedirs(self.python_site_packages) - def install_python_binaries(self): + def install_python_packages(self): # type: (...) -> None - wheels_filepath = os.path.join( - DIST_PATH, f"sentry_sdk-{SDK_VERSION}-py2.py3-none-any.whl" + sentry_python_sdk = os.path.join( + DIST_PATH, + f"sentry_sdk-{SDK_VERSION}-py2.py3-none-any.whl", # this is generated by "make dist" that is called by "make aws-lamber-layer" ) subprocess.run( [ "pip", "install", - "--no-cache-dir", # Disables the cache -> always accesses PyPI - "-q", # Quiet - wheels_filepath, # Copied to the target directory before installation - "-t", # Target directory flag + "--no-cache-dir", # always access PyPI + "--quiet", + sentry_python_sdk, + "--target", self.python_site_packages, ], check=True, @@ -63,9 +64,12 @@ def build_layer_dir(): with tempfile.TemporaryDirectory() as base_dir: layer_builder = LayerBuilder(base_dir) layer_builder.make_directories() - layer_builder.install_python_binaries() + layer_builder.install_python_packages() layer_builder.create_init_serverless_sdk_package() + # TODO: move whole directory to a dist folder somewhere. + # TODO: rename file to build_aws_lambda_layer.py + if __name__ == "__main__": build_layer_dir() From 3f2fee0249a0ce4ffeee6fe5c62f0f1555e7e8aa Mon Sep 17 00:00:00 2001 From: Anton Pirker Date: Tue, 5 Apr 2022 14:25:49 +0200 Subject: [PATCH 08/15] Consistent naming --- .github/workflows/ci.yml | 5 ++--- Makefile | 8 ++++---- ...build_awslambda_layer.py => build_aws_lambda_layer.py} | 5 +---- tests/integrations/aws_lambda/client.py | 2 +- 4 files changed, 8 insertions(+), 12 deletions(-) rename scripts/{build_awslambda_layer.py => build_aws_lambda_layer.py} (93%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4d7b1323cf..4b9aa1879c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -116,15 +116,14 @@ jobs: - run: | pip install virtualenv - make aws-lambda-layer-build - # TODO: xxx !!! rename to make aws-lambda-layer + make aws-lambda-layer - uses: actions/upload-artifact@v3 with: name: prepared-lambda-layer-${{ github.sha }} path: | dist/* - # TODO: xxx !!! MAKE SURE TO PICK UP DIST FOLDER FROM make aws-lambda-layer-build + # TODO: xxx !!! MAKE SURE TO PICK UP DIST FOLDER FROM make aws-lambda-layer - uses: getsentry/action-build-aws-lambda-extension@v1 with: diff --git a/Makefile b/Makefile index 577dd58740..d335f6f4df 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ help: @echo "make test: Run basic tests (not testing most integrations)" @echo "make test-all: Run ALL tests (slow, closest to CI)" @echo "make format: Run code formatters (destructive)" - @echo "make aws-lambda-layer-build: Build serverless ZIP dist package" + @echo "make aws-lambda-layer: Build AWS Lambda layer directorzy for serverless integration" @echo @echo "Also make sure to read ./CONTRIBUTING.md" @false @@ -60,8 +60,8 @@ apidocs-hotfix: apidocs @$(VENV_PATH)/bin/ghp-import -pf docs/_build .PHONY: apidocs-hotfix -aws-lambda-layer-build: dist +aws-lambda-layer: dist $(VENV_PATH)/bin/pip install urllib3 $(VENV_PATH)/bin/pip install certifi - $(VENV_PATH)/bin/python -m scripts.build_awslambda_layer -.PHONY: aws-lambda-layer-build + $(VENV_PATH)/bin/python -m scripts.build_aws_lambda_layer +.PHONY: aws-lambda-layer diff --git a/scripts/build_awslambda_layer.py b/scripts/build_aws_lambda_layer.py similarity index 93% rename from scripts/build_awslambda_layer.py rename to scripts/build_aws_lambda_layer.py index 754cafae65..b456a3ae5e 100644 --- a/scripts/build_awslambda_layer.py +++ b/scripts/build_aws_lambda_layer.py @@ -5,9 +5,7 @@ from sentry_sdk.consts import VERSION as SDK_VERSION -DIST_PATH = ( - "dist" # created by "make dist, that is called by make aws-lambda-layer-build" -) +DIST_PATH = "dist" # created by "make dist" that is called by "make aws-lambda-layer" PYTHON_SITE_PACKAGES = "python" # see https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html#configuration-layers-path @@ -68,7 +66,6 @@ def build_layer_dir(): layer_builder.create_init_serverless_sdk_package() # TODO: move whole directory to a dist folder somewhere. - # TODO: rename file to build_aws_lambda_layer.py if __name__ == "__main__": diff --git a/tests/integrations/aws_lambda/client.py b/tests/integrations/aws_lambda/client.py index fcaa5c5799..d8e430f3d7 100644 --- a/tests/integrations/aws_lambda/client.py +++ b/tests/integrations/aws_lambda/client.py @@ -25,7 +25,7 @@ def build_no_code_serverless_function_and_layer( sdk by creating a layer containing the Python-sdk, and then creating a func that uses that layer """ - from scripts.build_awslambda_layer import build_layer_dir + from scripts.build_aws_lambda_layer import build_layer_dir build_layer_dir(dest_abs_path=tmpdir) From 2eebc7e4b4ad1f9de1c3f294f168fb399914a98e Mon Sep 17 00:00:00 2001 From: Anton Pirker Date: Tue, 5 Apr 2022 14:29:05 +0200 Subject: [PATCH 09/15] Cleanup --- Makefile | 2 -- 1 file changed, 2 deletions(-) diff --git a/Makefile b/Makefile index d335f6f4df..c9eda1f2f1 100644 --- a/Makefile +++ b/Makefile @@ -21,7 +21,6 @@ help: dist: .venv rm -rf dist build $(VENV_PATH)/bin/python setup.py sdist bdist_wheel - .PHONY: dist format: .venv @@ -46,7 +45,6 @@ lint: .venv echo "Bad formatting? Run: make format"; \ echo "================================"; \ false) - .PHONY: lint apidocs: .venv From e7604c04046e9253bd9d96050ce445268132e86c Mon Sep 17 00:00:00 2001 From: Anton Pirker Date: Tue, 5 Apr 2022 14:55:24 +0200 Subject: [PATCH 10/15] Making sure dist-serverless is the directory the layer ends up in --- .github/workflows/ci.yml | 3 +-- Makefile | 2 +- scripts/build_aws_lambda_layer.py | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4b9aa1879c..995f30de79 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -122,8 +122,7 @@ jobs: with: name: prepared-lambda-layer-${{ github.sha }} path: | - dist/* - # TODO: xxx !!! MAKE SURE TO PICK UP DIST FOLDER FROM make aws-lambda-layer + dist-serverless/* - uses: getsentry/action-build-aws-lambda-extension@v1 with: diff --git a/Makefile b/Makefile index c9eda1f2f1..a379e39bd8 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,7 @@ help: $(VENV_PATH)/bin/pip install tox dist: .venv - rm -rf dist build + rm -rf dist dist-serverless build $(VENV_PATH)/bin/python setup.py sdist bdist_wheel .PHONY: dist diff --git a/scripts/build_aws_lambda_layer.py b/scripts/build_aws_lambda_layer.py index b456a3ae5e..d694d15ba7 100644 --- a/scripts/build_aws_lambda_layer.py +++ b/scripts/build_aws_lambda_layer.py @@ -65,7 +65,7 @@ def build_layer_dir(): layer_builder.install_python_packages() layer_builder.create_init_serverless_sdk_package() - # TODO: move whole directory to a dist folder somewhere. + shutil.copytree(base_dir, "dist-serverless") if __name__ == "__main__": From e88b72fe80213c47bd2c7b50819bf7faa1edd75c Mon Sep 17 00:00:00 2001 From: Anton Pirker Date: Tue, 5 Apr 2022 15:17:37 +0200 Subject: [PATCH 11/15] Fixed upload name. --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 995f30de79..5b91082672 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -120,13 +120,13 @@ jobs: - uses: actions/upload-artifact@v3 with: - name: prepared-lambda-layer-${{ github.sha }} + name: ${{ github.sha }} path: | dist-serverless/* - uses: getsentry/action-build-aws-lambda-extension@v1 with: - artifact_name: prepared-lambda-layer-${{ github.sha }} + artifact_name: ${{ github.sha }} zip_file_name: sentry-python-serverless-X.X.X.zip - name: Upload Zip From 2cb8a4471ae75c9708f7e699e0c833191d81b481 Mon Sep 17 00:00:00 2001 From: Anton Pirker Date: Tue, 5 Apr 2022 17:28:44 +0200 Subject: [PATCH 12/15] Disabled long running actions --- .github/workflows/ci.yml | 156 ++++++++++++++++++++------------------- 1 file changed, 79 insertions(+), 77 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5b91082672..edaeb83a65 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,83 +24,83 @@ jobs: pip install tox tox -e linters - test: - name: Run Tests - runs-on: ${{ matrix.linux-version }} - timeout-minutes: 45 - continue-on-error: true - strategy: - matrix: - linux-version: [ubuntu-latest] - python-version: ["2.7", "3.5", "3.6", "3.7", "3.8", "3.9", "3.10"] - include: - # GHA doesn't host the combo of python 3.4 and ubuntu-latest (which is - # currently 20.04), so run just that one under 18.04. (See - # https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json - # for a listing of supported python/os combos.) - - linux-version: ubuntu-18.04 - python-version: "3.4" - - services: - # Label used to access the service container - redis: - # Docker Hub image - image: redis - # Set health checks to wait until redis has started - options: >- - --health-cmd "redis-cli ping" - --health-interval 10s - --health-timeout 5s - --health-retries 5 - ports: - # Maps port 6379 on service container to the host - - 6379:6379 - - postgres: - image: postgres - env: - POSTGRES_PASSWORD: sentry - # Set health checks to wait until postgres has started - options: >- - --health-cmd pg_isready - --health-interval 10s - --health-timeout 5s - --health-retries 5 - # Maps tcp port 5432 on service container to the host - ports: - - 5432:5432 - - env: - SENTRY_PYTHON_TEST_POSTGRES_USER: postgres - SENTRY_PYTHON_TEST_POSTGRES_PASSWORD: sentry - SENTRY_PYTHON_TEST_POSTGRES_NAME: ci_test - - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 - - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - - name: Setup Test Env - env: - PGHOST: localhost - PGPASSWORD: sentry - run: | - psql -c 'create database travis_ci_test;' -U postgres - psql -c 'create database test_travis_ci_test;' -U postgres - pip install codecov tox - - - name: Run Tests - env: - CI_PYTHON_VERSION: ${{ matrix.python-version }} - timeout-minutes: 45 - run: | - coverage erase - ./scripts/runtox.sh '' --cov=tests --cov=sentry_sdk --cov-report= --cov-branch - coverage combine .coverage* - coverage xml -i - codecov --file coverage.xml + # test: + # name: Run Tests + # runs-on: ${{ matrix.linux-version }} + # timeout-minutes: 45 + # continue-on-error: true + # strategy: + # matrix: + # linux-version: [ubuntu-latest] + # python-version: ["2.7", "3.5", "3.6", "3.7", "3.8", "3.9", "3.10"] + # include: + # # GHA doesn't host the combo of python 3.4 and ubuntu-latest (which is + # # currently 20.04), so run just that one under 18.04. (See + # # https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json + # # for a listing of supported python/os combos.) + # - linux-version: ubuntu-18.04 + # python-version: "3.4" + + # services: + # # Label used to access the service container + # redis: + # # Docker Hub image + # image: redis + # # Set health checks to wait until redis has started + # options: >- + # --health-cmd "redis-cli ping" + # --health-interval 10s + # --health-timeout 5s + # --health-retries 5 + # ports: + # # Maps port 6379 on service container to the host + # - 6379:6379 + + # postgres: + # image: postgres + # env: + # POSTGRES_PASSWORD: sentry + # # Set health checks to wait until postgres has started + # options: >- + # --health-cmd pg_isready + # --health-interval 10s + # --health-timeout 5s + # --health-retries 5 + # # Maps tcp port 5432 on service container to the host + # ports: + # - 5432:5432 + + # env: + # SENTRY_PYTHON_TEST_POSTGRES_USER: postgres + # SENTRY_PYTHON_TEST_POSTGRES_PASSWORD: sentry + # SENTRY_PYTHON_TEST_POSTGRES_NAME: ci_test + + # steps: + # - uses: actions/checkout@v2 + # - uses: actions/setup-node@v1 + # - uses: actions/setup-python@v2 + # with: + # python-version: ${{ matrix.python-version }} + + # - name: Setup Test Env + # env: + # PGHOST: localhost + # PGPASSWORD: sentry + # run: | + # psql -c 'create database travis_ci_test;' -U postgres + # psql -c 'create database test_travis_ci_test;' -U postgres + # pip install codecov tox + + # - name: Run Tests + # env: + # CI_PYTHON_VERSION: ${{ matrix.python-version }} + # timeout-minutes: 45 + # run: | + # coverage erase + # ./scripts/runtox.sh '' --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + # coverage combine .coverage* + # coverage xml -i + # codecov --file coverage.xml dist: name: Build AWS Lambda Layer @@ -117,6 +117,8 @@ jobs: - run: | pip install virtualenv make aws-lambda-layer + echo "after make:" + ls -alh dist-serverless - uses: actions/upload-artifact@v3 with: From 495558bb72d7d170b2ab5198e501f08205943ef0 Mon Sep 17 00:00:00 2001 From: Anton Pirker Date: Wed, 6 Apr 2022 10:02:40 +0200 Subject: [PATCH 13/15] Cleanup --- .github/workflows/ci.yml | 156 +++++++++++++++++++-------------------- 1 file changed, 77 insertions(+), 79 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index edaeb83a65..5b91082672 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,83 +24,83 @@ jobs: pip install tox tox -e linters - # test: - # name: Run Tests - # runs-on: ${{ matrix.linux-version }} - # timeout-minutes: 45 - # continue-on-error: true - # strategy: - # matrix: - # linux-version: [ubuntu-latest] - # python-version: ["2.7", "3.5", "3.6", "3.7", "3.8", "3.9", "3.10"] - # include: - # # GHA doesn't host the combo of python 3.4 and ubuntu-latest (which is - # # currently 20.04), so run just that one under 18.04. (See - # # https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json - # # for a listing of supported python/os combos.) - # - linux-version: ubuntu-18.04 - # python-version: "3.4" - - # services: - # # Label used to access the service container - # redis: - # # Docker Hub image - # image: redis - # # Set health checks to wait until redis has started - # options: >- - # --health-cmd "redis-cli ping" - # --health-interval 10s - # --health-timeout 5s - # --health-retries 5 - # ports: - # # Maps port 6379 on service container to the host - # - 6379:6379 - - # postgres: - # image: postgres - # env: - # POSTGRES_PASSWORD: sentry - # # Set health checks to wait until postgres has started - # options: >- - # --health-cmd pg_isready - # --health-interval 10s - # --health-timeout 5s - # --health-retries 5 - # # Maps tcp port 5432 on service container to the host - # ports: - # - 5432:5432 - - # env: - # SENTRY_PYTHON_TEST_POSTGRES_USER: postgres - # SENTRY_PYTHON_TEST_POSTGRES_PASSWORD: sentry - # SENTRY_PYTHON_TEST_POSTGRES_NAME: ci_test - - # steps: - # - uses: actions/checkout@v2 - # - uses: actions/setup-node@v1 - # - uses: actions/setup-python@v2 - # with: - # python-version: ${{ matrix.python-version }} - - # - name: Setup Test Env - # env: - # PGHOST: localhost - # PGPASSWORD: sentry - # run: | - # psql -c 'create database travis_ci_test;' -U postgres - # psql -c 'create database test_travis_ci_test;' -U postgres - # pip install codecov tox - - # - name: Run Tests - # env: - # CI_PYTHON_VERSION: ${{ matrix.python-version }} - # timeout-minutes: 45 - # run: | - # coverage erase - # ./scripts/runtox.sh '' --cov=tests --cov=sentry_sdk --cov-report= --cov-branch - # coverage combine .coverage* - # coverage xml -i - # codecov --file coverage.xml + test: + name: Run Tests + runs-on: ${{ matrix.linux-version }} + timeout-minutes: 45 + continue-on-error: true + strategy: + matrix: + linux-version: [ubuntu-latest] + python-version: ["2.7", "3.5", "3.6", "3.7", "3.8", "3.9", "3.10"] + include: + # GHA doesn't host the combo of python 3.4 and ubuntu-latest (which is + # currently 20.04), so run just that one under 18.04. (See + # https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json + # for a listing of supported python/os combos.) + - linux-version: ubuntu-18.04 + python-version: "3.4" + + services: + # Label used to access the service container + redis: + # Docker Hub image + image: redis + # Set health checks to wait until redis has started + options: >- + --health-cmd "redis-cli ping" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + # Maps port 6379 on service container to the host + - 6379:6379 + + postgres: + image: postgres + env: + POSTGRES_PASSWORD: sentry + # Set health checks to wait until postgres has started + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + # Maps tcp port 5432 on service container to the host + ports: + - 5432:5432 + + env: + SENTRY_PYTHON_TEST_POSTGRES_USER: postgres + SENTRY_PYTHON_TEST_POSTGRES_PASSWORD: sentry + SENTRY_PYTHON_TEST_POSTGRES_NAME: ci_test + + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + - uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + - name: Setup Test Env + env: + PGHOST: localhost + PGPASSWORD: sentry + run: | + psql -c 'create database travis_ci_test;' -U postgres + psql -c 'create database test_travis_ci_test;' -U postgres + pip install codecov tox + + - name: Run Tests + env: + CI_PYTHON_VERSION: ${{ matrix.python-version }} + timeout-minutes: 45 + run: | + coverage erase + ./scripts/runtox.sh '' --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + coverage combine .coverage* + coverage xml -i + codecov --file coverage.xml dist: name: Build AWS Lambda Layer @@ -117,8 +117,6 @@ jobs: - run: | pip install virtualenv make aws-lambda-layer - echo "after make:" - ls -alh dist-serverless - uses: actions/upload-artifact@v3 with: From d5ce3602e56dd983fe7950a7e1dd5fe676604df6 Mon Sep 17 00:00:00 2001 From: Anton Pirker Date: Wed, 6 Apr 2022 11:17:20 +0200 Subject: [PATCH 14/15] Added version to zip file name. --- .github/workflows/ci.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5b91082672..76c6ba8fca 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -115,9 +115,15 @@ jobs: python-version: 3.9 - run: | + echo "Creating directory containing Python SDK Lambda Layer" pip install virtualenv make aws-lambda-layer + echo "Saving SDK_VERSION for later" + export SDK_VERSION=$(grep "VERSION = " sentry_sdk/consts.py | cut -f3 -d' ' | tr -d '"') + echo "SDK_VERSION=$SDK_VERSION" + echo "SDK_VERSION=$SDK_VERSION" >> $GITHUB_ENV + - uses: actions/upload-artifact@v3 with: name: ${{ github.sha }} @@ -127,13 +133,13 @@ jobs: - uses: getsentry/action-build-aws-lambda-extension@v1 with: artifact_name: ${{ github.sha }} - zip_file_name: sentry-python-serverless-X.X.X.zip + zip_file_name: sentry-python-serverless-${{ env.SDK_VERSION }}.zip - name: Upload Zip uses: actions/upload-artifact@v3 with: name: ${{ github.sha }} - path: sentry-python-serverless-X.X.X.zip + path: sentry-python-serverless-${{ env.SDK_VERSION }}.zip docs: name: Build SDK API Doc From 9950705b565ef27a2f23bcd700334e5f44f2a60a Mon Sep 17 00:00:00 2001 From: Anton Pirker Date: Wed, 13 Apr 2022 10:48:59 +0200 Subject: [PATCH 15/15] fixed typo --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index a379e39bd8..bf13e1117c 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ help: @echo "make test: Run basic tests (not testing most integrations)" @echo "make test-all: Run ALL tests (slow, closest to CI)" @echo "make format: Run code formatters (destructive)" - @echo "make aws-lambda-layer: Build AWS Lambda layer directorzy for serverless integration" + @echo "make aws-lambda-layer: Build AWS Lambda layer directory for serverless integration" @echo @echo "Also make sure to read ./CONTRIBUTING.md" @false