{"id":13484827,"url":"https://github.com/codecov/example-rust","last_synced_at":"2025-08-05T23:09:47.120Z","repository":{"id":4883702,"uuid":"47836521","full_name":"codecov/example-rust","owner":"codecov","description":null,"archived":false,"fork":false,"pushed_at":"2024-12-05T22:52:40.000Z","size":47,"stargazers_count":91,"open_issues_count":0,"forks_count":20,"subscribers_count":14,"default_branch":"main","last_synced_at":"2025-07-22T01:59:04.480Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codecov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-12-11T16:07:49.000Z","updated_at":"2025-03-31T13:30:51.000Z","dependencies_parsed_at":"2024-01-13T19:19:17.057Z","dependency_job_id":"6d713234-2d4c-4b45-ad86-62e02a6e9a21","html_url":"https://github.com/codecov/example-rust","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/codecov/example-rust","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codecov%2Fexample-rust","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codecov%2Fexample-rust/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codecov%2Fexample-rust/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codecov%2Fexample-rust/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codecov","download_url":"https://codeload.github.com/codecov/example-rust/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codecov%2Fexample-rust/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268987471,"owners_count":24340667,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-05T02:00:12.334Z","response_time":2576,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T17:01:35.232Z","updated_at":"2025-08-05T23:09:47.067Z","avatar_url":"https://github.com/codecov.png","language":"Rust","readme":"# [Codecov][1] Rust Example\n[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fcodecov%2Fexample-rust.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fcodecov%2Fexample-rust?ref=badge_shield)\n\n\n**As of July 2, 2016, there is [no option to make rustdoc generate a runnable test executable][7]. That means that documentation tests will not show in your coverage data. If you discover a way to run the doctest executable with kcov, please open an issue in our [feedback repository](https://github.com/codecov/feedback) and we will add that to these instructions.**\n\n## Guide\n### Travis Setup\n\nAdd to your `.travis.yml` file.\n\n**NOTE: You should change `examplerust` in `for file in target/debug/examplerust-* ...` (under `after_success`) to match your package name.** For example, if your package name is `minigrep`, then the lines should be changed to `for file in target/debug/minigrep-* ...`. If you are not sure what your package name is, it can also be found in `Cargo.toml` and it is usually the same name as when you had initialised the project.\n```yml\nlanguage: rust\n\nsudo: required\n\nrust:\n  - stable\n  - beta\n  - nightly\n\nmatrix:\n  allow_failures:\n    - rust: nightly\n\naddons:\n  apt:\n    packages:\n      - libcurl4-openssl-dev\n      - libelf-dev\n      - libdw-dev\n      - cmake\n      - gcc\n      - binutils-dev\n      - libiberty-dev\n\nafter_success: |\n  wget https://github.com/SimonKagstrom/kcov/archive/master.tar.gz \u0026\u0026\n  tar xzf master.tar.gz \u0026\u0026\n  cd kcov-master \u0026\u0026\n  mkdir build \u0026\u0026\n  cd build \u0026\u0026\n  cmake .. \u0026\u0026\n  make \u0026\u0026\n  make install DESTDIR=../../kcov-build \u0026\u0026\n  cd ../.. \u0026\u0026\n  rm -rf kcov-master \u0026\u0026\n  for file in target/debug/examplerust-*; do [ -x \"${file}\" ] || continue; mkdir -p \"target/cov/$(basename $file)\"; ./kcov-build/usr/local/bin/kcov --exclude-pattern=/.cargo,/usr/lib --verify \"target/cov/$(basename $file)\" \"$file\"; done \u0026\u0026\n  bash \u003c(curl -s https://codecov.io/bash) \u0026\u0026\n  echo \"Uploaded code coverage\"\n```\nThis will automatically run each executable and store the results in a\ndifferent directory. Codecov will automatically find the `cobertura.xml`\nfiles that `kcov` generates and combine the results.\n\n#### Other CI services\n- Adjust the materials in the above example as necessary for your CI.\n- Add CODECOV_TOKEN=\u003cyour repo token\u003e to your CI's environment variables. (Don't store the raw token in your repo.)\n- Run bash \u003c(curl -s https://codecov.io/bash) after tests complete.\n\n### Produce Coverage Reports\n\nRun your tests with [kcov][6] in order to create the necessary coverage\nreports. For example:\n\n```\nkcov --exclude-pattern=/.cargo,/usr/lib --verify target/cov target/debug/\u003cPROJECT-NAME\u003e-\u003chash\u003e\n```\n\n`\u003cPROJECT-NAME\u003e` and `\u003chash\u003e` are the appropriate project name and hash for\nyour executable.\n\nThe hash at the end may change if cargo generates different test\nexecutables with the same name. If you are building your code\ndifferently or without cargo, change the last two arguments\nto kcov to respectively represent where you want the coverage to\nbe stored and which executable to run.\n\nAttempting to run `kcov` with an executable argument ending in a wildcard\nlike `\u003cPROJECT-NAME\u003e-*` may result in incorrect coverage results as only a\nsingle test executable will run. **For best results, run the kcov command\nfor each test executable and store the results in separate directories.**\nCodecov will automatically find and upload the cobertura.xml files and\nmerge the coverage for you.\n\nNote that setting the environment variable `RUSTFLAGS=\"-C link-dead-code\"`\nduring tests build may improve coverage accuracy by preventing dead-code elimination.\nDo not set this variable when creating release builds since it will increase\nbinary size.\n\nAfter you've run the tests and created a cobertura.xml report, you can\nuse [the Codecov global uploader][4] to push that report to Codecov.\nSee below for further details.\n\nInstalling `kcov` is largely dependent on your operating system. It is\ndemonstrated to work on Linux systems but may not be fully compatible with\nWindows or OS X. Please lookup the appropriate installation instructions.\nThe Travis CI example below demonstrates installing `kcov` on a Linux\ncomputer.\n\n## Caveats\n### Private Repos\nAdd to your `.travis.yml` file.\n```yml\nafter_success:\n  - bash \u003c(curl -s https://codecov.io/bash) -t uuid-repo-token\n```\n### `kcov` Version\n\nThe version of `kcov` that is distributed with your package manager may not\nwork with Rust binaries. You usually need to manually build the latest\nmaster branch and run kcov from there. All of this is taken care of for you\nin the `.travis.yml` file.\n\n1. More documentation at https://docs.codecov.io\n2. Configure codecov through the `codecov.yml`  https://docs.codecov.io/docs/codecov-yaml\n\nWe are happy to help if you have any questions. Please contact email our Support at [support@codecov.io](mailto:support@codecov.io)\n\n[1]: https://codecov.io/\n[5]: http://codecov.io/github/codecov/example-rust?branch=master\n[6]: https://simonkagstrom.github.io/kcov/\n[7]: http://stackoverflow.com/questions/35547710/does-rustdoc-generate-runnable-binaries\n[8]: https://github.com/codecov/example-rust/issues\n\n\n## License\n[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fcodecov%2Fexample-rust.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Fcodecov%2Fexample-rust?ref=badge_large)\n","funding_links":[],"categories":["Rust","Examples"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodecov%2Fexample-rust","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodecov%2Fexample-rust","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodecov%2Fexample-rust/lists"}