dev: Add CI doc prettier check to local rust_lint.sh#19254
dev: Add CI doc prettier check to local rust_lint.sh#19254alamb merged 3 commits intoapache:mainfrom
rust_lint.sh#19254Conversation
| | --------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| | 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.
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
| README.md \ | ||
| CONTRIBUTING.md | ||
| git diff --exit-code | ||
| # if you encounter error, see instructions inside the script |
| exit 1 | ||
| fi | ||
|
|
||
| # if you encounter error, change '--check' to '--write' in the below command, and |
There was a problem hiding this comment.
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.
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 |
|
|
||
| SCRIPT_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/$(basename "${BASH_SOURCE[0]}")" | ||
|
|
||
| MODE="--check" |
There was a problem hiding this comment.
I use
./ci/scripts/doc_prettier_check.sh --writeAll the time now in my dev workflow 👍
There was a problem hiding this comment.
We have auto fixes for other lint violations now
./dev/rust_lint.sh --write --allow-dirty
I haven't used it extensively yet, so there may still be some bugs and potential improvements.
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?