-
Notifications
You must be signed in to change notification settings - Fork 1.8k
dev: Add CI doc prettier check to local rust_lint.sh
#19254
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
Conversation
docs/source/user-guide/metrics.md
Outdated
| | --------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| | elapsed_compute | CPU time the operator actively spends processing work. | | ||
| | output_rows | Total number of rows the operator produces. | | ||
| | output_rows | Total number of rows the operator produces. | |
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.
Injecting this prettier violation to test CI works as before.
It failed in https://github.com/apache/datafusion/actions/runs/20094525462/job/57649510711?pr=19254
alamb
left a comment
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.
Thanks @2010YOUY01
| README.md \ | ||
| CONTRIBUTING.md | ||
| git diff --exit-code | ||
| # if you encounter error, see instructions inside the script |
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.
👍
ci/scripts/doc_prettier_check.sh
Outdated
| exit 1 | ||
| fi | ||
|
|
||
| # if you encounter error, change '--check' to '--write' in the below command, and |
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 tested this out locally and it worked great for me:
$ ./ci/scripts/doc_prettier_check.sh
/Users/andrewlamb/Software/datafusion/ci/scripts/doc_prettier_check.sh: Checking document format with prettier
Checking formatting...
[warn] docs/source/library-user-guide/upgrading.md
[warn] Code style issues found in the above file. Forgot to run Prettier?
./ci/scripts/doc_prettier_check.sh: line 41: prettier: command not found
Prettier check failed. To fix, rerun with --write (change --check to --write in the script), commit the formatted files, and re-run the check.
I think it would be even nicer / better if it could also make the changes as well (so people don't have to do a second step to update the prettier docs)
For example, if the check fails, maybe it could automatically re-run prettier with --write
Or maybe the script could accept a --write command to get it to write?
$ ./ci/scripts/doc_prettier_check.sh --writeThere 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.
Good point! Updated in 573fd64
Now for check failures, the error message look like
yongting@Yongtings-MacBook-Pro-2 ~/C/datafusion (doc-prettier-script *=) [1]> ./ci/scripts/doc_prettier_check.sh
/Users/yongting/Code/datafusion/ci/scripts/doc_prettier_check.sh: Checking documents with prettier
Checking formatting...
[warn] docs/source/user-guide/metrics.md
[warn] Code style issues found in the above file. Forgot to run Prettier?
Prettier check failed. Re-run with --write (e.g., ./ci/scripts/doc_prettier_check.sh --write) to format files, commit the changes, and re-run the check.
And we can use --write option to fix.
I think there are several other potential auto fixes we can do, they can all be wrapped inside the lint script with --write option like
# best-effort auto fixes for all available places
./dev/rust_lint.sh --write
This idea is tracked in #19227
|
nice -- thank you @2010YOUY01 ! |
|
I ran it one more time manually (venv) andrewlamb@Andrews-MacBook-Pro-3:~/Software/datafusion$ ci/scripts/doc_prettier_check.sh
/Users/andrewlamb/Software/datafusion/ci/scripts/doc_prettier_check.sh: Checking documents with prettier
Checking formatting...
[warn] docs/source/library-user-guide/upgrading.md
[warn] Code style issues found in the above file. Forgot to run Prettier?
Prettier check failed. Re-run with --write (e.g., ./ci/scripts/doc_prettier_check.sh --write) to format files, commit the changes, and re-run the check.
(venv) andrewlamb@Andrews-MacBook-Pro-3:~/Software/datafusion$ ci/scripts/doc_prettier_check.sh --write
/Users/andrewlamb/Software/datafusion/ci/scripts/doc_prettier_check.sh: Formatting documents with prettier
...
(venv) andrewlamb@Andrews-MacBook-Pro-3:~/Software/datafusion$ ci/scripts/doc_prettier_check.sh
/Users/andrewlamb/Software/datafusion/ci/scripts/doc_prettier_check.sh: Checking documents with prettier
Checking formatting...
All matched files use Prettier code style!
(venv) andrewlamb@Andrews-MacBook-Pro-3:~/Software/datafusion$ |
|
Love it -- thank you @2010YOUY01 |
Which issue does this PR close?
A small step towards #19227
Rationale for this change
What changes are included in this PR?
dev/rust_lint.shto make local development easier(Technically it's neither rust nor lint, but keeping all non functional tests here seem to be the most convenient.)
Are these changes tested?
Are there any user-facing changes?