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

handle private repo #3

Merged
merged 6 commits into from
Aug 19, 2024
Merged
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
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,14 @@ Insights Engineering

_Default_: `false`

* `max-iter`:

_Description_: Maximum number of iterations to resolve dependencies.

_Required_: `false`

_Default_: `10`


## Outputs

Expand Down
44 changes: 26 additions & 18 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ inputs:
description: Skip the installation of R package dependencies.
required: false
default: false
max-iter:
description: Maximum number of iterations to resolve dependencies.
required: false
default: 10

branding:
icon: 'download'
Expand Down Expand Up @@ -83,11 +87,9 @@ runs:
cat("::group::Define utils\n")
desc_field_append <- function(d, key, value) {
old_values <- d$get_field(key)
new_values <- if (identical(trimws(old_values), "")) {
value
} else {
paste(old_values, value, sep = ", ")
}
old_values_v <- trimws(strsplit(x = old_values, split = ",")[[1]])
new_values_v <- unique(c(old_values_v, value))
new_values <- paste(new_values_v, collapse = ", ")
d$set_list(key, new_values)
}
desc_field_clear_if_empty <- function(d, key) {
Expand Down Expand Up @@ -163,8 +165,8 @@ runs:

- name: Prepare DESCRIPTION file (feature branch)
if: >
inputs.skip-desc-branch == 'false' ||
steps.branch-names.outputs.is_default == 'true'
inputs.skip-desc-branch == 'false' &&
steps.branch-names.outputs.is_default != 'true'
id: desc-branch
shell: Rscript {0}
run: |
Expand Down Expand Up @@ -200,7 +202,7 @@ runs:
}
cat("::endgroup::\n")

cat("::group::Modify DESCRIPTION file\n")
cat("::group::Modify DESCRIPTION file (feature branch)\n")
x <- new_pkg_deps(path)
x$solve()
d <- x$get_resolution()[1, "extra"][[1]]$description
Expand Down Expand Up @@ -265,7 +267,8 @@ runs:
cat("::group::Parse inputs\n")
lookup_refs <- parse_input("${{ inputs.lookup-refs }}")
path <- parse_input("${{ inputs.repository-path }}")
log_vars(lookup_refs, path)
max_iter <- as.integer("${{ inputs.max-iter }}")
log_vars(lookup_refs, path, max_iter)
cat("::endgroup::\n")

cat("::group::Assertions\n")
Expand All @@ -288,15 +291,18 @@ runs:
}
cat("::endgroup::\n")

cat("::group::Modify DESCRIPTION file\n")
cat("::group::Modify DESCRIPTION file (development)\n")
x <- new_pkg_deps(path)
x$solve()
d <- x$get_resolution()[1, "extra"][[1]]$description

d$set_list("Config/Needs/DepsDev", character(0))

failures_prev <- NULL
while (TRUE) {
i <- 0L
failures_message_prev <- NULL
while (i <= max_iter) {
i <- i + 1L

x$solve()

if (x$get_solution()$status == "OK") {
Expand All @@ -305,17 +311,19 @@ runs:
}

failures <- x$get_solution()$failures
failed_pkgs <- failures[1, "failure_down"][[1]]
cli::cli_alert_warning("Failed to resolve dependencies. Failed packages: {.pkg {failed_pkgs}}.")
failures
failed_refs <- failures[1, "failure_down"][[1]]
cli::cli_alert_warning("Failed to resolve dependencies. Failed refs: {.pkg {failed_refs}}.")
cat(format(failures))

if (identical(failures, failures_prev)) {
failure_message <- failures$failure_message
if (identical(failure_message, failures_message_prev)) {
pawelru marked this conversation as resolved.
Show resolved Hide resolved
cli::cli_alert_danger("Failed to resolve dependencies. No progress. Exiting.")
break()
}
failures_prev <- failures
failures_message_prev <- failure_message

for (pkg in failed_pkgs) {
for (failed_ref in failed_refs) {
pkg <- pkgdepends::parse_pkg_ref(failed_ref)$package
pkg_ref <- find_ref(pkg, lookup_refs)
if (length(pkg_ref) == 0) {
cli::cli_alert_danger("Package {.pkg {pkg}} not found in the {.code {lookup_refs}} list. Exiting.")
Expand Down
Loading