-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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] Added more R linters (fixes #2477) #2533
Conversation
5dfe9f9
to
81a9387
Compare
Just rebased to most recent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Below are some comments about a CI part.
.ci/test.sh
Outdated
pydocstyle | ||
conda install -q -y -n $CONDA_ENV -c conda-forge \ | ||
r-lintr==2.0.0 | ||
Rscript -e "install.packages('stringi', repos = 'http://cran.rstudio.com')" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It takes soo much time! Is it the only available fix? Maybe it will be faster to update lintr
from CRAN?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can try setting up an R environment like I'm doing in #2530 so that we can just use install.packages()
directly. Let's see if that speeds it up.
But in general the install process for R packages is notoriously time-consuming :/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh no! I think we should stick to conda's environment, since it's significantly faster than ordinary one and suits to our purpose (just linting) very well.
Sorry for my ambiguous comment above! I just meant to try Rscript -e "install.packages('lintr', repos = 'http://cran.rstudio.com')"
to see whether it's faster than reinstalling stringi
or not.
But in general the install process for R packages is notoriously time-consuming :/
But not from conda 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah I see, ok. Yes I think I misinterpreted what you were saying. I'll change it back and try.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like linting task took almost 7 minutes to run still with this approach (using alternative R setup)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
creating an R environment from conda
and then install.packages('lintr')
from CRAN, the lint
task ran for 8m38s and then failed with
ERROR: dependency ‘curl’ is not available for package ‘httr’
I could add an install.packages('curl')
but that would make it run even longer than 8 minutes.
I decided to summarize all the attempts here (and add a few new ideas):
- (-failure-) R env from conda,
lintr
from conda-forge - (success) R env from conda,
lintr
from conda-forge,install.packages('stringi')
: 6m9s - (success) R env from CRAN like [R-package][ci] added CI stage for R package (fixes #2335, fixes #2569) #2530,
install.packages('lintr')
: 6m48s - (-failure-) R env from conda,
install.packages('lintr')
: 8+ minutes - (-failure-) R env from conda,
lintr
from conda-forge, re-installingstringi
from default conda channels: failed - (success) R env from conda, installing
stringi
from conda first, thenlintr
from conda-forge: 1m57s
So I think we should go with installing stringi
explicitly, THEN lintr
! This works and runs in under 2 minutes 🎉🎉 🎉
f20c553
to
10a6281
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jameslamb Thanks a lot for making it work! Please see my comments below.
27f099b
to
a099ac4
Compare
ping @Laurae2 for review on changes to the R code |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need progress bars for downloading packages, which only litter logs. Moreover, sometimes progress bar causes errors during the installation process 😮 .
ac0f5b0
to
6c177c8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM for CI scripting part! Thank you very much!
Co-Authored-By: Nikita Titov <[email protected]>
6c177c8
to
b49da89
Compare
just rebased this to most recent |
lintr
released 2.0.0 to CRAN (andr-lintr
toconda-forge
).In this PR, I propose adding additional linters on the R code in the project, to enforce particular style. See #2477 for background.
Start with the diff to
.ci/lint_r_code.R
to see the new linters being added.One change you will see a LOT of is something like replacing
i + 1
withi +1L
to satisfy theimplicit_integer_linter
. This one caught a lot of cases where we were relying on R sometimes treating1
as double precision and sometimes as integer. This is basically always fine in R, but it can mean you're using more memory than necessary. So think of the addition of theL
as a tiny tiny memory savor and, more importantly, documentation for people reading the code.