chore: Release python lambda sdk v0.3.2 (#883) #250
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# PR's only | |
name: "Python: Integrate" | |
on: | |
push: | |
branches: [main] | |
paths: | |
- python/** | |
- proto/** | |
jobs: | |
validate: | |
name: "[Linux] Python 3: Unit Tests" | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python_version: ["3.7", "3.8", "3.9", "3.10"] | |
outputs: | |
pathChangedAwsLambdaSdk: ${{ steps.pathChanges.outputs.awsLambdaSdk }} | |
pathChangedSdk: ${{ steps.pathChanges.outputs.sdk}} | |
pathChangedSdkSchema: ${{ steps.pathChanges.outputs.sdkSchema}} | |
pathChangedProto: ${{ steps.pathChanges.outputs.proto }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Resolve path filters | |
uses: dorny/paths-filter@v2 | |
id: pathChanges | |
with: | |
filters: | | |
awsLambdaSdk: | |
- 'python/packages/aws-lambda-sdk/**' | |
sdk: | |
- 'python/packages/sdk/**' | |
sdkSchema: | |
- 'python/packages/sdk-schema/**' | |
proto: | |
- 'proto/**' | |
- name: Install Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python_version }} | |
# ensure project dependencies are cached | |
# When using only `pyproject.toml` for dependencies, see: | |
# https://github.com/actions/setup-python/issues/529#issuecomment-1367029699 | |
cache: "pip" | |
cache-dependency-path: | | |
**/pyproject.toml | |
- name: Install SDK project and dependencies | |
if: steps.pathChanges.outputs.sdk == 'true' | |
run: | | |
cd python/packages/sdk | |
python3 -m venv .venv | |
source .venv/bin/activate | |
python3 -m pip install '.[tests]' | |
- name: Run SDK type checking | |
if: steps.pathChanges.outputs.sdk == 'true' | |
run: | | |
cd python/packages/sdk | |
source .venv/bin/activate | |
python3 -m mypy sls_sdk | |
- name: Run SDK unit tests | |
if: steps.pathChanges.outputs.sdk == 'true' | |
run: | | |
cd python/packages/sdk | |
source .venv/bin/activate | |
python3 -m pytest | |
- name: Buf Setup | |
if: steps.pathChanges.outputs.sdkSchema == 'true' || steps.pathChanges.outputs.proto == 'true' | |
uses: bufbuild/buf-setup-action@v1 | |
with: | |
github_token: ${{ github.token }} | |
- name: Cache protobuf | |
id: cache-protobuf | |
uses: actions/cache@v3 | |
with: | |
path: ~/protobuf | |
key: "protobuf:protoc-22.2-linux-x86_32.zip" | |
- name: Install protoc compiler | |
if: steps.cache-protobuf.outputs.cache-hit != 'true' && (steps.pathChanges.outputs.sdkSchema == 'true' || steps.pathChanges.outputs.proto == 'true') | |
run: | | |
curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v22.2/protoc-22.2-linux-x86_32.zip | |
unzip protoc-22.2-linux-x86_32.zip -d ~/protobuf | |
- name: Add protobuf to PATH | |
if: steps.pathChanges.outputs.sdkSchema == 'true' || steps.pathChanges.outputs.proto == 'true' | |
run: | | |
echo ~/protobuf/bin >> $GITHUB_PATH | |
- name: Buf Lint | |
if: steps.pathChanges.outputs.proto == 'true' | |
uses: bufbuild/buf-lint-action@v1 | |
with: | |
input: "proto" | |
- name: Build Protobufs | |
if: steps.pathChanges.outputs.sdkSchema == 'true' || steps.pathChanges.outputs.proto == 'true' | |
run: | | |
cd ./proto | |
buf build | |
buf generate --template=buf.gen.python.yaml | |
- name: Install SDK Schema | |
if: steps.pathChanges.outputs.sdkSchema == 'true' || steps.pathChanges.outputs.proto == 'true' | |
run: | | |
cd python/packages/sdk-schema | |
python3 -m venv .venv | |
source .venv/bin/activate | |
python3 -m pip install '.[tests]' | |
- name: Run SDK Schema unit tests | |
if: steps.pathChanges.outputs.sdkSchema == 'true' || steps.pathChanges.outputs.proto == 'true' | |
run: | | |
cd python/packages/sdk-schema | |
source .venv/bin/activate | |
python3 -m pytest | |
- name: Install AWS Lambda SDK project and dependencies | |
if: steps.pathChanges.outputs.awsLambdaSdk == 'true' | |
run: | | |
cd python/packages/aws-lambda-sdk | |
python3 -m venv .venv | |
source .venv/bin/activate | |
python3 -m pip install '.[tests]' | |
- name: Run AWS Lambda SDK type checking | |
if: steps.pathChanges.outputs.awsLambdaSdk == 'true' | |
run: | | |
cd python/packages/aws-lambda-sdk | |
source .venv/bin/activate | |
python3 -m mypy serverless_aws_lambda_sdk | |
- name: Run AWS Lambda SDK unit tests | |
if: steps.pathChanges.outputs.awsLambdaSdk == 'true' | |
run: | | |
cd python/packages/aws-lambda-sdk | |
source .venv/bin/activate | |
python3 -m pytest | |
integratePythonSdk: | |
name: Integrate Python SDK | |
runs-on: ubuntu-latest | |
needs: [validate] | |
if: needs.validate.outputs.pathChangedSdk == 'true' | |
timeout-minutes: 5 # Default is 360 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
with: | |
# Ensure to have complete history of commits pushed with given push operation | |
# It's loose and imperfect assumption that no more than 30 commits will be pushed at once | |
fetch-depth: 30 | |
# Tag needs to be pushed with real user token, otherwise pushed tag won't trigger the actions workflow | |
# Hence we're passing 'serverless-ci' user authentication token | |
token: ${{ secrets.USER_GITHUB_TOKEN }} | |
- name: Tag if new version | |
run: | | |
NEW_VERSION=`git diff -U0 ${{ github.event.before }} python/packages/sdk/sls_sdk/VERSION | tail -n 1 | grep -oE "[0-9]+\.[0-9]+\.[0-9]+"` || : | |
if [ -n "$NEW_VERSION" ] && [ $NEW_VERSION != "0.0.0" ]; | |
then | |
git tag python/serverless-sdk@$NEW_VERSION | |
git push --tags | |
fi | |
integrateAwsLambdaSdk: | |
name: Integrate Python AWS Lambda SDK | |
runs-on: ubuntu-latest | |
needs: [validate] | |
if: needs.validate.outputs.pathChangedAwsLambdaSdk == 'true' | |
timeout-minutes: 5 # Default is 360 | |
env: | |
AWS_REGION: us-east-1 | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
SLS_ORG_ID: ${{ secrets.SLS_ORG_ID }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
with: | |
# Ensure to have complete history of commits pushed with given push operation | |
# It's loose and imperfect assumption that no more than 30 commits will be pushed at once | |
fetch-depth: 30 | |
# Tag needs to be pushed with real user token, otherwise pushed tag won't trigger the actions workflow | |
# Hence we're passing 'serverless-ci' user authentication token | |
token: ${{ secrets.USER_GITHUB_TOKEN }} | |
- name: Install Python 3.7 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.7" | |
cache: "pip" | |
cache-dependency-path: | | |
**/pyproject.toml | |
- name: Install AWS Lambda SDK project and dependencies | |
run: | | |
cd python/packages/aws-lambda-sdk | |
python3 -m pip install . --target=dist | |
python3 -m pip install pyclean | |
python3 -m pyclean dist | |
rm -rf dist/google/_upb | |
- name: Install Node.js and npm | |
uses: actions/setup-node@v1 | |
with: | |
node-version: 16.x | |
registry-url: https://registry.npmjs.org | |
- name: Install integration script dependencies | |
run: | | |
cd node | |
npm update --save-dev --no-save | |
- name: Integration tests | |
run: | | |
cd node | |
npx mocha test/python/aws-lambda-sdk/integration.test.js | |
- name: Performance tests | |
run: | | |
cd node | |
npx mocha test/python/aws-lambda-sdk/benchmark/performance.test.js | |
- name: Tag if new version | |
run: | | |
NEW_VERSION=`git diff -U0 ${{ github.event.before }} python/packages/aws-lambda-sdk/serverless_aws_lambda_sdk/VERSION | tail -n 1 | grep -oE "[0-9]+\.[0-9]+\.[0-9]+"` || : | |
if [ -n "$NEW_VERSION" ] && [ $NEW_VERSION != "0.0.0" ]; | |
then | |
git tag python/serverless-aws-lambda-sdk@$NEW_VERSION | |
git push --tags | |
fi | |
integratePythonSdkSchema: | |
name: Integrate Python SDK Schema | |
runs-on: ubuntu-latest | |
needs: [validate] | |
if: needs.validate.outputs.pathChangedSdkSchema == 'true' | |
timeout-minutes: 5 # Default is 360 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
with: | |
# Ensure to have complete history of commits pushed with given push operation | |
# It's loose and imperfect assumption that no more than 30 commits will be pushed at once | |
fetch-depth: 30 | |
# Tag needs to be pushed with real user token, otherwise pushed tag won't trigger the actions workflow | |
# Hence we're passing 'serverless-ci' user authentication token | |
token: ${{ secrets.USER_GITHUB_TOKEN }} | |
- name: Tag if new version | |
run: | | |
NEW_VERSION=`git diff -U0 ${{ github.event.before }} python/packages/sdk-schema/pyproject.toml | grep 'version = ' | tail -n 1 | grep -oE "[0-9]+\.[0-9]+\.[0-9]+"` || : | |
if [ -n "$NEW_VERSION" ] && [ $NEW_VERSION != "0.0.0" ]; | |
then | |
git tag python/serverless-sdk-schema@$NEW_VERSION | |
git push --tags | |
fi |