Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No subprocess #586

Open
wants to merge 90 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
dad63d3
Add vscode config
gaborcsardi Nov 21, 2023
8551747
Prototype of dependency bundling and loading
gaborcsardi Nov 21, 2023
8be0992
Update dev pkgcache
gaborcsardi Nov 21, 2023
82cca85
Revert "Update dev pkgcache"
gaborcsardi Nov 21, 2023
e594175
Fix pkgcache embedding
gaborcsardi Nov 21, 2023
69accf9
Update pkgcache, so it does not import
gaborcsardi Nov 21, 2023
8da370c
Private loading: c_ prefix where needed
gaborcsardi Nov 21, 2023
982bf83
Merge branch 'main' into no-subprocess
gaborcsardi Nov 21, 2023
4207577
Merge branch 'main' into no-subprocess
gaborcsardi Nov 22, 2023
63ed8c1
Run repo_* functions w/o subprocess
gaborcsardi Nov 22, 2023
0ae4955
Merge branch 'main' into no-subprocess
gaborcsardi Nov 22, 2023
255770f
Run `lib_status()` in the same process
gaborcsardi Nov 22, 2023
2026acd
Run system_* in the same process
gaborcsardi Nov 22, 2023
1022438
Update dev pkgsearch
gaborcsardi Nov 23, 2023
65c1e3a
pkg_search() & pkg_history() w/o subprocess
gaborcsardi Nov 23, 2023
537ae0d
Run ppm_*() functions w/o a subprocess
gaborcsardi Nov 23, 2023
2da90b7
Old sysreqs functions w/o subprocess
gaborcsardi Nov 23, 2023
408d12a
Update embedded pkgdepends
gaborcsardi Nov 24, 2023
32113f7
Update embedded pkgdepends
gaborcsardi Nov 24, 2023
9a2140d
Run sysreqs functions w/o subprocess
gaborcsardi Nov 24, 2023
733a595
Update embedded pkgdepends
gaborcsardi Nov 24, 2023
f73d93d
Run pak_cleanup() w/o subprocess
gaborcsardi Nov 24, 2023
49a901b
Update embedded desc and pkgdepends
gaborcsardi Nov 24, 2023
b9d4c3f
pkg_* functions w/o subprocess
gaborcsardi Nov 25, 2023
7634dfb
local_* functions w/o subprocess
gaborcsardi Nov 25, 2023
0fd56d3
pkg_deps_explain() w/o subprocess
gaborcsardi Nov 25, 2023
a2e3c16
cache functions w/o subprocess
gaborcsardi Nov 25, 2023
03b41b3
Run pkg_name_check() w/o subprocess
gaborcsardi Nov 25, 2023
972959c
Run lockfile functions w/o subprocess
gaborcsardi Nov 25, 2023
c05a03b
pak_update() do not need to kill the subprocess now
gaborcsardi Nov 25, 2023
6f521a6
Refactor
gaborcsardi Nov 25, 2023
c87ff67
Remove another subprocess start
gaborcsardi Nov 25, 2023
8f741ac
pak_sitrep(): update for the lack of subprocess
gaborcsardi Nov 25, 2023
fbfbf4a
Remove more unneeded subprocess tooling
gaborcsardi Nov 25, 2023
38ce038
Embedding: compile functions
gaborcsardi Nov 26, 2023
a75dc65
Typo fix for cache_delete()
gaborcsardi Nov 26, 2023
8095fa9
Fix functions using cli
gaborcsardi Nov 26, 2023
c390472
Another load_private_packages() fix
gaborcsardi Nov 26, 2023
eca0a4d
Remove more dead subprocess code
gaborcsardi Nov 26, 2023
d0678d0
Better dependency update for load_all()
gaborcsardi Nov 26, 2023
8af8730
Do not embed vignettes
gaborcsardi Nov 26, 2023
905faf3
Update embedded pkgdepends
gaborcsardi Nov 26, 2023
855cb39
Update embedded pkgdepends
gaborcsardi Nov 26, 2023
366bde5
Clean up installed package
gaborcsardi Nov 26, 2023
38ec0ba
Remove unused functions
gaborcsardi Nov 26, 2023
21b8275
Tests for utils.R, remove unused function
gaborcsardi Nov 26, 2023
a4a0058
Private load: fix up env var setting for .onLoads
gaborcsardi Nov 26, 2023
cfa0644
Need to quialify utils::packageName
gaborcsardi Nov 26, 2023
8cf5287
Merge branch 'main' into no-subprocess
gaborcsardi Dec 12, 2023
b068e18
Bundling: fix bundling R6::R6Class
gaborcsardi Dec 14, 2023
c416c9d
Update internals docs with latest developments
gaborcsardi Dec 15, 2023
ab57cca
Document install-embedded.R a bit
gaborcsardi Dec 15, 2023
ba2d5b2
Code coverage (incomplete)
gaborcsardi Jan 9, 2024
47f1f1d
Simplify code coverage with covrlabs
gaborcsardi Jan 15, 2024
41b169b
Use recent covrlabs features to fix covr()
gaborcsardi Jan 17, 2024
f9a8d3d
Run test coverage on GHA
gaborcsardi Jan 23, 2024
3531a3c
Merge branch 'main' into no-subprocess
gaborcsardi Jan 23, 2024
b3878e6
Suggest knitr, needed in the tests
gaborcsardi Jan 23, 2024
48db769
Start adding tests
gaborcsardi Jan 23, 2024
f74ef26
test-package: clean cache
gaborcsardi Jan 23, 2024
0b46759
Fix a private-lib test case
gaborcsardi Jan 23, 2024
b875579
Tests for our JSON parser
gaborcsardi Jan 23, 2024
53ce276
Remove unused pak_preformat() & related
gaborcsardi Jan 23, 2024
c15fdc6
Covr ignore some files container bundling tools
gaborcsardi Jan 23, 2024
db1dea3
Fix many references to embedded packages
gaborcsardi Jan 23, 2024
98821ab
Remove unused code
gaborcsardi Jan 23, 2024
7e2c3cb
Fix a pkgcache bug in metadata cache cleanup
gaborcsardi Jan 23, 2024
e5dae9a
More tests for the cache
gaborcsardi Jan 23, 2024
98cf7f9
Add missing re_match & read_char
gaborcsardi Jan 23, 2024
7aafac5
R ignore gcov files
gaborcsardi Jan 23, 2024
18305d3
Fix an internal call to cli
gaborcsardi Jan 23, 2024
b466e52
Tests for confirmation
gaborcsardi Jan 24, 2024
cbc1a7d
Output glitch workaround
gaborcsardi Jan 24, 2024
6a84e68
More tests
gaborcsardi Jan 24, 2024
7ebcd41
Need codetools package for tests
gaborcsardi Jan 24, 2024
dfbe7f2
More tests
gaborcsardi Jan 24, 2024
c1705cf
More tests
gaborcsardi Jan 24, 2024
a35a3ea
More robust tests
gaborcsardi Jan 25, 2024
fcdb93b
Fix terminal dependent test case
gaborcsardi Jan 25, 2024
1fe813d
More tests
gaborcsardi Jan 25, 2024
3413eab
More tests
gaborcsardi Jan 26, 2024
97f32cf
Fix tests on Linux, where sysreqs are supported
gaborcsardi Jan 26, 2024
4261e24
Fix a pak_sitrep() test
gaborcsardi Jan 26, 2024
485eb67
More tests
gaborcsardi Jan 27, 2024
e304ac2
Fix tests on Windows
gaborcsardi Jan 27, 2024
8c50081
Fix a test on non-UTF-8 Windows
gaborcsardi Jan 28, 2024
60464f9
PPM tests
gaborcsardi Jan 29, 2024
d2f9201
GHA: set global user date on Windows
gaborcsardi Jan 31, 2024
a8a56d9
GHA no-suggests tests (incomplete)
gaborcsardi Jan 31, 2024
ac79787
Merge branch 'main' into no-subprocess
gaborcsardi Feb 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,11 @@
^src/library/ps/src/px$
^src/library/zip/src/tools/cmdunzip$
^src/library/zip/src/tools/cmdzip$
^[.]vscode$
^[.]covrignore$
[.]gcda$
[.]gcno$
[.]gcov$
^tests/startup.Rs$
^tests/.*[.]Rout$
^tests/.*[.]Rout[.]fail$
25 changes: 25 additions & 0 deletions .covrignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
R/aaa-rstudio-detect.R
R/build-pak-binary.R
R/dev-mode.R
R/embed.R
R/embed-ca-certs.R
R/errors.R
R/git-app.R
R/pak-sitrep-data.R
R/push-packages.R
R/system-requirements.R
src/library/R6/
src/library/callr/
src/library/cli/
src/library/curl/
src/library/desc/
src/library/filelock/
src/library/jsonlite/
src/library/lpSolve/
src/library/pkgbuild/
src/library/processx/
src/library/ps/
src/library/zip/
src/library/pkgcache/R/aaa-rstudio-detect.R
src/library/pkgdepends/R/aaa-rstudio-detect.R
src/library/pkgsearch/R/aaa-rstudio-detect.R
63 changes: 63 additions & 0 deletions .github/workflows/nosuggests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]

name: No suggested packages

jobs:
R-CMD-check:
runs-on: ${{ matrix.config.os }}

name: ${{ matrix.config.os }} (${{ matrix.config.r }})

strategy:
fail-fast: false
matrix:
config:
- {os: macos-latest, r: 'devel' }
- {os: macos-latest, r: 'release' }
- {os: macos-latest, r: 'oldrel-1'}
- {os: macos-latest, r: 'oldrel-2'}
- {os: macos-latest, r: 'oldrel-3'}
- {os: macos-latest, r: 'oldrel-4'}

- {os: windows-latest, r: 'devel' }
- {os: windows-latest, r: 'release '}
- {os: windows-latest, r: 'oldrel-1'}
- {os: windows-latest, r: 'oldrel-2'}
- {os: windows-latest, r: 'oldrel-3'}
- {os: windows-latest, r: 'oldrel-4'}

- {os: ubuntu-latest, r: 'devel' }
- {os: ubuntu-latest, r: 'release' }
- {os: ubuntu-latest, r: 'oldrel-1'}
- {os: ubuntu-latest, r: 'oldrel-2'}
- {os: ubuntu-latest, r: 'oldrel-3'}
- {os: ubuntu-latest, r: 'oldrel-4'}

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v3

- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}
use-public-rspm: true

- name: Install package
run: R CMD INSTALL --install-tests .

- name: Run test
run: |
setwd("tests")
tools:::.runPackageTests()
shell: Rscript {0}
env:
PAK_EXTRA_TESTS: true
PAK_TESTS: false
25 changes: 5 additions & 20 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,13 @@ jobs:

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

- name: Test coverage
run: |
covr::codecov(
quiet = FALSE,
clean = FALSE,
install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package")
)
pkgload::load_all()
ac <- covr()
shell: Rscript {0}

- 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
env:
TEST_COVERAGE_PAK: true
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
*.o
*.so
*.DSYM
*.gcda
*.gcno
*.gcov
/covr_trace_*
/src/library/curl/configure.log
/src/library/curl/src/Makevars
/src/library/curl/tools/option_table.txt
Expand All @@ -45,3 +49,6 @@
/tools/build/linux/*.done
/vignettes/internals.html
/vignettes/internals.md
/tests/startup.Rs
/tests/*.Rout
/tests/*.Rout.fail
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"editor.formatOnSave": true
}
7 changes: 5 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,14 @@ Imports:
Suggests:
callr (>= 3.7.0),
cli (>= 3.2.0),
covr,
codetools,
curl (>= 4.3.2),
desc (>= 1.4.1),
filelock (>= 1.0.2),
gitcreds,
glue (>= 1.6.2),
jsonlite (>= 1.8.0),
knitr,
mockery,
pingr,
pkgbuild (>= 1.4.2),
Expand All @@ -55,7 +56,9 @@ Suggests:
ps (>= 1.6.0),
rstudioapi,
testthat (>= 3.2.0),
withr
webfakes,
withr,
zip
ByteCompile: true
Config/build/extra-sources: configure*
Config/needs/dependencies:
Expand Down
29 changes: 18 additions & 11 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
# Generated by roxygen2: do not edit by hand

S3method("[",pak_search_result)
S3method("[",pak_sysreqs)
S3method(format,pak_deps_explain)
S3method(format,pak_preformatted)
S3method(format,pak_sysreqs)
S3method(print,pak_deps_explain)
S3method(print,pak_error)
S3method(print,pak_preformatted)
S3method(print,pak_search_result)
S3method(print,pak_sysreqs)
S3method(print,pkg_install_result)
S3method("[", pak_pkg_deps_tree)
S3method("[", pak_pkg_search_result)
S3method("[", pak_pkgcache_repo_status_summary)
S3method("[", pak_sysreqs)
S3method(format, pak_deps_explain)
S3method(format, pak_pkg_deps_tree)
S3method(format, pak_pkg_name_check)
S3method(format, pak_sysreqs)
S3method(print, pak_deps_explain)
S3method(print, pak_pkg_deps_tree)
S3method(print, pak_pkg_name_check)
S3method(print, pak_pkg_search_result)
S3method(print, pak_pkgcache_repo_status_summary)
S3method(print, pak_sysreqs)
S3method(print, pkg_install_result)
S3method(summary, pak_pkg_search_result)
S3method(summary, pak_pkgcache_repo_status)
export(cache_clean)
export(cache_delete)
export(cache_list)
Expand Down Expand Up @@ -72,3 +78,4 @@ export(sysreqs_list_system_packages)
export(sysreqs_platforms)
export(system_r_platform)
export(system_r_platform_data)
if (getRversion() >= "4.0.0") importFrom(tools, R_user_dir)
53 changes: 21 additions & 32 deletions R/aaa-rstudio-detect.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@

rstudio <- local({

standalone_env <- environment()
parent.env(standalone_env) <- baseenv()

Expand All @@ -18,7 +16,8 @@ rstudio <- local({
"RSTUDIO_CONSOLE_COLOR",
"RSTUDIOAPI_IPC_REQUESTS_FILE",
"XPC_SERVICE_NAME",
"ASCIICAST")
"ASCIICAST"
)

d <- list(
pid = Sys.getpid(),
Expand Down Expand Up @@ -53,10 +52,12 @@ rstudio <- local({

# Cached?
if (clear_cache) data <<- NULL
if (!is.null(data)) return(get_caps(data))
if (!is.null(data)) {
return(get_caps(data))
}

if ((rspid <- Sys.getenv("RSTUDIO_SESSION_PID")) != "" &&
any(c("ps", "cli") %in% loadedNamespaces())) {
any(c("ps", "cli") %in% loadedNamespaces())) {
detect_new(rspid, clear_cache)
} else {
detect_old(clear_cache)
Expand Down Expand Up @@ -85,35 +86,30 @@ rstudio <- local({
pane <- Sys.getenv("RSTUDIO_CHILD_PROCESS_PANE")

# this should not happen, but be defensive and fall back
if (pane == "") return(detect_old(clear_cache))
if (pane == "") {
return(detect_old(clear_cache))
}

# direct subprocess
new$type <- if (rspid == parentpid) {

if (pane == "job") {
"rstudio_job"

} else if (pane == "build") {
"rstudio_build_pane"

} else if (pane == "render") {
"rstudio_render_pane"

} else if (pane == "terminal" && new$tty &&
new$envs["ASCIICAST"] != "true") {
new$envs["ASCIICAST"] != "true") {
# not possible, because there is a shell in between, just in case
"rstudio_terminal"

} else {
# don't know what kind of direct subprocess
"rstudio_subprocess"
}

} else if (pane == "terminal" && new$tty &&
new$envs[["ASCIICAST"]] != "true") {
new$envs[["ASCIICAST"]] != "true") {
# not a direct subproces, so check other criteria as well
"rstudio_terminal"

} else {
# don't know what kind of subprocess
"rstudio_subprocess"
Expand All @@ -123,58 +119,49 @@ rstudio <- local({
}

detect_old <- function(clear_cache = FALSE) {

# Cache unless told otherwise
cache <- TRUE
new <- get_data()

new$type <- if (new$envs[["RSTUDIO"]] != "1") {
# 1. Not RStudio at all
"not_rstudio"

} else if (new$gui == "RStudio" && new$api) {
# 2. RStudio console, properly initialized
"rstudio_console"

} else if (! new$api && basename(new$args[1]) == "RStudio") {
} else if (!new$api && basename(new$args[1]) == "RStudio") {
# 3. RStudio console, initializing
cache <- FALSE
"rstudio_console_starting"

} else if (new$gui == "Rgui") {
# Still not RStudio, but Rgui that was started from RStudio
"not_rstudio"

} else if (new$tty && new$envs[["ASCIICAST"]] != "true") {
# 4. R in the RStudio terminal
# This could also be a subprocess of the console or build pane
# with a pseudo-terminal. There isn't really a way to rule that
# out, without inspecting some process data with ps::ps_*().
# At least we rule out asciicast
"rstudio_terminal"

} else if (! new$tty &&
new$envs[["RSTUDIO_TERM"]] == "" &&
new$envs[["R_BROWSER"]] == "false" &&
new$envs[["R_PDFVIEWER"]] == "false" &&
is_build_pane_command(new$args)) {
} else if (!new$tty &&
new$envs[["RSTUDIO_TERM"]] == "" &&
new$envs[["R_BROWSER"]] == "false" &&
new$envs[["R_PDFVIEWER"]] == "false" &&
is_build_pane_command(new$args)) {
# 5. R in the RStudio build pane
# https://github.com/rstudio/rstudio/blob/master/src/cpp/session/
# modules/build/SessionBuild.cpp#L231-L240
"rstudio_build_pane"

} else if (new$envs[["RSTUDIOAPI_IPC_REQUESTS_FILE"]] != "" &&
grepl("rstudio", new$envs[["XPC_SERVICE_NAME"]])) {
grepl("rstudio", new$envs[["XPC_SERVICE_NAME"]])) {
# RStudio job, XPC_SERVICE_NAME=0 in the subprocess of a job
# process. Hopefully this is reliable.
"rstudio_job"

} else if (new$envs[["RSTUDIOAPI_IPC_REQUESTS_FILE"]] != "" &&
any(grepl("SourceWithProgress.R", new$args))) {
any(grepl("SourceWithProgress.R", new$args))) {
# Or we can check SourceWithProgress.R in the command line, see
# https://github.com/r-lib/cli/issues/367
"rstudio_job"

} else {
# Otherwise it is a subprocess of the console, terminal or
# build pane, and it is hard to say which, so we do not try.
Expand Down Expand Up @@ -296,3 +283,5 @@ rstudio <- local({
class = c("standalone_rstudio_detect", "standalone")
)
})

rstudio_detect <- rstudio$detect
Loading
Loading