From 8d569a8dadd7ebbc33e8695b3d36ad6a90a7e927 Mon Sep 17 00:00:00 2001 From: Jeroen Ooms Date: Sun, 7 Jan 2024 01:18:19 +0100 Subject: [PATCH] Add needs_compilation --- DESCRIPTION | 2 +- NAMESPACE | 1 + R/buildtools.R | 7 +++++++ action.yml | 3 +++ entrypoint.sh | 6 ++++++ man/buildtools.Rd | 3 +++ 6 files changed, 21 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index d7248ef..9fd4a45 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -25,7 +25,7 @@ Imports: rmarkdown, yaml, xml2 -RoxygenNote: 7.2.1 +RoxygenNote: 7.2.3 Remotes: ropensci/postdoc, r-lib/remotes diff --git a/NAMESPACE b/NAMESPACE index a01401d..c9d0d3d 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -14,6 +14,7 @@ export(get_package_datasets) export(install_dependencies) export(install_sysdeps) export(maintainer_info_base64) +export(needs_compilation) export(read_description_field) export(render_article) export(render_html_manual) diff --git a/R/buildtools.R b/R/buildtools.R index ab87659..694bd39 100644 --- a/R/buildtools.R +++ b/R/buildtools.R @@ -699,6 +699,13 @@ generate_metadata_files <- function(package, repo, subdir, outdir, pkgdir, git_u jsonlite::write_json(Filter(function(x){!is.null(x)}, contents), path = file.path(extra_dir, 'contents.json')) } +#' @export +#' @rdname buildtools +needs_compilation <- function(package){ + desc <- as.data.frame(read.dcf(system.file('DESCRIPTION', package = package))) + desc$NeedsCompilation +} + #' @export #' @rdname buildtools maintainer_info_base64 <- function(path = '.'){ diff --git a/action.yml b/action.yml index eef621b..db0dbbb 100644 --- a/action.yml +++ b/action.yml @@ -37,6 +37,9 @@ outputs: description: 'Base64 encoded JSON list with commit data' GITSTATS: description: 'Base64 encoded JSON list with git stats' + NEEDS_COMPILATION: + description: 'If the source package has a src dir' + runs: using: 'docker' image: 'docker://ghcr.io/r-universe-org/build-source' diff --git a/entrypoint.sh b/entrypoint.sh index 8fc2972..cedf71c 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -194,6 +194,12 @@ if [ "$MANUAL_FAILURE" ]; then cat stderr_manual.txt fi +# Test if package needs compilation (R simply checks if there is a 'src' dir) +NEEDS_COMPILATION=$(Rscript -e "cat(buildtools::needs_compilation('${PACKAGE}'))") +if [ "$NEEDS_COMPILATION" == "yes" ]; then +echo "NEEDS_COMPILATION=yes" >> $GITHUB_OUTPUT +fi + # Find readme URL export README_URL=$(Rscript -e "cat(buildtools::find_readme_url('$URL', '$SUBDIR'))") if [ "$README_URL" ]; then diff --git a/man/buildtools.Rd b/man/buildtools.Rd index 100fcc8..acace77 100644 --- a/man/buildtools.Rd +++ b/man/buildtools.Rd @@ -19,6 +19,7 @@ \alias{get_help_metadata} \alias{get_package_datasets} \alias{generate_metadata_files} +\alias{needs_compilation} \alias{maintainer_info_base64} \alias{tweak_help_files} \title{Build tools} @@ -59,6 +60,8 @@ get_package_datasets(package) generate_metadata_files(package, repo, subdir, outdir, pkgdir, git_url) +needs_compilation(package) + maintainer_info_base64(path = ".") tweak_help_files(path)