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

Solves problem with second-level dependencies #22

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.Rproj.user
.Rhistory
.RData
.Ruserdata
r-verdepcheck-action.Rproj
69 changes: 14 additions & 55 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,70 +18,29 @@ When executed for A, script would read A's `DESCRIPTION` file, determine version
Please see [`verdepcheck`](https://github.com/insightsengineering/verdepcheck) package documentation for details.

## Action type

Composite

## Author
Insights Engineering

## Inputs
* `github-token`:

_Description_: Token with permissions to clone repositories with dependencies.

_Required_: `false`

_Default_: `""`

* `repository-path`:

_Description_: Directory where the checked package has been cloned.

_Required_: `false`

_Default_: `repository`

* `extra-deps`:

_Description_: Extra dependencies specified similarly as in the `DESCRIPTION` file, i.e. `"<package name> (<operator> <version>)"` where both `<operator>` and `<version>` are optional. Multiple entries are possible separated by `";"`.

_Required_: `false`

_Default_: `""`

* `check-args`:
[Insights Engineering](https://github.com/insightsengineering/)

_Description_: Optional value of `args` argument to `rcmdcheck::rcmdcheck` in form of a string with space as delimeter, e.g. `"--no-examples --no-tests"`.

_Required_: `false`

_Default_: `""`

* `build-args`:

_Description_: Optional value of `build_args` argument to `rcmdcheck::rcmdcheck` in form of a string with space as delimeter, e.g. `"--force --keep-empty-dirs"`.

_Required_: `false`

_Default_: `""`

* `strategy`:

_Description_: Strategy for dependency test, should be one of: min, release, max.

_Required_: `true`

* `additional-env-vars`:

_Description_: Additional environment variables.

_Required_: `false`

_Default_: `""`
## Inputs

| Input | Description | Required | Default |
| -------------- | --------------------------------------------------------------- | ------- | ---- |
| `github-token` | Token with permissions to clone repositories with dependencies. | _no_ | `""` |
| `repository-path` | Directory where the checked package has been cloned. | _no_ | `"repository"` |
| `extra-deps` | Extra dependencies specified similarly as in the `DESCRIPTION` file, i.e. `"<package name> (<operator> <version>)"` where both `<operator>` and `<version>` are optional. Multiple entries are possible separated by `";"`. | _no_ | `""` |
| `check-args` | Optional value of `args` argument to `rcmdcheck::rcmdcheck` in form of a string with space as delimeter, e.g. `"--no-examples --no-tests"`. | `false` | `""` |
| `build-args` | Optional value of `build_args` argument to `rcmdcheck::rcmdcheck` in form of a string with space as delimeter, e.g. `"--force --keep-empty-dirs"`. | `false` | `""` |
| `strategy` | Strategy for dependency test, should be one of: min, release, max. | _yes_ | |
| `additional-env-vars` | Additional environment variables. | _no_ | `""` |
| `additional-repos` | Optional value that add R repositories for a given strategy. Multiple entries are possible separated by `";"`. | _no_ | `""` |

## Outputs

None
_None_

## Usage

Expand Down
9 changes: 8 additions & 1 deletion action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ inputs:
XYZ=456
required: false
default: ""
additional-repos:
description: |
Optional value that add R repositories for a given strategy (multiple repos per strategy can be defined by separating with a comma).
Example usage:
additional-repos: https://repo1.example.com,https://repo2.example.com
required: false
default: ""

branding:
icon: 'refresh-ccw'
Expand All @@ -57,7 +64,7 @@ runs:
echo ".libPaths(\" \", include.site = FALSE)" > .Rprofile
export R_LIBS_SITE=" "
export R_LIBS_USER=" "
Rscript ${GITHUB_ACTION_PATH}/script.R '${{ inputs.repository-path }}' '${{ inputs.extra-deps }}' '${{ inputs.build-args }}' '${{ inputs.check-args }}' '${{ inputs.strategy }}'
Rscript ${GITHUB_ACTION_PATH}/script.R '${{ inputs.repository-path }}' '${{ inputs.extra-deps }}' '${{ inputs.build-args }}' '${{ inputs.check-args }}' '${{ inputs.strategy }}' '${{ inputs.additional-repos }}'
shell: bash
env:
GITHUB_PAT: "${{ inputs.github-token }}"
Expand Down
8 changes: 6 additions & 2 deletions script.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
if (length(x) == 0) cat(var_string, "(empty)\n") else cat(var_string, x, "\n")
}

catnl("Install required packages")
catnl("\n── \033[1mInstall required packages\033[22m ────────────")

install.packages(c("remotes", "cli"), quiet = TRUE, verbose = FALSE)
install.packages(c("remotes", "cli", "rlang"), quiet = TRUE, verbose = FALSE)
remotes::install_github("insightsengineering/verdepcheck", quiet = TRUE, verbose = FALSE)
remotes::install_github("r-lib/rcmdcheck#196", quiet = TRUE, verbose = FALSE) # TODO: remove when merged / linked issue fixed

Check warning on line 15 in script.R

View workflow job for this annotation

GitHub Actions / Lint Code Base

file=/github/workspace/script.R,line=15,col=121,[line_length_linter] Lines should not be more than 120 characters.

Check warning on line 15 in script.R

View workflow job for this annotation

GitHub Actions / Lint Code Base

file=/github/workspace/script.R,line=15,col=121,[line_length_linter] Lines should not be more than 120 characters.

args <- trimws(commandArgs(trailingOnly = TRUE))
path <- normalizePath(file.path(".", args[1]))
Expand All @@ -20,12 +20,16 @@
build_args <- strsplit(args[3], " ")[[1]]
check_args <- strsplit(args[4], " ")[[1]]
strategy <- args[5]
additional_repositories <- strsplit(args[6], ";")[[1]]

cli::cli_h1("Cat script parameters")
catnl_param(path)
catnl_param(extra_deps)
catnl_param(build_args)
catnl_param(check_args)
catnl_param(additional_repositories)

rlang::local_options(repos = c(options("repos"), additional_repositories))

cli::cli_h1("Execute verdepcheck...")
fun <- switch(
Expand Down Expand Up @@ -66,7 +70,7 @@

# TODO: https://github.com/r-lib/pkgdepends/issues/305 - remove when fixed
# this provides additional debug info in case of empty error report
if (inherits(x$ip, "pkg_installation_proposal") &&

Check warning on line 73 in script.R

View workflow job for this annotation

GitHub Actions / Lint Code Base

file=/github/workspace/script.R,line=73,col=1,[cyclocomp_linter] Functions should have cyclomatic complexity of less than 15, this has 16.

Check warning on line 73 in script.R

View workflow job for this annotation

GitHub Actions / Lint Code Base

file=/github/workspace/script.R,line=73,col=1,[cyclocomp_linter] Functions should have cyclomatic complexity of less than 15, this has 16.
inherits(x$ip$get_solution(), "pkg_solution_result") &&
x$ip$get_solution()$status == "FAILED" &&
inherits(x$ip$get_solution()$failures, "pkg_solution_failures") &&
Expand Down
Loading