Skip to content

Commit 0a0e903

Browse files
committed
Testing features added
1 parent 5e6b431 commit 0a0e903

File tree

4 files changed

+40
-6
lines changed

4 files changed

+40
-6
lines changed

.github/workflows/main.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@ name: Deploy AWS Lambda with Serverless
33
on:
44
push:
55
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
712

813
jobs:
914
deploy:
@@ -21,8 +26,9 @@ jobs:
2126
- name: Verify Python installation
2227
run: python --version
2328

24-
25-
29+
- name: Triggering the run_checks using shell
30+
run: sh run_checks.sh
31+
2632
- name: Install Serverless Framework
2733
run: |
2834
npm install -g [email protected]
@@ -46,10 +52,10 @@ jobs:
4652
- name: Install only production dependencies
4753
run: npm ci --only=production # Only production dependencies are deployed
4854

49-
- name: Installing the prune Plugin
55+
- name: Installing the prune Plugin
5056
run: npm install serverless-prune-plugin
5157

5258
- name: Deploy with Serverless
5359
env:
5460
SERVERLESS_ACCESS_KEY: ${{ secrets.SERVERLESS_ACCESS_KEY }}
55-
run: serverless deploy --verbose
61+
run: serverless deploy

app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import logging
22

33
from flask import Flask, jsonify
4-
from nltk.sentiment import SentimentIntensityAnalyzer # type: ignore
4+
from nltk.sentiment import SentimentIntensityAnalyzer # type: ignore
55

66
logging.basicConfig(level=logging.ERROR)
77
logger = logging.getLogger(__name__)

run_checks.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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

serverless.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ custom:
3131
app: app.app
3232
pythonRequirements:
3333
dockerizePip: false
34+
prune:
35+
automatic: true
36+
number: 2
3437

3538
package:
3639
patterns:

0 commit comments

Comments
 (0)