-
Notifications
You must be signed in to change notification settings - Fork 10
268 lines (236 loc) · 9.41 KB
/
python-integrate.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
# 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