Path Regexp
Outlining our regular expression technique used
The Codecov Yaml accepts regexp patterns to filter report content. Detailed below is the strategy of how codecov processes these paths.
Regexp patterns
Codecov will try to ensure regex patterns input as a string by the user are gracefully handled and that string is used as a pattern to identify which paths to include/exclude from their report.
Codecov does this by taking the user input and transforming it into a regex that Python can process. The user can input three types of patterns:
path_prefix
,regex
, andglob
.
Codecov tries to determine which type of pattern the user inputted. We say "try" because some paths can be more than one type, and we try our best to see what the user meant. After determining the type, the code converts that type of pattern to a regex
(in case the user inputted a regex
, it is used as it is).
One additional processing we do is to account for the usage of !
by the user. !
means negation, and although we support ignore
fields, sometimes the users prefer to just use !
to denote something they want to exclude.
Status Checks and Flags do not support Regex rules
At this time, the Codecov Flags and Status Checks features do not accept regex-based paths
Expression | Result |
---|---|
/path | include ^path.* |
path/ | include ^path/.* |
path/* | include ^path/.* |
path/to/file.rb$ | include ^path/to/file.rb$ |
*/tests | include .*/tests.* |
'!path' | exclude ^path.\* |
Logic
if any negative match:
skip
else if has positive matches:
if positive match found:
include
else:
skip
else:
include
Updated 6 months ago