-
Notifications
You must be signed in to change notification settings - Fork 418
135 lines (117 loc) · 3.95 KB
/
test.yml
File metadata and controls
135 lines (117 loc) · 3.95 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
name: Test Workflow with Coverage - Code-Gen
permissions:
contents: read
actions: read
pull-requests: write
on:
push:
branches:
- main
- dev
- demo
paths:
- 'src/backend/**/*.py'
- 'src/tests/**'
- '.github/workflows/test.yml'
- 'src/backend/requirements.txt'
- 'src/frontend/requirements.txt'
- 'src/backend/pyproject.toml'
pull_request:
types:
- opened
- ready_for_review
- reopened
- synchronize
branches:
- main
- dev
- demo
paths:
- 'src/backend/**/*.py'
- 'src/tests/**'
- '.github/workflows/test.yml'
- 'src/backend/requirements.txt'
- 'src/frontend/requirements.txt'
- 'src/backend/pyproject.toml'
jobs:
# frontend_tests:
# runs-on: ubuntu-latest
# steps:
# - name: Checkout code
# uses: actions/checkout@v6
# - name: Set up Node.js
# uses: actions/setup-node@v3
# with:
# node-version: '20'
# - name: Check if Frontend Test Files Exist
# id: check_frontend_tests
# run: |
# if [ -z "$(find src/tests/frontend -type f -name '*.test.js' -o -name '*.test.ts' -o -name '*.test.tsx')" ]; then
# echo "No frontend test files found, skipping frontend tests."
# echo "skip_frontend_tests=true" >> $GITHUB_ENV
# else
# echo "Frontend test files found, running tests."
# echo "skip_frontend_tests=false" >> $GITHUB_ENV
# fi
# - name: Install Frontend Dependencies
# if: env.skip_frontend_tests == 'false'
# run: |
# cd src/frontend
# npm install
# - name: Run Frontend Tests with Coverage
# if: env.skip_frontend_tests == 'false'
# run: |
# cd src/tests/frontend
# npm run test -- --coverage
# - name: Skip Frontend Tests
# if: env.skip_frontend_tests == 'true'
# run: |
# echo "Skipping frontend tests because no test files were found."
backend_tests:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.11'
- name: Install Backend Dependencies
run: |
python -m pip install --upgrade pip
pip install -r src/backend/requirements.txt
pip install -r src/frontend/requirements.txt
pip install pytest-cov
pip install pytest-asyncio
- name: Set PYTHONPATH
run: echo "PYTHONPATH=$PWD/src/backend" >> $GITHUB_ENV
- name: Check if Backend Test Files Exist
id: check_backend_tests
run: |
if [ -z "$(find src/tests/backend -type f -name '*_test.py')" ]; then
echo "No backend test files found, skipping backend tests."
echo "skip_backend_tests=true" >> $GITHUB_ENV
else
echo "Backend test files found, running tests."
echo "skip_backend_tests=false" >> $GITHUB_ENV
fi
- name: Run Backend Tests with Coverage
if: env.skip_backend_tests == 'false'
run: |
cd src
pytest tests/backend --cov=backend --cov-report=term-missing --cov-report=xml --cov-fail-under=80 --junitxml=pytest.xml
- name: Pytest Coverage Comment
if: |
always() &&
github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.fork == false &&
env.skip_backend_tests == 'false'
uses: MishaKav/pytest-coverage-comment@26f986d2599c288bb62f623d29c2da98609e9cd4 # v1.6.0
with:
pytest-xml-coverage-path: src/coverage.xml
junitxml-path: src/pytest.xml
report-only-changed-files: true
- name: Skip Backend Tests
if: env.skip_backend_tests == 'true'
run: |
echo "Skipping backend tests because no test files were found."