Skip to content

Commit

Permalink
feat: separate cran from dev_history
Browse files Browse the repository at this point in the history
isssue #239
  • Loading branch information
statnmap committed Jan 23, 2024
1 parent 09f6e59 commit 6906fdd
Show file tree
Hide file tree
Showing 3 changed files with 164 additions and 118 deletions.
2 changes: 1 addition & 1 deletion dev/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
*.html
*.R
!dev_history.R
!dev_history*.R
118 changes: 1 addition & 117 deletions dev/dev_history.R
Original file line number Diff line number Diff line change
Expand Up @@ -165,120 +165,4 @@ usethis::pr_finish(41)


# Prepare for CRAN ----
# _Update template Rmd ----
skeleton_dir <- tempfile()
dir.create(skeleton_dir)
# When opening, verify that "skeleton" is written in the correct places
the_flat <- fusen::add_additional(
pkg = skeleton_dir,
dev_dir = "dev",
flat_name = "skeleton",
open = TRUE
)
file.copy(
the_flat,
here::here("inst/rmarkdown/templates/additional/skeleton/skeleton.Rmd"),
overwrite = TRUE
)
unlink(skeleton_dir, recursive = TRUE)

# _Check in interactive test-inflate for templates and Addins ----
pkgload::load_all()

Sys.setenv("NOT_CRAN" = "true")
testthat::test_dir("tests/testthat/")
testthat::test_file("tests/testthat/test-inflate-part1.R")
testthat::test_file("tests/testthat/test-inflate-part2.R")
testthat::test_file("tests/testthat/test-inflate_all.R")
testthat::test_file("tests/testthat/test-add_flat_template.R")
testthat::test_file("tests/testthat/test-skeleton.R")
Sys.setenv("NOT_CRAN" = "false")

# Run line by line
Sys.setenv("FUSEN_TEST_PUBLISH" = "TRUE")
testthat::test_file("tests/testthat/test-init_share_on_github.R")
Sys.setenv("FUSEN_TEST_PUBLISH" = "FALSE")
# testthat::test_file("tests/testthat/test-build_fusen_chunks.R")
# Test no output generated in the user files
# pkgload::load_all(export_all = FALSE)
# remotes::install_github("ropensci-review-tools/autotest")

# Run examples in interactive mode too
devtools::run_examples()

# Check package as CRAN
rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"))
devtools::check(args = c("--no-manual", "--as-cran"))

# Check content
# remotes::install_github("ThinkR-open/checkhelper")
tags <- checkhelper::find_missing_tags()
View(tags$functions)

# Remettre: Config/testthat/parallel: false dans DESCRIPTION
out <- checkhelper::check_clean_userspace(pkg = ".")
out
checkhelper::check_as_cran()
# Remettre: Config/testthat/parallel: true dans DESCRIPTION

# Check spelling
# usethis::use_spell_check()
spelling::spell_check_package()

# Check URL are correct
# remotes::install_github("r-lib/urlchecker")
urlchecker::url_check()
urlchecker::url_update()

# Upgrade version number
usethis::use_version(which = c("patch", "minor", "major", "dev")[2])

# check on other distributions
# _rhub
devtools::check_rhub()
rhub::platforms()
rhub::check_on_windows(check_args = "--force-multiarch", show_status = FALSE)
rhub::check_on_solaris(show_status = FALSE)
rhub::check(platform = "debian-clang-devel", show_status = FALSE)
rhub::check(platform = "debian-gcc-devel", show_status = FALSE)
rhub::check(platform = "fedora-clang-devel", show_status = FALSE)
rhub::check(platform = "macos-m1-bigsur-release", show_status = FALSE)
rhub::check_for_cran(show_status = FALSE)

# Run locally in Docker
# docker pull rhub/debian-clang-devel
# docker run -ti rhub/debian-clang-devel bash
# docker run -v /mnt/Data/github/ThinkR-open/fusen:/home/root/toto -ti rhub/debian-clang-devel bash
rhub::local_check_linux(image = "rhub/debian-clang-devel")
rhub::local_check_linux(image = "rhub/fedora-clang-devel")
# a55df815-38f2-4854-a3bc-29cdcac878cc-2

rstudioapi::navigateToFile(system.file(package = "rhub", "bin", "rhub-linux-docker.sh"))
# docker container start -i 7181196d-bc3c-4fc8-a0e8-dc511150335d-2
# docker exec -it 7181196d-bc3c-4fc8-a0e8-dc511150335d-2 bash
# https://www.thorsten-hans.com/how-to-run-commands-in-stopped-docker-containers/
# /opt/R-devel/bin/R


rhub::check(platform = "windows-x86_64-devel", show_status = FALSE)

# _win devel
devtools::check_win_devel()
devtools::check_win_release()
# remotes::install_github("r-lib/devtools")
devtools::check_mac_release()

# Update NEWS
# Bump version manually and add list of changes

# Add comments for CRAN
usethis::use_cran_comments(open = rlang::is_interactive())

# Upgrade version number
usethis::use_version(which = c("patch", "minor", "major", "dev")[1])

# Verify you're ready for release, and release
devtools::release()

# Back to dev
usethis::use_version(which = c("patch", "minor", "major", "dev")[4])
# See dev/dev_history_cran.R
162 changes: 162 additions & 0 deletions dev/dev_history_cran.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
# Prepare for CRAN

# > Special for {fusen} ====================
# _Update template Rmd ----
skeleton_dir <- tempfile()
dir.create(skeleton_dir)
# When opening, verify that "skeleton" is written in the correct places
the_flat <- fusen::add_additional(
pkg = skeleton_dir,
dev_dir = "dev",
flat_name = "skeleton",
open = TRUE
)
file.copy(
the_flat,
here::here("inst/rmarkdown/templates/additional/skeleton/skeleton.Rmd"),
overwrite = TRUE
)
unlink(skeleton_dir, recursive = TRUE)

# _Check in interactive test-inflate for templates and Addins ----
pkgload::load_all()

Sys.setenv("NOT_CRAN" = "true")
testthat::test_dir("tests/testthat/")
testthat::test_file("tests/testthat/test-inflate-part1.R")
testthat::test_file("tests/testthat/test-inflate-part2.R")
testthat::test_file("tests/testthat/test-inflate_all.R")
testthat::test_file("tests/testthat/test-add_flat_template.R")
testthat::test_file("tests/testthat/test-skeleton.R")
Sys.setenv("NOT_CRAN" = "false")

# Run line by line
Sys.setenv("FUSEN_TEST_PUBLISH" = "TRUE")
testthat::test_file("tests/testthat/test-init_share_on_github.R")
Sys.setenv("FUSEN_TEST_PUBLISH" = "FALSE")
# testthat::test_file("tests/testthat/test-build_fusen_chunks.R")
# Test no output generated in the user files
# pkgload::load_all(export_all = FALSE)
# remotes::install_github("ropensci-review-tools/autotest")


# > Copy from Prepare-for-cran - https://github.com/ThinkR-open/prepare-for-cran ====================


# Update dependencies in DESCRIPTION
# install.packages('attachment', repos = 'https://thinkr-open.r-universe.dev')
attachment::att_amend_desc()

# Check package coverage
covr::package_coverage()
covr::report()

# Run tests
devtools::test()
testthat::test_dir("tests/testthat/")

# Run examples
devtools::run_examples()

# autotest::autotest_package(test = TRUE)

# Check package as CRAN using the correct CRAN repo
withr::with_options(list(repos = c(CRAN = "https://cloud.r-project.org/")), {
callr::default_repos()
rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"))
})
# devtools::check(args = c("--no-manual", "--as-cran"))

# Check content
# install.packages('checkhelper', repos = 'https://thinkr-open.r-universe.dev')
# All functions must have either `@noRd` or an `@export`.
checkhelper::find_missing_tags()

# Check that you let the house clean after the check, examples and tests
# If you used parallel testing, you may need to avoid it for the next check with `Config/testthat/parallel: false` in DESCRIPTION
all_files_remaining <- checkhelper::check_clean_userspace()
all_files_remaining
# If needed, set back parallel testing with `Config/testthat/parallel: true` in DESCRIPTION

# Check spelling - No typo
# usethis::use_spell_check()
spelling::spell_check_package()

# Check URL are correct
# install.packages('urlchecker', repos = 'https://r-lib.r-universe.dev')
urlchecker::url_check()
urlchecker::url_update()

# check on other distributions
# _rhub
devtools::check_rhub()
# List all R-hub platforms:
rhub::platforms()
buildpath <- devtools::build()
rhub::check_on_windows(
check_args = "--force-multiarch",
show_status = FALSE,
path = buildpath
)
rhub::check_on_solaris(show_status = FALSE, path = buildpath)
rhub::check(
platform = "debian-clang-devel",
show_status = FALSE,
path = buildpath
)
rhub::check(
platform = "debian-gcc-devel",
show_status = FALSE,
path = buildpath
)
rhub::check(
platform = "fedora-clang-devel",
show_status = FALSE,
path = buildpath
)
rhub::check(
platform = "macos-highsierra-release-cran",
show_status = FALSE,
path = buildpath
)
rhub::check_for_cran(show_status = FALSE, path = buildpath)

# _win devel CRAN
devtools::check_win_devel()
# _win release CRAN
devtools::check_win_release()
# _macos CRAN
# Need to follow the URL proposed to see the results
devtools::check_mac_release()

# Check reverse dependencies
# remotes::install_github("r-lib/revdepcheck")
usethis::use_git_ignore("revdep/")
usethis::use_build_ignore("revdep/")

devtools::revdep()
library(revdepcheck)
# In another session because Rstudio interactive change your config:
id <- rstudioapi::terminalExecute("Rscript -e 'revdepcheck::revdep_check(num_workers = 4)'")
rstudioapi::terminalKill(id)
# if [Exit Code] is not 0, there is a problem !
# to see the problem: execute the command in a new terminal manually.

# See outputs now available in revdep/
revdep_details(revdep = "pkg")
revdep_summary() # table of results by package
revdep_report()
# Clean up when on CRAN
revdep_reset()

# Update NEWS
# Bump version manually and add list of changes

# Add comments for CRAN
usethis::use_cran_comments(open = rlang::is_interactive())

# Upgrade version number
usethis::use_version(which = c("patch", "minor", "major", "dev")[1])

# Verify you're ready for release, and release
devtools::release()

0 comments on commit 6906fdd

Please sign in to comment.