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

[R-package] [ci] Make Windows CI fail if R CMD check fails #3435

Merged
merged 12 commits into from
Oct 6, 2020

Conversation

jameslamb
Copy link
Collaborator

In #3405 (comment), I noticed that if R CMD check raises an ERROR on Windows, LightGBM's CI doesn't fail. Maybe that is a result of the way we have to intercept stderr on GitHub Actions Windows environments (

# External utilities like R.exe / Rscript.exe writing to stderr (even for harmless
# status information) can cause failures in GitHub Actions PowerShell jobs.
# See https://github.saobby.my.eu.orgmunity/t/powershell-steps-fail-nondeterministically/115496
#
# Using standard PowerShell redirection does not work to avoid these errors.
# This function uses R's built-in redirection mechanism, sink(). Any place where
# this function is used is a command that writes harmless messages to stderr
function Run-R-Code-Redirect-Stderr {
param(
[string]$rcode
)
$decorated_code = "out_file <- file(tempfile(), open = 'wt'); sink(out_file, type = 'message'); $rcode; sink()"
Rscript --vanilla -e $decorated_code
}
).

This PR proposes a fix, to be sure that CI fails on changes that break the R package.

@jameslamb jameslamb added the fix label Oct 4, 2020
@jameslamb jameslamb requested a review from StrikerRUS October 4, 2020 05:57
@jameslamb jameslamb requested a review from Laurae2 as a code owner October 4, 2020 05:57
@@ -6,6 +6,7 @@
# R sources files during installation).
# [return] A named list, where each key is a parameter relevant to lgb.DataSet and each value is a character
# vector of corresponding aliases.
,,,,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm starting by intentionally pushing a change that raises an ERROR in R CMD check, so we can see that the Windows tests pass.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

even with this syntax error, all of the Windows tests passed!

https://github.com/microsoft/LightGBM/pull/3435/checks?check_run_id=1204672524

image

image

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

After adding f916575, the MINGW tests fail as expected

https://github.com/microsoft/LightGBM/pull/3435/checks?check_run_id=1204732555

image

But the MSVC ones do not! Another issue with how errors are caught by Run-R-Code-Redirect-Stderr, maybe.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Collaborator

@StrikerRUS StrikerRUS left a comment

Choose a reason for hiding this comment

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

LGTM! Looks like we cannot rely on Run-R-Code-Redirect-Stderr...

@@ -181,6 +185,11 @@ if ($env:COMPILER -ne "MSVC") {
Get-Content -Path "$INSTALL_LOG_FILE_NAME"
Write-Output "----- end of build and install logs -----"
Check-Output $install_succeeded
# some errors are not raised above, but can be found in the logs
if (Get-Content "$INSTALL_LOG_FILE_NAME" | Select-String -Pattern "ERROR" -Quiet) {
echo "ERRORs have been found installing lightgbm"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Oops! Seems that during VS trials and errors (we use them to find any supported VS version) we trigger this condition:

Trying 'Visual Studio 16 2019'

-- Configuring incomplete, errors occurred!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I always forget that Select-String is case-insensitive by default 🙃

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

LGTM! Looks like we cannot rely on Run-R-Code-Redirect-Stderr...

Oh wait, I see why! I might be able to fix this by fixing Run-R-Code-Redirect-Stderr.

My next few commits here will be to test...I'll comment when it's ready for another review

ok sadly my experiment failed. I thought I just needed to add a return or Exit in Run-R-Code-Redirect-Stderr but that didn't work. All of the ways we have to catch errors makes it really complicated :/

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed!

@jameslamb
Copy link
Collaborator Author

LGTM! Looks like we cannot rely on Run-R-Code-Redirect-Stderr...

Oh wait, I see why! I might be able to fix this by fixing Run-R-Code-Redirect-Stderr.

My next few commits here will be to test...I'll comment when it's ready for another review

Copy link
Collaborator

@StrikerRUS StrikerRUS left a comment

Choose a reason for hiding this comment

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

Thanks for the neat solution!

@StrikerRUS StrikerRUS merged commit 967a781 into microsoft:master Oct 6, 2020
@jameslamb jameslamb deleted the fix/r-windows-ci branch October 11, 2020 04:36
@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity since it was closed. To start a new related discussion, open a new issue at https://github.com/microsoft/LightGBM/issues including a reference to this.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants