Ignoring Paths

You can use the top-level ignore: key to tell Codecov to ignore certain paths.

Add a list of paths (folders or file names) to your codecov.yml file under the ignore key to exclude files from being collected by Codecov. Ignored files will be skipped during processing.

šŸ“˜

Things to note

File paths will be read as regex patterns, so special characters in regex will need to be escaped using \\ prior to the character, an example being + which would require \\+ to be processed correctly.

The pattern folder/* will not match recursively in the folder.
Please use this folder/**/*, which will exclude all files within the given folder.

# sample regex patterns
ignore:
  - "path/to/folder"  # ignore folders and all its contents
  - "test_*.rb"       # wildcards accepted
  - "**/*.py"         # glob accepted

The following are examples of different rules and how they behave followed by a corresponding directory with the ignored files called out for clarity.

Ignoring a Specific Folder

This rule will ignore everything in the top level project2 folder and everything underneath it, but will NOT ignore project 2 underneath the src/ folder.

ignore:
    - "project2"

Sample file tree:

ā”œā”€ā”€ src/
     ā”œā”€ā”€ project1/
          ā”œā”€ā”€ 1A.py
          ā”œā”€ā”€ 1B.py
          ā”œā”€ā”€ 1C.py
          ā”œā”€ā”€ coverage/
               ā”œā”€ā”€ coverage.xml
     ā”œā”€ā”€ project2/
          ā”œā”€ā”€ 2A.py
          ā”œā”€ā”€ 2B.py
          ā”œā”€ā”€ 2C.py
          ā”œā”€ā”€ coverage/
               ā”œā”€ā”€ coverage.xml
     ā”œā”€ā”€ project3/
          ā”œā”€ā”€ 3A.py
          ā”œā”€ā”€ test_3A.rb
          ā”œā”€ā”€ 3B.py
          ā”œā”€ā”€ test_3B.rb
          ā”œā”€ā”€ 3C.py
          ā”œā”€ā”€ test_3C.rb
          ā”œā”€ā”€ coverage/
               ā”œā”€ā”€ coverage.xml
ā”œā”€ā”€ project2/
     ā”œā”€ā”€ 2A.py
     ā”œā”€ā”€ 2B.py
     ā”œā”€ā”€ 2C.py
     ā”œā”€ā”€ coverage/
          ā”œā”€ā”€ coverage.xml

Ignored files:

  • project2/2A.py
  • project2/2B.py
  • project2/2C.py
  • project2/coverage/coverage.xml

Ignoring Specific Files At All Depths

This rule will ignore any files at any depth that start with "test_" and end with ".rb".

ignore:
    - "**/test_*.rb"

Sample file tree:

ā”œā”€ā”€ src/
     ā”œā”€ā”€ project1/
          ā”œā”€ā”€ 1A.py
          ā”œā”€ā”€ 1B.py
          ā”œā”€ā”€ 1C.py
     ā”œā”€ā”€ project2/
          ā”œā”€ā”€ 2A.py
          ā”œā”€ā”€ 2B.py
          ā”œā”€ā”€ 2C.py
     ā”œā”€ā”€ project3/
          ā”œā”€ā”€ 3A.py
          ā”œā”€ā”€ test_3A.rb
          ā”œā”€ā”€ 3B.py
          ā”œā”€ā”€ test_3B.rb
          ā”œā”€ā”€ 3C.py
          ā”œā”€ā”€ test_3C.rb
ā”œā”€ā”€ project4/.  
     ā”œā”€ā”€ test_4A.rb   
     ā”œā”€ā”€ test_4B.rb
     ā”œā”€ā”€ test_4C.rb

Ignored files:

  • src/project3/test_3A.rb
  • src/project3/test_3B.rb
  • src/project3/test_3C.rb
  • project4/test_4A.rb
  • project4/test_4B.rb
  • project4/test_4C.rb

Ignoring Specific File Types

This rule will ignore any file at any depth that ends in ".py".

ignore:
    - "**/*.py"

Sample file tree:

ā”œā”€ā”€ src/
     ā”œā”€ā”€ project1/
          ā”œā”€ā”€ 1A.py
          ā”œā”€ā”€ 1B.py
          ā”œā”€ā”€ 1C.py
     ā”œā”€ā”€ project2/
          ā”œā”€ā”€ 2A.py
          ā”œā”€ā”€ 2B.py
          ā”œā”€ā”€ 2C.py
     ā”œā”€ā”€ project3/
          ā”œā”€ā”€ 3A.py
          ā”œā”€ā”€ test_3A.rb
          ā”œā”€ā”€ 3B.py
          ā”œā”€ā”€ test_3B.rb
          ā”œā”€ā”€ 3C.py
          ā”œā”€ā”€ test_3C.rb
ā”œā”€ā”€ project4/.  
     ā”œā”€ā”€ test_4A.rb   
     ā”œā”€ā”€ test_4B.rb
     ā”œā”€ā”€ test_4C.rb

Ignored files:

  • src/project1/1A.py
  • src/project1/1B.py
  • src/project1/1C.py
  • src/project2/2A.py
  • src/project2/2B.py
  • src/project2/2C.py
  • src/project3/3A.py
  • src/project3/3B.py
  • src/project3/3C.py

Ignoring Specific File Names

This rule will ignore any folders and files in any folder called "coverage".

ignore:
    - "**/coverage"

Sample file tree:

ā”œā”€ā”€ src/
     ā”œā”€ā”€ project1/
          ā”œā”€ā”€ 1A.py
          ā”œā”€ā”€ 1B.py
          ā”œā”€ā”€ 1C.py
          ā”œā”€ā”€ coverage/
               ā”œā”€ā”€ coverage.xml
     ā”œā”€ā”€ project2/
          ā”œā”€ā”€ 2A.py
          ā”œā”€ā”€ 2B.py
          ā”œā”€ā”€ 2C.py
          ā”œā”€ā”€ coverage/
               ā”œā”€ā”€ coverage.xml
     ā”œā”€ā”€ project3/
          ā”œā”€ā”€ 3A.py
          ā”œā”€ā”€ test_3A.rb
          ā”œā”€ā”€ 3B.py
          ā”œā”€ā”€ test_3B.rb
          ā”œā”€ā”€ 3C.py
          ā”œā”€ā”€ test_3C.rb
          ā”œā”€ā”€ coverage/
               ā”œā”€ā”€ coverage.xml
ā”œā”€ā”€ project2/.  
     ā”œā”€ā”€ 2A.py   
     ā”œā”€ā”€ 2B.py
     ā”œā”€ā”€ 2C.py
     ā”œā”€ā”€ coverage/
          ā”œā”€ā”€ coverage.xml
ā”œā”€ā”€ coverage/
     ā”œā”€ā”€ coverage.xml 

Ignored files:

  • src/project1/coverage/coverage.xml
  • src/project2/coverage/coverage.xml
  • src/project3/coverage/coverage.xml
  • project2/coverage/coverage.xml
  • coverage/coverage.xml