File search (original) (raw)

We do a depth first search through all directories for files that have names or paths that expect what we're looking for.

We do 2 searches with both being optional:

There are 4 arguments you can pass to Codecov to customize the files it uploads.

The search_root and folders_to_ignore are useful for specifying which files to upload in the automated search, and also have the side effect of skipping searching through directories that may have a bunch of files we don't care about, thus improving the speed of looking for files to upload.

The usage of these options can be best explained using examples, and the files that will be uploaded in those examples.

🚧

In these examples, we are going to be ignoring any other arguments you may need to pass to the CLI or Action in order for Codecov to work, like the Token. We will only focus on the arguments that affect file searching.

Let's say we have the following directory structure, where dir is the root of our git repo:

dir/
├── subdir1/
│   ├── sub_subdir1/
│   │   └── coverage1.xml
│   └── sub_subdir2/
│       └── coverage2.xml
└── subdir2/
    ├── sub_subdir1/
    │   └── coverage3.xml
    └── sub_subdir2/
        └── coverage4.xml

This will upload all the files in this directory:

codecovcli
uses: codecov/codecov-action@v5

This will find no files and fail:

codecovcli --disable-search
uses: codecov/codecov-action@v5
with:
    disable_search: true

This will upload only the files found in subdir1, so coverage1.xml and coverage2.xml

codecovcli --dir subdir1
uses: codecov/codecov-action@v5
with:
    directory: "subdir1"

This will upload coverage2.xml and coverage4.xml since we're starting our search through all directories that don't have the name sub_subdir1

codecovcli --exclude sub_subdir1
uses: codecov/codecov-action@v5
with:
    exclude: "sub_subdir1"

This will upload coverage2.xml since we're starting our search in subdir1 that don't have the name sub_subdir1

codecovcli --dir subdir1 --exclude sub_subdir1
uses: codecov/codecov-action@v5
with:
    directory: "subdir1"
    exclude: "sub_subdir1"

This will upload coverage1.xml since we're starting our search in subdir1 that have the path relative to the directory in which we're running codecov: subdir1/sub_subdir1/coverage1.xml

codecovcli --disable-search --dir subdir1 --file subdir1/sub_subdir1/coverage1.xml 
uses: codecov/codecov-action@v5
with:
    disable_search: true
    directory: "subdir1"
    files: "subdir1/sub_subdir1/coverage1.xml"

This will upload coverage1.xml since we're starting our search in subdir1/sub_subdir1 that have the path relative to the directory in which we're running codecov: subdir1/sub_subdir1/coverage1.xml

codecovcli --disable-search --dir subdir1/sub_subdir1 --file subdir1/sub_subdir1/coverage1.xml 
uses: codecov/codecov-action@v5
with:
    disable_search: true
    directory: "subdir1/sub_subdir1"
    files: "subdir1/sub_subdir1/coverage1.xml"