Skip to content

Commit

Permalink
Update test-coverage.yaml
Browse files Browse the repository at this point in the history
added uploaded action
          token: ${{ secrets.CODECOV_TOKEN }}

Update test-coverage.yaml

removed
          # token: ${{ secrets.CODECOV_TOKEN }}
to confirm that it is not useful

Update test-coverage.yaml

https://github.com/codecov/example-python/blob/main/.github/workflows/ci.yml

https://app.codecov.io/gh/JohnGavin/hellow/new

Update test-coverage.yaml

from r-lib/covr#430

Update test-coverage.yaml

v3 -> v4
        uses: actions/upload-artifact@v4

Update test-coverage.yaml

v4->v3 second try

Update test-coverage.yaml

trying again

Update test-coverage.yaml

v4 -> v3
      uses: actions/upload-artifact@v3

Update test-coverage.yaml

v4 to v3
codecov/codecov-action#1274

Add GitHub links to DESCRIPTION

Initial commit
  • Loading branch information
JohnGavin committed Aug 13, 2024
0 parents commit 8eb297d
Show file tree
Hide file tree
Showing 26 changed files with 403 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
^hellow\.Rproj$
^\.Rproj\.user$
^LICENSE\.md$
_quarto.yml
about.qmd
hellow.code-workspace
index.qmd
styles.css
^\.github$
^docker$
1 change: 1 addition & 0 deletions .github/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.html
65 changes: 65 additions & 0 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]

name: test-coverage.yaml

permissions: read-all

jobs:
test-coverage:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::covr, any::xml2
needs: coverage

- name: Test coverage
run: |
covr::codecov(token = "${{ secrets.CODECOV_TOKEN }}")
cov <- covr::package_coverage(
quiet = FALSE,
clean = FALSE,
install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package")
)
covr::to_cobertura(cov)
shell: Rscript {0}

- name: Upload coverage reports to Codecov
# uses: codecov/codecov-action@v4.0.1
uses: codecov/codecov-action@v4
with:
# token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

- name: Show testthat output
if: always()
run: |
## --------------------------------------------------------------------
find '${{ runner.temp }}/package' -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash

- name: Upload test results
if: failure()
uses: actions/upload-artifact@v4
with:
name: coverage-test-failures
path: ${{ runner.temp }}/package
token: ${{ secrets.CODECOV_TOKEN }}

6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.Rproj.user
.Rhistory
.Rdata
.httr-oauth
.DS_Store
.quarto
17 changes: 17 additions & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Package: hellow
Title: What the Package Does (One Line, Title Case)
Version: 0.0.0.9001
Authors@R:
person("John", "Gavin", , "john.b.gavin@gmail.com", role = c("aut", "cre"))
Description: What the package does (one paragraph).
License: MIT + file LICENSE
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.2.9000
Imports:
praise
Suggests:
testthat (>= 3.0.0)
Config/testthat/edition: 3
URL: https://github.com/JohnGavin/hellow
BugReports: https://github.com/JohnGavin/hellow/issues
2 changes: 2 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
YEAR: 2024
COPYRIGHT HOLDER: john gavin
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# MIT License

Copyright (c) 2024 john gavin

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
3 changes: 3 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Generated by roxygen2: do not edit by hand

export(isay)
19 changes: 19 additions & 0 deletions R/isay.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Cmd-Shift-D: Document with Roxygen

#' say hellp
#'
#' @param size number of time to greet
#' @param ... other args passed to [sample()].
#'
#' @return a greeting
#' @export
#'
#' @examples
#'


isay <- function(size=1, ...) {
message(praise::praise())
h <- sample(c("Hello", "Hi", "Howdy", "What's up?"), size=size, ...)
return(h)
}
19 changes: 19 additions & 0 deletions _quarto.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
project:
type: website

website:
title: "new_project_hellow"
navbar:
left:
- href: index.qmd
text: Home
- about.qmd

format:
html:
theme: cosmo
css: styles.css
toc: true



5 changes: 5 additions & 0 deletions about.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: "About"
---

About this site
46 changes: 46 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@

# https://blog.stephenturner.us/p/r-package-development-in-positron
# pak::pak('exactextractr')
# pracpac::use_docker()
# pracpac::use_docker(build = FALSE, use_case = "pipeline")
# add the line to install a few additional system utilities using apt, and actually write this shell script. The pracpac package templated out everything else.
# build local docker file with 'hellow' tag
# docker build -t ttmmghmm/hellow:latest -t hellow:0.0.0.9000 ./docker
# docker run --rm ttmmghmm/hellow:latest
# not docker build -f Dockerfile ./docker
# https://stackoverflow.com/questions/34434231/docker-how-to-authenticate-for-docker-push
# docker login --username=ttmmghmm
# not docker login -u="${DOCKER_USERNAME}" -p="${DOCKER_PASSWORD}"
# docker push ttmmghmm/hellow:latest
# docker pull ttmmghmm/hellow:latest


# TODO: switch to rix

FROM rocker/r-ver:latest

## copy the renv.lock into the image
COPY renv.lock /renv.lock

## install renv
RUN Rscript -e 'install.packages(c("renv"))'

## set the renv path var to the renv lib
ENV RENV_PATHS_LIBRARY renv/library

## restore packages from renv.lock
RUN Rscript -e 'renv::restore(lockfile="/renv.lock", repos=NULL)'

## copy in built R package
COPY hellow_0.0.0.9001.tar.gz /hellow_0.0.0.9001.tar.gz

## run script to install built R package from source
RUN Rscript -e 'install.packages("/hellow_0.0.0.9001.tar.gz", type="source", repos=NULL)'


RUN apt-get update && apt-get install -y bsdmainutils translate-shell

COPY assets/run.sh /run.sh
COPY assets/pre.R /pre.R

CMD ["bash", "/run.sh"]
5 changes: 5 additions & 0 deletions docker/assets/pre.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@


library(hellow)

isay()
9 changes: 9 additions & 0 deletions docker/assets/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

# https://blog.stephenturner.us/p/r-package-development-in-positron

# get translation language from first arg: default is french
TOLANG="${1:-:fr}"
HELLO=$(Rscript /pre.R)

trans "$HELLO" "$TOLANG"
Binary file added docker/hellow_0.0.0.9001.tar.gz
Binary file not shown.
24 changes: 24 additions & 0 deletions docker/renv.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"R": {
"Version": "4.4.1",
"Repositories": [
{
"Name": "ropenscireviewtools",
"URL": "https://ropensci-review-tools.r-universe.dev"
},
{
"Name": "CRAN",
"URL": "https://cloud.r-project.org"
}
]
},
"Packages": {
"praise": {
"Package": "praise",
"Version": "1.0.0",
"Source": "Repository",
"Repository": "CRAN",
"Hash": "a555924add98c99d2f411e37e7d25e9f"
}
}
}
17 changes: 17 additions & 0 deletions hellow.Rproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Version: 1.0

RestoreWorkspace: No
SaveWorkspace: No
AlwaysSaveHistory: Default

EnableCodeIndexing: Yes
Encoding: UTF-8

AutoAppendNewline: Yes
StripTrailingWhitespace: Yes
LineEndingConversion: Posix

BuildType: Package
PackageUseDevtools: Yes
PackageInstallArgs: --no-multiarch --with-keep.source
PackageRoxygenize: rd,collate,namespace
11 changes: 11 additions & 0 deletions hellow.code-workspace
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"folders": [
{
"path": "hellow"
},
{
"path": "."
}
],
"settings": {}
}
76 changes: 76 additions & 0 deletions index.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
---
params:
source_url: "https://blog.stephenturner.us/p/r-package-development-in-positron"
title: "r-package-development-in-positron"
---

This is a Quarto website.

To learn more about Quarto websites visit <https://quarto.org/docs/websites>.

# usethis
+ dependency management,
+ DESCRIPTION file manipulation,
+ .R and test file creation,
+ data-raw creation,
+ vignettes,
+ pkgdown,
+ GitHub actions ...

```{r, eval = FALSE}
usethis::create_packagesw("hellow")
usethis::use_mit_license("john gavin")
usethis::use_package("praise")
#
# Cmd-Shift-D: Document with Roxygen
#
devtools::document()
# cmd-shift-E
devtools::check()
# RStudio keyboard shortcut cmd-shift-B
devtools::build()
pak::local_install()
usethis::use_test("hello")
# cmd-shift-T
devtools::test()
```

+ RStudio uses `R CMD INSTALL`
+ Positron uses `pak::local_install()`

## covr
+ https://covr.r-lib.org/

```{r}
library(covr)
report() # requries DT
# or
if (interactive()) {
# covr::report(covr::package_coverage())
usethis::use_github_action("test-coverage")
}
```

## pracpac
+ R Packaging with Docker

```{r}
# pak::pak('pracpac')
# add renv.lock file and a Dockerfile
pracpac::use_docker() # analyzes package DESCRIPTION
```
+ build renv lock file
+ captures versions of dependent packages installed
+ writes Dockerfile builds R package
+ install all dependencies from renv lock file
+ guarantees dependent pkgs versions install in Docker image
+ templates out pre- and post-processing R scripts
+ shell script that will drive the analysis

## workflow
+ https://www.tidyverse.org/blog/2017/12/workflow-vs-script/
```{r}
library(here)
```
1 change: 1 addition & 0 deletions inst/qmd/symlink pins_download_local_board.qmd
1 change: 1 addition & 0 deletions inst/qmd/symlink rix.qmd
1 change: 1 addition & 0 deletions inst/qmd/symlink usethis_targets.qmd
Loading

0 comments on commit 8eb297d

Please sign in to comment.