File tree Expand file tree Collapse file tree 4 files changed +40
-6
lines changed Expand file tree Collapse file tree 4 files changed +40
-6
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,12 @@ name: Deploy AWS Lambda with Serverless
3
3
on :
4
4
push :
5
5
branches :
6
- - main # Adjust for your deployment branch
6
+ - main
7
+ - dev
8
+ pull_request :
9
+ branches :
10
+ - main # Run tests when merging to main and dev
11
+ - dev
7
12
8
13
jobs :
9
14
deploy :
21
26
- name : Verify Python installation
22
27
run : python --version
23
28
24
-
25
-
29
+ - name : Triggering the run_checks using shell
30
+ run : sh run_checks.sh
31
+
26
32
- name : Install Serverless Framework
27
33
run : |
28
34
@@ -46,10 +52,10 @@ jobs:
46
52
- name : Install only production dependencies
47
53
run : npm ci --only=production # Only production dependencies are deployed
48
54
49
- - name : Installing the prune Plugin
55
+ - name : Installing the prune Plugin
50
56
run : npm install serverless-prune-plugin
51
57
52
58
- name : Deploy with Serverless
53
59
env :
54
60
SERVERLESS_ACCESS_KEY : ${{ secrets.SERVERLESS_ACCESS_KEY }}
55
- run : serverless deploy --verbose
61
+ run : serverless deploy
Original file line number Diff line number Diff line change 1
1
import logging
2
2
3
3
from flask import Flask , jsonify
4
- from nltk .sentiment import SentimentIntensityAnalyzer # type: ignore
4
+ from nltk .sentiment import SentimentIntensityAnalyzer # type: ignore
5
5
6
6
logging .basicConfig (level = logging .ERROR )
7
7
logger = logging .getLogger (__name__ )
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+ GREEN=" \e[32m"
3
+ RESET=" \e[0m"
4
+ set -e
5
+ echo " Installing test dependencies..."
6
+ pip install -q -r requirements-test.txt || exit 1
7
+
8
+ echo " Running pytest (UnitTest)..."
9
+ set -e python -m pytest app.py || exit 1
10
+
11
+ echo " Running flake8(Linter)..."
12
+ python -m flake8 app.py || exit 1
13
+
14
+ echo " Running isort(Organizing import)..."
15
+ python -m isort app.py || exit 1
16
+
17
+ echo " Running mypy(Static type checking)..."
18
+ python -m mypy app.py || exit 1
19
+
20
+ echo " Running bandit(vulnerability test)..."
21
+ python -m bandit -r app.py || exit 1
22
+
23
+ echo -e " ${GREEN} ============= All checks passed! ===============${RESET} "
24
+ echo " Removing test Dependencies"
25
+ pip uninstall -r requirements-test.txt -y || exit 1
Original file line number Diff line number Diff line change @@ -31,6 +31,9 @@ custom:
31
31
app : app.app
32
32
pythonRequirements :
33
33
dockerizePip : false
34
+ prune :
35
+ automatic : true
36
+ number : 2
34
37
35
38
package :
36
39
patterns :
You can’t perform that action at this time.
0 commit comments