Skip to content

Commit 21c3e61

Browse files
Codecov Setup: Update coverage configuration and TravisCI script (Cloud-CV#4774)
* Update coverage configuration and TravisCI script - Added 'data_file' entry to .coveragerc to specify coverage data file. - Modified .travis.yml to run coveralls using docker-compose for better environment management. * Enhance coverage reporting and TravisCI configuration - Updated .travis.yml to generate and upload separate coverage reports for backend and frontend to Codecov. - Modified codecov.yml to define explicit coverage checks for backend and frontend with specified targets and thresholds. - Adjusted karma.conf.js to output frontend coverage reports to a dedicated directory and changed reporter type. - Removed coveralls integration from the project as it is no longer needed. - Cleaned up requirements by removing coveralls dependency. * Update codecov.yml to enforce stricter coverage requirements - Changed the patch target from 0% to 100% to ensure all changed lines are covered. - Cleaned up comments for clarity while maintaining explicit coverage checks for backend and frontend. * Update coverage configuration and reporting settings - Added 'manage.py' and 'evalai/wsgi.py' to the .coveragerc omit list to exclude them from coverage reports. - Modified karma.conf.js to adjust the lcovonly reporter configuration for better output structure. * Remove frontend_v2 path from coverage configuration in codecov.yml * Enhance codecov.yml configuration for improved coverage reporting - Added comprehensive ignore paths for various file types including Python environments, Django files, and frontend assets. - Defined individual component coverage targets and thresholds for better granularity in coverage reporting. - Updated notification settings and GitHub Checks integration for enhanced feedback on coverage status. - Adjusted patch coverage requirements to ensure new changes meet specified standards. * Remove 'manage.py' and 'evalai/wsgi.py' from .coveragerc omit list to include them in coverage reports. * Remove frontend directory from coverage exclusions in codecov.yml
1 parent 0e0e5a3 commit 21c3e61

5 files changed

Lines changed: 298 additions & 18 deletions

File tree

.travis.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646

4747
# Backend Tests
4848
- docker-compose run -e DJANGO_SETTINGS_MODULE=settings.test django python manage.py flush --noinput || travis_terminate 1;
49-
- docker-compose run -e DJANGO_SETTINGS_MODULE=settings.test django pytest --cov . --cov-config .coveragerc || travis_terminate 1;
49+
- docker-compose run -e DJANGO_SETTINGS_MODULE=settings.test django pytest --cov . --cov-config .coveragerc --cov-report=xml:coverage-backend.xml || travis_terminate 1;
5050

5151
# Check Code Quality
5252
- docker-compose run -e DJANGO_SETTINGS_MODULE=settings.dev -e VERBOSE=1 django bash -c "
@@ -63,8 +63,11 @@ jobs:
6363
echo 'All code quality checks passed!'" || travis_terminate 1;
6464

6565
after_success:
66-
- bash <(curl -s https://codecov.io/bash)
67-
- coveralls --rcfile=.coveragerc
66+
# Upload backend coverage to Codecov
67+
- bash <(curl -s https://codecov.io/bash) -f coverage-backend.xml -F backend
68+
69+
# Upload frontend coverage to Codecov
70+
- bash <(curl -s https://codecov.io/bash) -f coverage/frontend/lcov.info -F frontend
6871

6972
- stage: Package & Deployment
7073
name: Push & Deploy Services

codecov.yml

Lines changed: 290 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,298 @@
11
codecov:
2+
# Global Codecov settings
3+
branch: master # set default branch (overrides Git default)
4+
max_report_age: off # Turn off max report age
5+
strict_yaml_branch: master # always use YAML from master branch
6+
7+
# Bot configuration for GitHub operations
8+
bot: "codecov[bot]" # GitHub App bot username
9+
10+
# Notification settings
211
notify:
3-
require_ci_to_pass: yes
12+
require_ci_to_pass: yes # require CI to pass before processing coverage
13+
after_n_builds: 2 # wait for both backend and frontend uploads
14+
wait_for_ci: yes # wait for CI completion
415

516
coverage:
6-
precision: 2
7-
round: down
8-
range: "70...100"
17+
precision: 2 # decimal places in coverage percentage
18+
round: down # round coverage down
19+
range: "70...100" # acceptable coverage range
20+
21+
# Comprehensive ignore paths for coverage calculation
22+
ignore:
23+
# Python environment and system files
24+
- "*/python?.?/*" # Python installations
25+
- "*/site-packages/*" # Python packages
26+
- "*/venv/*" # virtual environments
27+
- "*/env/*" # virtual environments
28+
- "*/.venv/*" # virtual environments
29+
30+
# Django generated/boilerplate files
31+
- "*/migrations/*" # Django migrations
32+
- "*/templates/*" # Django templates
33+
- "*/static/*" # static files
34+
- "*/media/*" # media files
35+
- "manage.py" # Django management script
36+
- "evalai/wsgi.py" # WSGI configuration
37+
- "evalai/asgi.py" # ASGI configuration
38+
39+
# Test files
40+
- "*/tests/*" # test directories
41+
- "*/test_*.py" # test files
42+
- "*_test.py" # test files
43+
- "test_*.py" # test files
44+
- "conftest.py" # pytest configuration
45+
46+
# Django settings (environment-specific)
47+
- "settings/custom_storages.py" # storage settings
48+
- "settings/staging.py" # staging settings
49+
- "settings/dev.py" # development settings
50+
- "settings/prod.py" # production settings
51+
- "settings/test.py" # test settings
52+
53+
# Scripts and utilities
54+
- "scripts/seed.py" # seed script
55+
- "scripts/migration/*" # migration scripts
56+
- "scripts/deployment/*" # deployment scripts
57+
58+
# Third-party dependencies
59+
- "*/node_modules/*" # Node.js dependencies
60+
- "*/bower_components/*" # Bower dependencies
61+
62+
# Frontend (not Python)
63+
- "frontend_v2/" # frontend v2 directory
64+
65+
# Other non-essential files
66+
- "*/middleware/*" # middleware files
67+
- "*/admin.py" # Django admin
68+
- "*/apps.py" # Django app configuration
69+
- "*.min.js" # minified JavaScript
70+
- "*.min.css" # minified CSS
971

1072
status:
11-
project: yes
12-
patch: yes
13-
changes: no
73+
# Default rules applied to all status checks
74+
default_rules:
75+
flag_coverage_not_uploaded_behavior: exclude
76+
77+
# Project status checks
78+
project:
79+
default: false # disable default project status
80+
81+
backend:
82+
target: 70% # minimum coverage required
83+
threshold: 1% # allow coverage to drop by 1%
84+
flags:
85+
- backend
86+
paths:
87+
- evalai/
88+
- apps/
89+
if_ci_failed: error # fail status if CI fails
90+
informational: false
91+
only_pulls: false
92+
93+
frontend:
94+
target: 70%
95+
threshold: 1%
96+
flags:
97+
- frontend
98+
paths:
99+
- frontend/
100+
if_ci_failed: error
101+
informational: false
102+
only_pulls: false
103+
104+
# Combined overall project status
105+
overall:
106+
target: 70%
107+
threshold: 2%
108+
patch:
109+
default:
110+
target: 80% # require 80% coverage on new/changed lines
111+
threshold: 0% # no threshold for patch coverage
112+
if_ci_failed: error
113+
only_pulls: true # only apply to pull requests
114+
115+
backend_patch:
116+
target: 80%
117+
flags:
118+
- backend
119+
paths:
120+
- evalai/
121+
- apps/
122+
only_pulls: true
123+
124+
frontend_patch:
125+
target: 70% # slightly lower for frontend
126+
flags:
127+
- frontend
128+
paths:
129+
- frontend/
130+
only_pulls: true
14131

132+
flags:
133+
backend:
134+
paths:
135+
- evalai/
136+
- apps/
137+
frontend:
138+
paths:
139+
- frontend/
140+
141+
# Components configuration - isolate and categorize coverage data
142+
component_management:
143+
default_rules: # default rules inherited by all components
144+
statuses:
145+
- type: project
146+
target: 70%
147+
threshold: 1%
148+
149+
individual_components:
150+
# Backend Core Components
151+
- component_id: accounts_module
152+
name: "Accounts & Authentication"
153+
paths:
154+
- apps/accounts/**
155+
statuses:
156+
- type: project
157+
target: 75% # higher target for authentication
158+
- type: patch
159+
target: 85%
160+
161+
- component_id: challenges_module
162+
name: "Challenges Management"
163+
paths:
164+
- apps/challenges/**
165+
statuses:
166+
- type: project
167+
target: 80% # core functionality needs high coverage
168+
- type: patch
169+
target: 85%
170+
171+
- component_id: jobs_module
172+
name: "Job Processing"
173+
paths:
174+
- apps/jobs/**
175+
statuses:
176+
- type: project
177+
target: 75%
178+
- type: patch
179+
target: 80%
180+
181+
- component_id: participants_module
182+
name: "Participants & Teams"
183+
paths:
184+
- apps/participants/**
185+
statuses:
186+
- type: project
187+
target: 70%
188+
- type: patch
189+
target: 75%
190+
191+
- component_id: hosts_module
192+
name: "Challenge Hosts"
193+
paths:
194+
- apps/hosts/**
195+
196+
- component_id: analytics_module
197+
name: "Analytics"
198+
paths:
199+
- apps/analytics/**
200+
201+
- component_id: web_module
202+
name: "Web Interface"
203+
paths:
204+
- apps/web/**
205+
206+
# Frontend Components
207+
- component_id: frontend
208+
name: "Frontend (Gulp)"
209+
paths:
210+
- frontend/**
211+
flag_regexes:
212+
- "frontend"
213+
statuses:
214+
- type: project
215+
target: 65% # frontend might have lower coverage
216+
217+
# Cross-cutting Components
218+
- component_id: models_all
219+
name: "All Models"
220+
paths:
221+
- "**/models.py"
222+
statuses:
223+
- type: project
224+
target: 85% # models should be well tested
225+
226+
- component_id: views_all
227+
name: "All Views"
228+
paths:
229+
- "**/views.py"
230+
statuses:
231+
- type: project
232+
target: 75%
233+
234+
- component_id: serializers_all
235+
name: "All Serializers"
236+
paths:
237+
- "**/serializers.py"
238+
statuses:
239+
- type: project
240+
target: 80%
241+
242+
- component_id: utils_all
243+
name: "Utility Functions"
244+
paths:
245+
- "**/utils.py"
246+
- "**/aws_utils.py"
247+
- "apps/base/**"
248+
statuses:
249+
- type: project
250+
target: 70%
251+
252+
# Configuration & Scripts
253+
- component_id: core_config
254+
name: "Core Configuration"
255+
paths:
256+
- evalai/**
257+
- settings/**
258+
- "*.py" # root level Python files
259+
statuses:
260+
- type: project
261+
target: 60% # config files might have lower coverage
262+
263+
# Parsers configuration for different coverage formats
264+
parsers:
265+
gcov:
266+
branch_detection:
267+
conditional: yes
268+
loop: yes
269+
method: no
270+
macro: no
271+
javascript:
272+
enable_partials: no
273+
274+
# Pull request comment configuration
15275
comment:
16-
layout: "header, diff, flags, files, changes, sunburst, uncovered, tree, footer"
17-
behavior: default
18-
require_changes: no
276+
layout: "header, diff, flags, components, files, changes, sunburst, uncovered, tree, footer"
277+
behavior: default # default, once, new, spammy
278+
require_changes: no # post comment even if no coverage changes
279+
require_base: no # post comment even if no base coverage
280+
require_head: yes # only post if head coverage exists
281+
hide_project_coverage: no # show project coverage in comment
282+
283+
# GitHub Checks integration
284+
github_checks:
285+
annotations: true # show coverage annotations on GitHub
286+
287+
# Profiling configuration
288+
profiling:
289+
critical_files_paths: # files that are critical for the project
290+
- "apps/accounts/**" # authentication
291+
- "apps/challenges/**" # core functionality
292+
- "apps/jobs/**" # job processing
293+
294+
# Slack notifications (optional - requires setup)
295+
# slack:
296+
# url: "your-slack-webhook-url"
297+
# threshold: 1%
298+
# message: "Coverage changed by {{ range diff }}% in {{ owner }}/{{ repo }}"

karma.conf.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ module.exports = function(config) {
5454
'karma-jasmine',
5555
'karma-chrome-launcher',
5656
'karma-coverage',
57-
'karma-coveralls',
5857
'karma-brief-reporter',
5958
],
6059

@@ -91,9 +90,9 @@ module.exports = function(config) {
9190

9291
coverageReporter: {
9392
includeAllSources: true,
94-
dir: 'coverage/',
93+
dir: 'coverage/frontend/',
9594
reporters: [
96-
{ type: "lcov" },
95+
{ type: 'lcovonly', subdir: '.', file: 'lcov.info' },
9796
{ type: 'text-summary' }
9897
]
9998
}

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
"karma-chrome-launcher": "^2.2.0",
4949
"karma-cli": "^2.0.0",
5050
"karma-coverage": "^1.1.2",
51-
"karma-coveralls": "^2.1.0",
5251
"karma-jasmine": "^2.0.1",
5352
"puppeteer": "^1.16.0"
5453
}

requirements/dev.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11

22
-r common.txt
33
coverage==5.3
4-
coveralls==2.2.0
54
django-debug-toolbar==3.2.1
65
django-extensions==3.1.0
76
django-silk==4.1.0

0 commit comments

Comments
 (0)