Skip to content

Commit

Permalink
merge with old stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
jeroen committed Apr 15, 2024
1 parent ecb66ac commit 8fac2da
Show file tree
Hide file tree
Showing 15 changed files with 311 additions and 2 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Build Docker Image

on:
push:
branches:
- 'v1'
workflow_dispatch:

jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to GHCR (GitHub Packages)
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
id: docker_build
uses: docker/build-push-action@v5
with:
push: true
tags: |
ghcr.io/${{github.repository}}:latest
4 changes: 2 additions & 2 deletions .github/workflows/recheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
prepare:
name: Prepare dependencies
runs-on: ubuntu-latest
container: ghcr.io/r-universe-org/recheck
container: ghcr.io/r-devel/recheck
outputs:
oldfile: ${{ steps.filenames.outputs.oldfile }}
newfile: ${{ steps.filenames.outputs.newfile }}
Expand Down Expand Up @@ -66,7 +66,7 @@ jobs:
needs: prepare
runs-on: ubuntu-latest
name: Recheck ${{matrix.check == 'oldpkg' && needs.prepare.outputs.oldfile || needs.prepare.outputs.newfile}} (${{matrix.check}})
container: ghcr.io/r-universe-org/recheck
container: ghcr.io/r-devel/recheck
timeout-minutes: 600
strategy:
matrix:
Expand Down
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
*.o
*.so
*.dll
.Rproj.user
.Rhistory
revdeps
*_recheck
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM ghcr.io/r-devel/rcheckserver/ubuntu

COPY rechecktools /rechecktools
RUN R -e 'install.packages("remotes");remotes::install_local("/rechecktools");library(rechecktools)'
9 changes: 9 additions & 0 deletions rechecktools/.Rbuildignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
^.*\.Rproj$
^\.Rproj\.user$
^Dockerfile$
^\.git$
^\.github$
^LICENSE.md$
^action.yml$
^entrypoint.sh$
^.*_recheck$
13 changes: 13 additions & 0 deletions rechecktools/DESCRIPTION
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Package: rechecktools
Type: Package
Title: Reverse Dependency Check Tools
Version: 0.1.0
Author: Who wrote it
Maintainer: The package maintainer <yourself@somewhere.net>
Description: Runs a reverse dependency check in a similar manner as CRAN incoming.
License: MIT + file LICENSE
Encoding: UTF-8
Imports:
curl
RoxygenNote: 7.3.1
Roxygen: list(markdown = TRUE)
2 changes: 2 additions & 0 deletions rechecktools/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
YEAR: 2024
COPYRIGHT HOLDER: Jeroen Ooms
21 changes: 21 additions & 0 deletions rechecktools/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# MIT License

Copyright (c) 2024 Jeroen Ooms

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.
4 changes: 4 additions & 0 deletions rechecktools/NAMESPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Generated by roxygen2: do not edit by hand

export(install_recheck_deps)
export(recheck)
24 changes: 24 additions & 0 deletions rechecktools/R/ci.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#' Wrappers to run in CI
#'
#' To call in CI
#'
#' @export
#' @param path path to source package
#' @param which either be strong or most
install_recheck_deps <- function(path = '.', which = 'strong'){
oldrepos <- enable_all_repos()
oldtimeout <- options(timeout = 600)
on.exit(options(c(oldrepos, oldtimeout)), add = TRUE)
desc <- read.dcf(file.path(path, 'DESCRIPTION'))
pkg <- desc[[1, 'Package']]
cranrepo <- getOption('repos')['CRAN']
cran <- utils::available.packages(repos = cranrepo)
packages <- c(pkg, tools::package_dependencies(pkg, db = cran, which = which, reverse = TRUE)[[pkg]])
if(grepl("Linux", Sys.info()[['sysname']])){
preinstall_linux_binaries(packages)
} else {
utils::install.packages(packages, dependencies = TRUE)
deps <- unique(unlist(unname(tools::package_dependencies(packages, recursive = TRUE))))
update.packages(oldPkgs = deps, ask = FALSE)
}
}
47 changes: 47 additions & 0 deletions rechecktools/R/linux-binaries.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# The goal of this function is to speed up installation of dependencies.
# This is done in two ways:
# - Try to get precompiled binaries when available (mainly on ubuntu)
# - Download files in parallel using curl
# The latter can be removed once fixed in base-R: https://github.com/r-devel/r-svn/pull/155
preinstall_linux_binaries <- function(tocheck){
rver <- getRversion()
distro <- system2('lsb_release', '-sc', stdout = TRUE)
options(HTTPUserAgent = sprintf("R/%s R (%s); r-universe (%s)", rver, paste(rver, R.version$platform, R.version$arch, R.version$os), distro))
bioc <- sprintf("https://bioc.r-universe.dev/bin/linux/%s/4/", distro)
cran <- sprintf("https://p3m.dev/cran/__linux__/%s/latest", distro)
repos <- c(cran, bioc)
db <- utils::available.packages(repos = c(CRAN = cran, BIOC = bioc, official_bioc_repos()))
checkdeps <- unique(unlist(unname(tools::package_dependencies(tocheck, db = db, which = 'most'))))
alldeps <- tools::package_dependencies(checkdeps, db = db, recursive = TRUE)
packages <- unlist(lapply(checkdeps, function(x){
c(rev(alldeps[[x]]), x)
}))
packages <- intersect(unique(packages), row.names(db))
packages <- setdiff(packages, loadedNamespaces())
versions <- db[packages, 'Version']
mirrors <- db[packages, 'Repository']
urls <- sprintf("%s/%s_%s.tar.gz", mirrors, packages, versions)
destdir <- tempfile()
dir.create(destdir)
pwd <- setwd(destdir)
on.exit(setwd(pwd), add = TRUE)
on.exit(unlink(destdir, recursive = TRUE), add = TRUE)
res <- curl::multi_download(urls)
res$ok <- res$success & res$status_code == 200
failures <- res$destfile[!res$ok]
if(length(failures)){
warning("Failed downloads for: ", paste(failures, collapse = ', '))
unlink(failures)
res <- res[res$ok,]
}
utils::install.packages(res$destfile, repos = NULL, Ncpus = parallel::detectCores())
}

official_bioc_repos <- function(){
version <- utils:::.BioC_version_associated_with_R_version()
sprintf(c(
BioCsoft = "https://bioconductor.org/packages/%s/bioc",
BioCann = "https://bioconductor.org/packages/%s/data/annotation",
BioCexp = "https://bioconductor.org/packages/%s/data/experiment"
), version)
}
90 changes: 90 additions & 0 deletions rechecktools/R/recheck.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#' Reverse Dependency Check
#'
#' Run a reverse dependency check similar to CRAN.
#'
#' @export
#' @rdname recheck
#' @param sourcepkg path or URL to a source package tarball
#' @param which passed to `tools::package_dependencies`; set to "most" to
#' also check reverse suggests.
#' @param preinstall_dependencies start by installing dependencies for all
#' packages to be checked.
recheck <- function(sourcepkg, which = "strong", preinstall_dependencies = TRUE){
# Some temporary settings
oldrepos <- enable_all_repos()
oldtimeout <- options(timeout = 600)
on.exit(options(c(oldrepos, oldtimeout)), add = TRUE)

# Get the tarball
if(grepl('^https:', sourcepkg)){
curl::curl_download(sourcepkg, basename(sourcepkg))
sourcepkg <- basename(sourcepkg)
}
if(!grepl("_", sourcepkg)){
dl <- utils::download.packages(sourcepkg, '.')
sourcepkg <- basename(dl[,2])
}
pkg <- sub("_.*", "", basename(sourcepkg))
checkdir <- dirname(sourcepkg)
cranrepo <- getOption('repos')['CRAN'] #
cran <- utils::available.packages(repos = cranrepo)
packages <- c(pkg, tools::package_dependencies(pkg, db = cran, which = which, reverse = TRUE)[[pkg]])
if(preinstall_dependencies){
group_output("Preparing dependencies", {
if(grepl("Linux", Sys.info()[['sysname']])){
preinstall_linux_binaries(packages)
} else {
utils::install.packages(packages, dependencies = TRUE)
deps <- unique(unlist(unname(tools::package_dependencies(packages, recursive = TRUE))))
update.packages(oldPkgs = deps, ask = FALSE)
}
})
}
check_args <- character()
if(nchar(Sys.which('pdflatex')) == 0){
message("No pdflatex found, skipping pdf checks")
check_args <- c(check_args, '--no-manual --no-build-vignettes')
}
group_output("Running checks", {
Sys.setenv('_R_CHECK_FORCE_SUGGESTS_' = 'false')
if(.Platform$OS.type == 'windows') Sys.setenv(TAR = 'internal')
tools::check_packages_in_dir(checkdir, basename(sourcepkg),
reverse = list(repos = cranrepo, which = which),
Ncpus = parallel::detectCores(),
check_args = check_args)
})
group_output("Check results details", {
details <- tools::check_packages_in_dir_details(checkdir)
write.csv(details, file.path(checkdir, 'check-details.csv'))
writeLines(paste(format(details), collapse = "\n\n"), file.path(checkdir, 'check-details.txt'))
print(details)
})
tools::summarize_check_packages_in_dir_results(checkdir)
}

enable_all_repos <- function(){
old <- options(repos = c(CRAN = 'https://cloud.r-project.org'))
utils::setRepositories(ind = 1:4) #adds bioc
my_universe <- Sys.getenv('MY_UNIVERSE')
if(nchar(my_universe)){
options(repos = c(my_universe = my_universe, getOption('repos')))
}
return(old)
}

group_output<- function(title, expr){
if(Sys.getenv('CI') != ""){
cat("::group::", title, "\n", sep = "")
on.exit(cat("::endgroup::\n"))
}
cat("===========", title, "===========\n")
eval(expr)
}

test_recheck <- function(pkg, which = 'strong'){
checkdir <- paste(pkg, 'recheck', sep = '_')
unlink(checkdir, recursive = TRUE)
dir.create(checkdir)
utils::download.packages(pkg, checkdir, repos = 'https://cloud.r-project.org')
recheck(list.files(checkdir, pattern = 'tar.gz$', full.names = TRUE), which = which)
}
16 changes: 16 additions & 0 deletions rechecktools/man/install_recheck_deps.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions rechecktools/man/recheck.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions rechecktools/recheck.Rproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Version: 1.0

RestoreWorkspace: Default
SaveWorkspace: Default
AlwaysSaveHistory: Default

EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: UTF-8

RnwWeave: Sweave
LaTeX: pdfLaTeX

AutoAppendNewline: Yes
StripTrailingWhitespace: Yes

BuildType: Package
PackageUseDevtools: Yes
PackageInstallArgs: --no-multiarch --with-keep.source

0 comments on commit 8fac2da

Please sign in to comment.