-
Notifications
You must be signed in to change notification settings - Fork 0
58 lines (51 loc) · 1.65 KB
/
ci.yml
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
name: CI - Code Testing Workflow
on:
pull_request:
branches:
- develop
- main
- "feature/*"
- "hotfix/*"
paths:
- "src/**"
- "tests/**"
push:
branches:
- main
- develop
paths:
- "src/**"
- "tests/**"
jobs:
test:
name: Run Tests and Generate Coverage Report
runs-on: ubuntu-latest
steps:
# Step 1: Checkout the repository code
- name: Checkout code
uses: actions/checkout@v3
# Step 2: Set up Python environment
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.9"
# Step 3: Install dependencies
- name: Install dependencies
run: |
python -m venv venv # Create a virtual environment
source venv/bin/activate # Activate the virtual environment
pip install -r requirements.txt # Install required dependencies
pip install pytest pytest-cov # Add coverage tools
# Step 4: Run tests with coverage
- name: Run tests with coverage
run: |
source venv/bin/activate # Ensure the virtual environment is active
pytest --maxfail=3 --disable-warnings --cov=src --cov-report=xml --cov-report=term
# Step 5: Post coverage summary as a PR comment
- name: Post coverage summary
if: github.event_name == 'pull_request'
uses: mikepenz/comment-action@v2
with:
message: |
## Test Coverage Summary
$(cat coverage.xml | sed -n '/<coverage/,/<\/coverage>/p' | sed -e 's/<[^>]*>//g' | head -n 10)