-
Notifications
You must be signed in to change notification settings - Fork 0
105 lines (81 loc) · 2.46 KB
/
Python-Code-Testing.yml
File metadata and controls
105 lines (81 loc) · 2.46 KB
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
name: Python Syntax Check
on:
pull_request:
push:
branches:
- main
jobs:
General-Syntax-Check:
runs-on: ubuntu-latest
steps:
# Check out the repository code
- name: Checkout code
uses: actions/checkout@v3
# Set up Python
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.11
# Install dependencies for flake8 (optional step if you want code style checking)
- name: Install flake8
run: |
python -m pip install --upgrade pip
pip install flake8
# Step 1: Basic Syntax Check
- name: Syntax Check with Python
run: python -m compileall .
# Step 2: Code Style Check with flake8
- name: Lint with flake8
run: flake8 .
Code-Quality-Check:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.11
- name: Install tools
run: |
python -m pip install --upgrade pip
pip install bandit safety vulture radon pydocstyle black isort pyre-check
- name: Security Check with Bandit
run: bandit -r src
- name: Dependency Security Check
run: |
if [ -f requirements.txt ]; then
safety check -r requirements.txt
else
echo "No requirements.txt file found. Skipping dependency security check."
fi
- name: Dead Code Detection with Vulture
run: vulture .
- name: Code Complexity Check with Radon
run: radon cc . -a
- name: Documentation Check with pydocstyle
run: pydocstyle .
- name: Format Python Code
run: |
black .
- name: Check Python Code Formatting
run: |
black --check .
- name: Sort Imports with isort
run: |
isort .
- name: Import Sorting Check with isort
run: isort --check-only .
Unit-Tests:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.11
- name: Install dependencies
run: pip install pytest streamlit langchain_ollama langchain_core langchain_chroma langchain
- name: Run unit tests
run: python -m pytest tests/