├── .Rbuildignore ├── .github └── workflows │ └── enforce-license-compliance.yml ├── .gitignore ├── .travis.yml ├── DESCRIPTION ├── LICENSE.md ├── NAMESPACE ├── R ├── tested.R └── untested.R ├── README.md ├── Rscript_covr.png ├── Rscript_covr_success.png ├── build_passing.png ├── codecov.R.Rproj ├── example-r.Rproj ├── man ├── tested.Rd └── untested.Rd └── tests ├── testthat.R └── testthat └── test-allwehave.R /.Rbuildignore: -------------------------------------------------------------------------------- 1 | .travis.yml 2 | ^.*\.Rproj$ 3 | ^\.Rproj\.user$ 4 | 5 | # ignore pictures for readme.md 6 | ^.*\.png$ 7 | 8 | -------------------------------------------------------------------------------- /.github/workflows/enforce-license-compliance.yml: -------------------------------------------------------------------------------- 1 | name: Enforce License Compliance 2 | 3 | on: 4 | pull_request: 5 | branches: [main, master] 6 | 7 | jobs: 8 | enforce-license-compliance: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - name: 'Enforce License Compliance' 12 | uses: getsentry/action-enforce-license-compliance@57ba820387a1a9315a46115ee276b2968da51f3d # main 13 | with: 14 | fossa_api_key: ${{ secrets.FOSSA_API_KEY }} 15 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .Rproj.user 2 | .Rhistory 3 | .RData 4 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: r 2 | 3 | sudo: required 4 | 5 | env: _R_CHECK_CRAN_INCOMING_=FALSE 6 | 7 | r_packages: 8 | - covr 9 | - devtools 10 | 11 | r_github_packages: 12 | - codecov/example-r 13 | 14 | after_success: 15 | - Rscript -e 'library(covr);codecov()' 16 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: codecov.R 2 | Version: 0.1 3 | Title: A Minimal R Package Including Some Unit Tests 4 | Description: This package demostrates how "covr" and "codecov.io" can 5 | report test coverage on R packages. 6 | Encoding: UTF-8 7 | Authors@R: 8 | person("Gergely", "Daróczi", , "daroczig@rapporter.net", c("aut", "cre")) 9 | License: GPL-3 10 | Suggests: testthat 11 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Codecov 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2 (4.1.1): do not edit by hand 2 | 3 | export(tested) 4 | export(untested) 5 | -------------------------------------------------------------------------------- /R/tested.R: -------------------------------------------------------------------------------- 1 | #' Demo function to return numbers 2 | #' @param x character or numeric vector 3 | #' @return numeric vector 4 | #' @export 5 | tested <- function(x) { 6 | 7 | ## error handling 8 | if (!(is.numeric(x) | is.character(x))) { 9 | stop('Wrong object type, only numeric or character is supported.') 10 | } 11 | 12 | ## do something with numbers 13 | if (is.numeric(x)) { 14 | 15 | return(x) 16 | 17 | } else { 18 | 19 | ## convert to numeric 20 | x <- as.numeric(x) 21 | 22 | } 23 | 24 | ## return stuff 25 | x * 2 26 | 27 | } 28 | -------------------------------------------------------------------------------- /R/untested.R: -------------------------------------------------------------------------------- 1 | #' Demo function to return the value of pi 2 | #' @return something like 3.14 3 | #' @export 4 | untested <- function() 5 | pi 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # [Codecov](https://codecov.io) R Example 2 | 3 | [![codecov](https://codecov.io/github/codecov/example-r/branch/master/graphs/badge.svg)](https://codecov.io/github/codecov/example-r) 4 | [![Build Status](https://img.shields.io/travis/codecov/example-r/master.svg)](https://travis-ci.org/codecov/example-r) 5 | [![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fcodecov%2Fexample-r.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fcodecov%2Fexample-r?ref=badge_shield) 6 | 7 | ## Guide 8 | ### Travis Setup 9 | 10 | Add to your `.travis.yml` file. 11 | 12 | ```yml 13 | language: r 14 | 15 | r_packages: 16 | - covr 17 | 18 | after_success: 19 | - Rscript -e 'library(covr); codecov()' 20 | ``` 21 | 22 | ## Caveats 23 | ### Private Repo 24 | Repository tokens are required for (a) all private repos, (b) public repos not using Travis-CI, CircleCI or AppVeyor. Find your repository token at Codecov and provide via appending `-t ` to you where you upload reports. 25 | 26 | ## Links 27 | - [Community Boards](https://community.codecov.io) 28 | - [Support](https://codecov.io/support) 29 | - [Documentation](https://docs.codecov.io) 30 | 31 | 32 | ## License 33 | [![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fcodecov%2Fexample-r.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Fcodecov%2Fexample-r?ref=badge_large) -------------------------------------------------------------------------------- /Rscript_covr.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codecov/example-r/911b84bdcf80cb5df24644cc93e2f60bc8aa0f3c/Rscript_covr.png -------------------------------------------------------------------------------- /Rscript_covr_success.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codecov/example-r/911b84bdcf80cb5df24644cc93e2f60bc8aa0f3c/Rscript_covr_success.png -------------------------------------------------------------------------------- /build_passing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codecov/example-r/911b84bdcf80cb5df24644cc93e2f60bc8aa0f3c/build_passing.png -------------------------------------------------------------------------------- /codecov.R.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: No 4 | SaveWorkspace: No 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: knitr 13 | LaTeX: pdfLaTeX 14 | 15 | AutoAppendNewline: Yes 16 | StripTrailingWhitespace: Yes 17 | 18 | BuildType: Package 19 | PackageUseDevtools: Yes 20 | PackageInstallArgs: --no-multiarch --with-keep.source 21 | PackageRoxygenize: rd,collate,namespace 22 | -------------------------------------------------------------------------------- /example-r.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: Default 4 | SaveWorkspace: Default 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: Sweave 13 | LaTeX: pdfLaTeX 14 | 15 | AutoAppendNewline: Yes 16 | StripTrailingWhitespace: Yes 17 | 18 | BuildType: Package 19 | PackageUseDevtools: Yes 20 | PackageInstallArgs: --no-multiarch --with-keep.source 21 | -------------------------------------------------------------------------------- /man/tested.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.1.1): do not edit by hand 2 | % Please edit documentation in R/tested.R 3 | \name{tested} 4 | \alias{tested} 5 | \title{Demo function to return numbers} 6 | \usage{ 7 | tested(x) 8 | } 9 | \arguments{ 10 | \item{x}{character or numeric vector} 11 | } 12 | \value{ 13 | numeric vector 14 | } 15 | \description{ 16 | Demo function to return numbers 17 | } 18 | 19 | -------------------------------------------------------------------------------- /man/untested.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2 (4.1.1): do not edit by hand 2 | % Please edit documentation in R/untested.R 3 | \name{untested} 4 | \alias{untested} 5 | \title{Demo function to return the value of pi} 6 | \usage{ 7 | untested() 8 | } 9 | \value{ 10 | something like 3.14 11 | } 12 | \description{ 13 | Demo function to return the value of pi 14 | } 15 | 16 | -------------------------------------------------------------------------------- /tests/testthat.R: -------------------------------------------------------------------------------- 1 | ## load dependencies 2 | library(testthat) 3 | library(codecov.R) 4 | 5 | ## test package 6 | test_check('codecov.R') 7 | -------------------------------------------------------------------------------- /tests/testthat/test-allwehave.R: -------------------------------------------------------------------------------- 1 | context('functions') 2 | 3 | test_that('We got numbers', { 4 | expect_equal(tested(5), 5) 5 | }) 6 | --------------------------------------------------------------------------------