Skip to content

Commit

Permalink
Correct errors reported by GitHub actions
Browse files Browse the repository at this point in the history
- Configure integration with codecov.io.
- Add status badge to README.Rmd showing percentage of code coverage.
- Add badge to README.Rmd showing package version on CRAN.
  • Loading branch information
pakjiddat committed Jun 14, 2021
1 parent 4473e3e commit 8af9460
Show file tree
Hide file tree
Showing 11 changed files with 62 additions and 11 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@
^vignettes/features_cache$
^vignettes/overview_cache$
^CRAN-RELEASE$
^codecov\.yml$
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,7 @@ jobs:
- name: Check
run: |
options(crayon.enabled = TRUE)
rcmdcheck::rcmdcheck(args = "--no-manual", error_on = "error")
d <- rcmdcheck::rcmdcheck(args = "--no-manual --no-build-vignettes --ignore-vignettes", error_on = "error", check_dir = "check")
print(d)
rcmdcheck::check_failures(path = "check")
shell: Rscript {0}
2 changes: 1 addition & 1 deletion .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@ jobs:
shell: Rscript {0}

- name: Test coverage
run: covr::codecov()
run: testthat::test_dir(path = "tests/testthat/")
shell: Rscript {0}
4 changes: 2 additions & 2 deletions CRAN-RELEASE
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
This package was submitted to CRAN on 2021-06-10.
Once it is accepted, delete this file and tag the release (commit d4046b8).
This package was submitted to CRAN on 2021-06-11.
Once it is accepted, delete this file and tag the release (commit 40778a5).
8 changes: 7 additions & 1 deletion R/env-manager.R
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,16 @@ EnvManager <- R6::R6Class(
# The wordpredictor options are updated
options("wordpredictor" = wp)

d1 <- system.file("extdata", package = "wordpredictor")
d2 <- system.file(package = "wordpredictor")
print(d1)
list.files(d2)

# Each file is copied from inst/extdata to the given folder
for (fn in fns) {
# The source file path
sfp <- system.file("extdata", fn, package = "wordpredictor")
sfp <- system.file(
"extdata", fn, package = "wordpredictor", mustWork = T)
# If the source file path does not exist
if (!file.exists(sfp)) {
stop(getwd())
Expand Down
2 changes: 2 additions & 0 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ clean_up <- function(ve) {
[![R-CMD-check](https://github.com/pakjiddat/word-predictor/workflows/R-CMD-check/badge.svg)](https://github.com/pakjiddat/word-predictor/actions)
[![lint](https://github.com/pakjiddat/word-predictor/workflows/lint/badge.svg)](https://github.com/pakjiddat/word-predictor/actions)
[![test-coverage](https://github.com/pakjiddat/word-predictor/workflows/test-coverage/badge.svg)](https://github.com/pakjiddat/word-predictor/actions)
[![Codecov test coverage](https://codecov.io/gh/pakjiddat/word-predictor/branch/master/graph/badge.svg)](https://codecov.io/gh/pakjiddat/word-predictor?branch=master)
[![CRAN version](https://www.r-pkg.org/badges/version/wordpredictor)](https://cran.r-project.org/package=wordpredictor)
<!-- badges: end -->

The goal of the wordpredictor package is to provide a flexible and easy to use framework for generating [n-gram models](https://en.wikipedia.org/wiki/N-gram) for word prediction.
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
[![R-CMD-check](https://github.com/pakjiddat/word-predictor/workflows/R-CMD-check/badge.svg)](https://github.com/pakjiddat/word-predictor/actions)
[![lint](https://github.com/pakjiddat/word-predictor/workflows/lint/badge.svg)](https://github.com/pakjiddat/word-predictor/actions)
[![test-coverage](https://github.com/pakjiddat/word-predictor/workflows/test-coverage/badge.svg)](https://github.com/pakjiddat/word-predictor/actions)
[![Codecov test
coverage](https://codecov.io/gh/pakjiddat/word-predictor/branch/master/graph/badge.svg)](https://codecov.io/gh/pakjiddat/word-predictor?branch=master)
[![CRAN
version](https://www.r-pkg.org/badges/version/wordpredictor)](https://cran.r-project.org/package=wordpredictor)
<!-- badges: end -->

The goal of the wordpredictor package is to provide a flexible and easy
Expand Down
26 changes: 26 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
comment: false

coverage:
status:
project:
default:
target: auto
threshold: 1%
informational: true
patch:
default:
target: auto
threshold: 1%
informational: true

codecov:
token: 8cd3b4cb-4ba6-4f09-b302-61a856b82970
language: R

sudo: false

cache: packages

after_success:

- Rscript -e 'covr::codecov()'
15 changes: 13 additions & 2 deletions tests/testthat/inc.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,16 @@
wp <- getOption("wordpredictor")
# An object of class EnvManager is created
em <- EnvManager$new(ve = wp$ve)
# The required files are downloaded
ed <- em$setup_env(wp$rf)

tryCatch({
# The required files are downloaded
ed <- em$setup_env(wp$rf)
},
error = function(cond) {
print(cond)
traceback()
},
warning = function(cond) {
print(cond)
traceback()
})
2 changes: 1 addition & 1 deletion tests/testthat/setup.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ for (fn in fl) {
# nolint end

# If level of verbosity in the information messages
ve <- 0
ve <- 2
# The action to take after the test ends
ea <- "t"

Expand Down
5 changes: 2 additions & 3 deletions vignettes/overview.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,8 @@ ed <- setup_env(rf, ve)
# The following code generates n-gram model using default options for data
# cleaning and tokenization. See the following section on how to customize these
# options. Note that input.txt is the name of the input data file. It should be
# present in the data directory. ddir is the data directory. mdir is the model
# directory. The output model file, which is def-model.RDS will be placed in
# this directory.
# present in the ed directory. The generated model file is also placed in this
# directory.
# ModelGenerator class object is created
mg <- ModelGenerator$new(
Expand Down

0 comments on commit 8af9460

Please sign in to comment.