Skip to content

Commit

Permalink
Merge pull request #21 from e-kotov/main
Browse files Browse the repository at this point in the history
resync to main
  • Loading branch information
e-kotov authored Jul 7, 2024
2 parents d2e2ff8 + 25b0810 commit 5d2df87
Show file tree
Hide file tree
Showing 12 changed files with 239 additions and 124 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::pkgdown, local::.
extra-packages: any::pkgdown, any::bookdown, local::.
needs: website

- name: Build site
Expand Down
95 changes: 95 additions & 0 deletions .github/workflows/rhub.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# R-hub's generic GitHub Actions workflow file. It's canonical location is at
# https://github.com/r-hub/actions/blob/v1/workflows/rhub.yaml
# You can update this file to a newer version using the rhub2 package:
#
# rhub::rhub_setup()
#
# It is unlikely that you need to modify this file manually.

name: R-hub
run-name: "${{ github.event.inputs.id }}: ${{ github.event.inputs.name || format('Manually run by {0}', github.triggering_actor) }}"

on:
workflow_dispatch:
inputs:
config:
description: 'A comma separated list of R-hub platforms to use.'
type: string
default: 'linux,windows,macos'
name:
description: 'Run name. You can leave this empty now.'
type: string
id:
description: 'Unique ID. You can leave this empty now.'
type: string

jobs:

setup:
runs-on: ubuntu-latest
outputs:
containers: ${{ steps.rhub-setup.outputs.containers }}
platforms: ${{ steps.rhub-setup.outputs.platforms }}

steps:
# NO NEED TO CHECKOUT HERE
- uses: r-hub/actions/setup@v1
with:
config: ${{ github.event.inputs.config }}
id: rhub-setup

linux-containers:
needs: setup
if: ${{ needs.setup.outputs.containers != '[]' }}
runs-on: ubuntu-latest
name: ${{ matrix.config.label }}
strategy:
fail-fast: false
matrix:
config: ${{ fromJson(needs.setup.outputs.containers) }}
container:
image: ${{ matrix.config.container }}

steps:
- uses: r-hub/actions/checkout@v1
- uses: r-hub/actions/platform-info@v1
with:
token: ${{ secrets.RHUB_TOKEN }}
job-config: ${{ matrix.config.job-config }}
- uses: r-hub/actions/setup-deps@v1
with:
token: ${{ secrets.RHUB_TOKEN }}
job-config: ${{ matrix.config.job-config }}
- uses: r-hub/actions/run-check@v1
with:
token: ${{ secrets.RHUB_TOKEN }}
job-config: ${{ matrix.config.job-config }}

other-platforms:
needs: setup
if: ${{ needs.setup.outputs.platforms != '[]' }}
runs-on: ${{ matrix.config.os }}
name: ${{ matrix.config.label }}
strategy:
fail-fast: false
matrix:
config: ${{ fromJson(needs.setup.outputs.platforms) }}

steps:
- uses: r-hub/actions/checkout@v1
- uses: r-hub/actions/setup-r@v1
with:
job-config: ${{ matrix.config.job-config }}
token: ${{ secrets.RHUB_TOKEN }}
- uses: r-hub/actions/platform-info@v1
with:
token: ${{ secrets.RHUB_TOKEN }}
job-config: ${{ matrix.config.job-config }}
- uses: r-hub/actions/setup-deps@v1
with:
job-config: ${{ matrix.config.job-config }}
token: ${{ secrets.RHUB_TOKEN }}
- uses: r-hub/actions/run-check@v1
with:
job-config: ${{ matrix.config.job-config }}
token: ${{ secrets.RHUB_TOKEN }}
136 changes: 68 additions & 68 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,63 @@ contact:
email: kotov.egor@gmail.com
orcid: https://orcid.org/0000-0001-6690-5345
references:
- type: software
title: checkmate
abstract: 'checkmate: Fast and Versatile Argument Checks'
notes: Imports
url: https://mllg.github.io/checkmate/
repository: https://CRAN.R-project.org/package=checkmate
authors:
- family-names: Lang
given-names: Michel
email: michellang@gmail.com
orcid: https://orcid.org/0000-0001-9754-0393
year: '2024'
- type: software
title: cli
abstract: 'cli: Helpers for Developing Command Line Interfaces'
notes: Imports
url: https://cli.r-lib.org
repository: https://CRAN.R-project.org/package=cli
authors:
- family-names: Csárdi
given-names: Gábor
email: csardi.gabor@gmail.com
year: '2024'
- type: software
title: curl
abstract: 'curl: A Modern and Flexible Web Client for R'
notes: Imports
url: https://jeroen.r-universe.dev/curl
repository: https://CRAN.R-project.org/package=curl
authors:
- family-names: Ooms
given-names: Jeroen
email: jeroen@berkeley.edu
orcid: https://orcid.org/0000-0002-4035-0289
year: '2024'
- type: software
title: jsonlite
abstract: 'jsonlite: A Simple and Robust JSON Parser and Generator for R'
notes: Imports
url: https://jeroen.r-universe.dev/jsonlite
repository: https://CRAN.R-project.org/package=jsonlite
authors:
- family-names: Ooms
given-names: Jeroen
email: jeroen@berkeley.edu
orcid: https://orcid.org/0000-0002-4035-0289
year: '2024'
- type: software
title: utils
abstract: 'R: A Language and Environment for Statistical Computing'
notes: Imports
authors:
- name: R Core Team
institution:
name: R Foundation for Statistical Computing
address: Vienna, Austria
year: '2024'
- type: software
title: knitr
abstract: 'knitr: A General-Purpose Package for Dynamic Report Generation in R'
Expand All @@ -55,6 +112,17 @@ references:
email: xie@yihui.name
orcid: https://orcid.org/0000-0003-0645-5666
year: '2024'
- type: software
title: rJava
abstract: 'rJava: Low-Level R to Java Interface'
notes: Suggests
url: http://www.rforge.net/rJava/
repository: https://CRAN.R-project.org/package=rJava
authors:
- family-names: Urbanek
given-names: Simon
email: simon.urbanek@r-project.org
year: '2024'
- type: software
title: rmarkdown
abstract: 'rmarkdown: Dynamic Documents for R'
Expand Down Expand Up @@ -98,17 +166,6 @@ references:
email: rich@posit.co
orcid: https://orcid.org/0000-0003-3925-190X
year: '2024'
- type: software
title: rJava
abstract: 'rJava: Low-Level R to Java Interface'
notes: Suggests
url: http://www.rforge.net/rJava/
repository: https://CRAN.R-project.org/package=rJava
authors:
- family-names: Urbanek
given-names: Simon
email: simon.urbanek@r-project.org
year: '2024'
- type: software
title: testthat
abstract: 'testthat: Unit Testing for R'
Expand All @@ -121,61 +178,4 @@ references:
email: hadley@posit.co
year: '2024'
version: '>= 3.0.0'
- type: software
title: checkmate
abstract: 'checkmate: Fast and Versatile Argument Checks'
notes: Imports
url: https://mllg.github.io/checkmate/
repository: https://CRAN.R-project.org/package=checkmate
authors:
- family-names: Lang
given-names: Michel
email: michellang@gmail.com
orcid: https://orcid.org/0000-0001-9754-0393
year: '2024'
- type: software
title: cli
abstract: 'cli: Helpers for Developing Command Line Interfaces'
notes: Imports
url: https://cli.r-lib.org
repository: https://CRAN.R-project.org/package=cli
authors:
- family-names: Csárdi
given-names: Gábor
email: csardi.gabor@gmail.com
year: '2024'
- type: software
title: curl
abstract: 'curl: A Modern and Flexible Web Client for R'
notes: Imports
url: https://jeroen.r-universe.dev/curl
repository: https://CRAN.R-project.org/package=curl
authors:
- family-names: Ooms
given-names: Jeroen
email: jeroen@berkeley.edu
orcid: https://orcid.org/0000-0002-4035-0289
year: '2024'
- type: software
title: jsonlite
abstract: 'jsonlite: A Simple and Robust JSON Parser and Generator for R'
notes: Imports
url: https://jeroen.r-universe.dev/jsonlite
repository: https://CRAN.R-project.org/package=jsonlite
authors:
- family-names: Ooms
given-names: Jeroen
email: jeroen@berkeley.edu
orcid: https://orcid.org/0000-0002-4035-0289
year: '2024'
- type: software
title: utils
abstract: 'R: A Language and Environment for Statistical Computing'
notes: Imports
authors:
- name: R Core Team
institution:
name: R Foundation for Statistical Computing
address: Vienna, Austria
year: '2024'

9 changes: 6 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
Package: rJavaEnv
Title: Java Environments for R Projects
Version: 0.0.1
Authors@R:
Authors@R: c(
person("Egor", "Kotov", , "kotov.egor@gmail.com", role = c("aut", "cre", "cph"),
comment = c(ORCID = "0000-0001-6690-5345"))
comment = c(ORCID = "0000-0001-6690-5345")),
person("Mauricio", "Vargas", , "mavargas11@uc.cl", role = "ctb",
comment = c(ORCID = "0000-0003-1017-7574"))
)
Description: Install specific version of Java runtime environment at the R
project level. The goal of rJavaEnv is to manage multiple Java JDKs in
R projects by automatingthe process of downloading, installing, and
Expand Down Expand Up @@ -34,4 +37,4 @@ VignetteBuilder:
Config/testthat/edition: 3
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.1
RoxygenNote: 7.3.2.9000
1 change: 0 additions & 1 deletion R/internal_utilities.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ java_urls_load <- function() {
jsonlite::fromJSON(json_file, simplifyVector = FALSE)
}


#' Test all Java URLs
#'
#' @keywords internal
Expand Down
15 changes: 15 additions & 0 deletions R/java_download.R
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,11 @@ java_download <- function(version = 21,

url_template <- java_urls[[distribution]][[platform]][[arch]]
url <- gsub("\\{version\\}", version, url_template)
url_md5 <- gsub("latest/", "latest_checksum/", url)

dest_file <- file.path(dest_dir, basename(url))
dest_file_md5 <- paste0(file.path(dest_dir, basename(url_md5)), ".md5")


if (verbose) {
cli::cli_inform("Downloading Java {version} ({distribution}) for {platform} {arch} to {dest_file}", .envir = environment())
Expand All @@ -82,8 +85,20 @@ java_download <- function(version = 21,
}
} else {
curl::curl_download(url, dest_file, quiet = FALSE)
curl::curl_download(url_md5, dest_file_md5, quiet = TRUE)
if (verbose) {
cli::cli_inform("Download completed.", .envir = environment())

md5sum <- tools::md5sum(dest_file)
md5sum_expected <- readLines(dest_file_md5, warn = FALSE)

if (md5sum != md5sum_expected) {
cli::cli_alert_danger("MD5 checksum mismatch. Please try downloading the file again.", .envir = environment())
unlink(dest_file)
return(NULL)
} else {
cli::cli_inform("MD5 checksum verified.", .envir = environment())
}
}
}

Expand Down
5 changes: 2 additions & 3 deletions R/java_env.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#' }
java_env_set <- function(java_home,
where = c("both", "session", "project"),
verbose = T) {
verbose = TRUE) {
where <- match.arg(where)
checkmate::assertString(java_home)
checkmate::assertFlag(verbose)
Expand Down Expand Up @@ -159,7 +159,7 @@ java_check_version_rjava <- function(java_home = NULL, verbose = TRUE) {

# Process and print the output
if (length(output) > 0) {
if (any(grepl("error", tolower(output)))){
if (any(grepl("error", tolower(output)))) {
cli::cli_alert_danger("Failed to retrieve Java version.")
return(FALSE)
} else {
Expand All @@ -179,7 +179,6 @@ java_check_version_rjava <- function(java_home = NULL, verbose = TRUE) {
} else {
if (verbose) cli::cli_alert_danger("Failed to retrieve Java version.")
}

}

#' Check installed Java version using terminal commands
Expand Down
Loading

0 comments on commit 5d2df87

Please sign in to comment.