-
Notifications
You must be signed in to change notification settings - Fork 3
74 lines (59 loc) · 1.76 KB
/
Unit_Tests.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
name: Unit Test
on:
push:
branches:
- master
paths-ignore:
- '**.md'
pull_request:
branches:
- master
jobs:
test:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./Project_phase_2/
strategy:
matrix:
python-version: [3.10]
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.10.13
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r test_requirements.txt
pip install werkzeug==2.3.0
pip install coverage
pip install coverage-badge
- name: Test with coverage
run: |
cd tests/Unit_Test_Cases
coverage run -m pytest Unit_Test.py
coverage xml -o coverage.xml
rm -f coverage.svg
coverage-badge -o coverage.svg
- name: Commit Coverage Badge
run: |
git config --global user.name 'Waariss'
git config --global user.email '[email protected]'
# Stash any local changes
git stash --include-untracked
# Pull latest changes from the remote repository
git pull origin master --rebase
# Apply the stashed changes
git stash pop
# Add all changes to staging
git add -A
# Commit and push only if there are changes
git diff --staged --quiet || git commit -m "Update coverage badge"
git push
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
with:
file: ./Project_phase_2/tests/Unit_Test_Cases/coverage.xml
fail_ci_if_error: true