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