Skip to content

Commit 47117ca

Browse files
Create main.yml
1 parent bed8d46 commit 47117ca

File tree

1 file changed

+86
-0
lines changed

1 file changed

+86
-0
lines changed

.github/workflows/main.yml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: CI/CD Pipeline for Flask App
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
jobs:
12+
build-and-test:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
# 1. Checkout Code
17+
- name: Checkout repository
18+
uses: actions/checkout@v3
19+
20+
# 2. Set up Python
21+
- name: Set up Python
22+
uses: actions/setup-python@v4
23+
with:
24+
python-version: "3.9"
25+
26+
# 3. Install dependencies
27+
- name: Install dependencies
28+
run: |
29+
python -m pip install --upgrade pip
30+
pip install -r requirements.txt
31+
32+
# 4. Run tests with coverage
33+
- name: Run tests and generate coverage report
34+
run: |
35+
pytest --cov=app tests/
36+
env:
37+
CI: true
38+
39+
# 5. Upload coverage to Codecov
40+
- name: Upload coverage report
41+
uses: codecov/codecov-action@v5
42+
with:
43+
token: ${{ secrets.CODECOV_TOKEN }}
44+
files: ./coverage.xml
45+
46+
static-analysis:
47+
runs-on: ubuntu-latest
48+
49+
steps:
50+
# 1. Checkout Code
51+
- name: Checkout repository
52+
uses: actions/checkout@v3
53+
54+
# 2. SonarCloud Analysis
55+
- name: Run SonarCloud Scan
56+
uses: SonarSource/sonarcloud-github-action@v2
57+
env:
58+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
59+
SONAR_PROJECT_KEY: ${{ secrets.SONAR_PROJECT_KEY }}
60+
SONAR_ORGANIZATION: ${{ secrets.SONAR_ORGANIZATION }}
61+
62+
dynamic-analysis:
63+
runs-on: ubuntu-latest
64+
65+
steps:
66+
# 1. Checkout Code
67+
- name: Checkout repository
68+
uses: actions/checkout@v3
69+
70+
# 2. Start Flask App
71+
- name: Start Flask Application
72+
run: |
73+
python app.py &
74+
sleep 10
75+
76+
# 3. Run OWASP ZAP
77+
- name: Run OWASP ZAP
78+
uses: zaproxy/action-full-scan@v0.5.0
79+
with:
80+
token: ${{ secrets.ZAP_API_KEY }}
81+
target: "http://127.0.0.1:5500"
82+
83+
# 4. Stop Flask Application
84+
- name: Stop Flask Application
85+
run: |
86+
pkill -f app.py

0 commit comments

Comments
 (0)