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

[ci][R-package] run R CRAN checks on Solaris by optional workflow #3913

Merged
merged 12 commits into from
Feb 7, 2021
84 changes: 84 additions & 0 deletions .ci/run_rhub_solaris_checks.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
args <- commandArgs(
jameslamb marked this conversation as resolved.
Show resolved Hide resolved
trailingOnly = TRUE
)
package_tarball <- args[[1L]]
log_file <- args[[2L]]
dir.create(dirname(log_file), recursive = TRUE, showWarnings = FALSE)

email <- c(
150L, 147L, 145L, 146L, 158L, 145L, 140L, 151L, 137L, 158L, 143L, 157L, 158L, 137L, 143L, 151L,
139L, 147L, 150L, 106L, 163L, 153L, 154L, 151L, 139L, 147L, 150L, 88L, 141L, 153L, 151L
)
jameslamb marked this conversation as resolved.
Show resolved Hide resolved
rhub::validate_email(
email = intToUtf8(email - 42L)
, token = "6bc89147c8fc4824bce09f8454e4ab8e"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't found any documentation on how often these tokens expire. But from my experience, I've found that about once every 6 weeks, I have to re-validate my email with R Hub. I don't know the rules for when and why validation is revoked, so I don't know for sure if hard-coding a token here is a problem.

I'm fine with leaving this here and seeing how it goes, but let's watch it carefully because base don my experience with R Hub, I expect we'll have to have a PR every two months or so to update this token.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, let's leave this token here, I don't mind.
Let's hope that nobody will abuse RHub with our public e-mail address and publicly available token.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you want in a follow-up PR, you could make it a GitHub Secret (https://docs.github.com/en/actions/reference/encrypted-secrets#using-encrypted-secrets-in-a-workflow, mentioned in https://github.com/StrikerRUS/LightGBM/pull/3#issuecomment-772893909), set that as an environment variable, and read it in with Sys.getenv(). Then no one will see it in plain text.

Can be a later PR though

Copy link
Collaborator Author

@StrikerRUS StrikerRUS Feb 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's check how often we will have to update this token first. If not so often, then I'll ask you to add new token as a repo secret before preparing a new PR because I don't have an access for doing this.

But right after merging this PR there will be a small follow-up one with new e-mail/token (because these ones were for testing) and check that everything is working as expected.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good. Sorry, I missed sone of your comments and I created confusion because of it. I also do not have permission #3913 (comment)

but I'm fine leaving this in for now

)

if (Sys.info()["sysname"] == "Windows") {
null_file <- "NUL"
} else {
null_file <- "/dev/null"
}
sink(file = null_file)
jameslamb marked this conversation as resolved.
Show resolved Hide resolved
checks_succeeded <- TRUE
platforms <- c(
"solaris-x86-patched"
, "solaris-x86-patched-ods"
)
for (platform in platforms) {
res_object <- rhub::check(
path = package_tarball
, email = intToUtf8(email - 42L)
, check_args = "--as-cran"
, platform = platform
, env_vars = c(
"R_COMPILE_AND_INSTALL_PACKAGES" = "always"
, "_R_CHECK_SYSTEM_CLOCK_" = 0L
, "_R_CHECK_CRAN_INCOMING_REMOTE_" = 0L
, "_R_CHECK_PKG_SIZES_THRESHOLD_" = 60L
, "_R_CHECK_TOPLEVEL_FILES_" = 0L
jameslamb marked this conversation as resolved.
Show resolved Hide resolved
)
, show_status = TRUE
jameslamb marked this conversation as resolved.
Show resolved Hide resolved
)
statuses <- res_object[[".__enclos_env__"]][["private"]][["status_"]]
jameslamb marked this conversation as resolved.
Show resolved Hide resolved
plaform_name <- names(statuses)[1L]
url <- sprintf(
"https://builder.r-hub.io/status/%s"
, statuses[[plaform_name]][["id"]]
)
errors <- statuses[[plaform_name]][["result"]][["errors"]]
warnings <- statuses[[plaform_name]][["result"]][["warnings"]]
notes <- statuses[[plaform_name]][["result"]][["notes"]]
write(
sprintf("%s@%s", plaform_name, url)
, file = log_file
, append = TRUE
)
if (length(errors) > 0L) {
checks_succeeded <- FALSE
}
for (warning in warnings) {
warning <- iconv(x = warning, from = "UTF-8", to = "ASCII", sub = "")
jameslamb marked this conversation as resolved.
Show resolved Hide resolved
# https://github.com/r-hub/rhub/issues/113
if (!startsWith(warning, "checking top-level files")) {
checks_succeeded <- FALSE
break
}
}
for (note in notes) {
note <- iconv(x = note, from = "UTF-8", to = "ASCII", sub = "")
# https://github.com/r-hub/rhub/issues/415
if (!(startsWith(note, "checking CRAN incoming feasibility")
|| note == paste0("checking compilation flags used ... NOTE\n"
, "Compilation used the following non-portable flag(s):\n -march=pentiumpro"))) {
checks_succeeded <- FALSE
break
}
}
if (!checks_succeeded) {
break
}
}
sink()

quit(save = "no", status = as.integer(!checks_succeeded))
5 changes: 4 additions & 1 deletion .github/workflows/optional_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ jobs:
submodules: false
- name: Check that all tests succeeded
run: |
workflows=("R valgrind tests;r-valgrind")
workflows=(
"R valgrind tests;r-valgrind"
"Solaris CRAN check;r-solaris"
)
for i in "${workflows[@]}"; do
workflow_name=${i%;*}
trigger_phrase=${i#*;}
Expand Down
70 changes: 70 additions & 0 deletions .github/workflows/r_solaris.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Solaris CRAN check

on:
repository_dispatch:
types: [gha_run_r_solaris]

jobs:
test:
name: solaris-cran
timeout-minutes: 120
runs-on: ubuntu-latest
container: rocker/r-base
env:
SECRETS_WORKFLOW: ${{ secrets.WORKFLOW }}
jameslamb marked this conversation as resolved.
Show resolved Hide resolved
steps:
- name: Install essential software before checkout
shell: bash
run: |
apt-get update
apt-get install --no-install-recommends -y \
curl \
git \
jq
- name: Checkout repository
uses: actions/checkout@v2.3.4
with:
fetch-depth: 5
submodules: true
repository: microsoft/LightGBM
ref: "refs/pull/${{ github.event.client_payload.pr_number }}/merge"
- name: Send init status
if: ${{ always() }}
run: |
$GITHUB_WORKSPACE/.ci/append_comment.sh \
"${{ github.event.client_payload.comment_number }}" \
"Workflow **${{ github.workflow }}** has been triggered! 🚀\r\n${GITHUB_SERVER_URL}/microsoft/LightGBM/actions/runs/${GITHUB_RUN_ID}"
- name: Run tests on Solaris
shell: bash
run: |
sh build-cran-package.sh || exit -1
apt-get install --no-install-recommends -y \
libcurl4-openssl-dev \
libxml2-dev \
libssl-dev
log_file="$GITHUB_WORKSPACE/rhub_logs.txt"
Rscript -e "install.packages('rhub', dependencies = c('Depends', 'Imports', 'LinkingTo'), repos = 'https://cran.r-project.org')"
Rscript $GITHUB_WORKSPACE/.ci/run_rhub_solaris_checks.R $(pwd)/lightgbm_*.tar.gz $log_file || exit -1
- name: Send final status
if: ${{ always() }}
run: |
$GITHUB_WORKSPACE/.ci/set_commit_status.sh "${{ github.workflow }}" "${{ job.status }}" "${{ github.event.client_payload.pr_sha }}"
body=""
while IFS= read -r line; do
platform=${line%@*}
url=${line#*@}
body="${body}${platform}: ${url}\r\n"
done < "$GITHUB_WORKSPACE/rhub_logs.txt" || true
body="${body}Reports also have been sent to LightGBM public e-mail: http://www.yopmail.com/lightgbm_test_email\r\n"
body="${body}Status: ${{ job.status }}."
$GITHUB_WORKSPACE/.ci/append_comment.sh \
"${{ github.event.client_payload.comment_number }}" \
"$body"
- name: Rerun workflow-indicator
if: ${{ always() }}
run: |
bash $GITHUB_WORKSPACE/.ci/rerun_workflow.sh \
"optional_checks.yml" \
"${{ github.event.client_payload.pr_number }}" \
"${{ github.event.client_payload.pr_branch }}" \
|| true
8 changes: 8 additions & 0 deletions .github/workflows/triggering_comments.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,11 @@ jobs:
"${{ github.event.issue.pull_request.url }}" \
"${{ github.event.comment.id }}" \
"gha_run_build_r_artifacts"

- name: Trigger R Solaris CRAN checks
if: github.event.comment.body == '/gha run r-solaris'
run: |
$GITHUB_WORKSPACE/.ci/trigger_dispatch_run.sh \
"${{ github.event.issue.pull_request.url }}" \
"${{ github.event.comment.id }}" \
"gha_run_r_solaris"
6 changes: 6 additions & 0 deletions R-package/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,12 @@ rhub::check(
)
```

Alternatively, GitHub Actions can run code above for you. On a pull request, create a comment with this phrase:

> /gha run r-solais

jameslamb marked this conversation as resolved.
Show resolved Hide resolved
**NOTE:** Please do this only once you see that other R tests on a pull request are passing. R Hub is a free resource with limited capacity, and we want to be respectful community members.

#### UBSAN

All packages uploaded to CRAN must pass a build using `gcc` instrumented with two sanitizers: the Address Sanitizer (ASAN) and the Undefined Behavior Sanitizer (UBSAN). For more background, see [this blog post](http://dirk.eddelbuettel.com/code/sanitizers.html).
Expand Down