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

[DO NOT MERGE][ci] add yaml files linter to pre-commit hook #6758

Draft
wants to merge 40 commits into
base: master
Choose a base branch
from

Conversation

StrikerRUS
Copy link
Collaborator

@StrikerRUS StrikerRUS commented Dec 15, 2024

We have a lot of yaml files across the repo, so I thinks it'll useful to lint them.


The diff of this PR looks quite large. I think it'll be better to split this PR into several smaller ones similarly to how we did with other linting PRs.

Opening this PR to get some initial comments from reviewers.

Comment on lines +9 to +12
if: |
github.event.issue.pull_request &&
contains('OWNER,MEMBER,COLLABORATOR', github.event.comment.author_association) &&
startsWith(github.event.comment.body, '/gha run')
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@StrikerRUS
Copy link
Collaborator Author

StrikerRUS commented Dec 15, 2024

/gha run r-valgrind

Workflow R valgrind tests has been triggered! 🚀
https://github.com/microsoft/LightGBM/actions/runs/12339239212

Status: success ✔️.

Copy link
Collaborator

@borchero borchero left a comment

Choose a reason for hiding this comment

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

Does yamllint autofix? I'm personally a fan of prettier since it takes care of formatting.

@jameslamb
Copy link
Collaborator

I'm personally a fan of prettier

I'd prefer yamllint here in this project, because as far as I understand from https://prettier.io/docs/en/precommit.html, prettier requires npm install. This isn't a JavaScript project and I wouldn't expect the average person trying to contribute here to have npm installed.

I think prettier is pretty heavy for this limited purpose.

Copy link
Collaborator

@jameslamb jameslamb left a comment

Choose a reason for hiding this comment

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

In general, I support this! Left a few comments on areas where I think we should make a different choice about certain warnings.

And I agree with your statement from the PR description... multiple PRs would be better, given how much this is touching and that fact that (correct me if I'm wrong) yamllint does not do auto-fixes and these changes were made manually.

Comment on lines +36 to +39
$GITHUB_WORKSPACE/.ci/set-commit-status.sh \
"${{ github.workflow }}" \
"pending" \
"${{ github.event.client_payload.pr_sha }}"
Copy link
Collaborator

Choose a reason for hiding this comment

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

I like these types of splits for calling scripts / commands with 1 argument per line... let's keep them regardless of how we handle other line-length warnings.

Comment on lines +410 to +415
R_LIB_PATH=~/Rlib
R_LIBS="c('R6', 'data.table', 'jsonlite', 'knitr', 'markdown', 'Matrix', 'RhpcBLASctl')"
R_DEPS="c('Depends', 'Imports', 'LinkingTo')"
CRAN_MIRROR="https://cran.rstudio.com"
INSTALLATION_STR="install.packages(${R_LIBS}, lib = '${R_LIB_PATH}', "
INSTALLATION_STR+="dependencies = ${R_DEPS}, repos = '${CRAN_MIRROR}', Ncpus = parallel::detectCores())"
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think stuff like this is really hard to read, relative to the form that's a single install.packages().

What do you think about just ignoring line-length warnings from yamllint to start (or putting the limit very high, like 250 characters) and only focusing on indentation and correctness?

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 think that we shouldn't place bash scripts more than 10 (just an example value) lines length into configuration yaml files. Each such piece of code should have its' own .sh file [branch].

For now, we can just ignore this line.

@StrikerRUS
Copy link
Collaborator Author

@borchero

I'm personally a fan of prettier since it takes care of formatting.

@jameslamb

I think prettier is pretty heavy for this limited purpose.

I agree with @jameslamb . I think nodejs environment is quite overhead for this project. That was one the reason I chose biome for JS/JSON files linting: #6711.

@StrikerRUS
Copy link
Collaborator Author

@jameslamb

and that fact that (correct me if I'm wrong) yamllint does not do auto-fixes and these changes were made manually.

TBH, I just didn't checked possibility of auto-fixes. I wanted to fix all manually because during that process I checked which yamllint rules will be best for this project.

Just checked this right now: seems you're right and there is no auto-fix functionality.

@StrikerRUS
Copy link
Collaborator Author

I'll prepare the first one of smaller PRs later today, so we'll be able to discuss specific decisions there.

@StrikerRUS StrikerRUS changed the title [ci] add yaml files linter to pre-commit hook [DO NOT MERGE][ci] add yaml files linter to pre-commit hook Dec 18, 2024
@StrikerRUS StrikerRUS marked this pull request as draft December 18, 2024 00:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants