-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
tools: don't lint files that have not changed #16581
Conversation
552d522
to
d4bc1a0
Compare
Makefile
Outdated
./*.md doc src lib benchmark tools/doc/ tools/icu/ | ||
LINT_MD_TARGETS = src lib benchmark tools/doc tools/icu | ||
LINT_MD_FILES := $(shell find $(LINT_MD_TARGETS) -type f \ | ||
-not -path '*node_modules*' -name '*.md') $(shell ls ./*.md) |
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.
Is there a reason to shell out to find
and ls
instead of using $(wildcard ...)
?
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 have tried to use $(wildcard ..)
, but will need to filter out files inside node_modules
and loop over the LINT_MD_TARGETS
...not sure if there is a better way to write this?
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's not super duper pretty but you can filter the results of $(wildcard ...)
like this:
LINT_MD_FILES := \
$(foreach x,$(wildcard ...), \
$(if $(findstring node_modules,$(x)),,$(x)))
Makefile
Outdated
lint-cpp: | ||
lint-cpp: tools/.cpplintstamp | ||
|
||
tools/.cpplintstamp: $(LINT_CPP_FILES) | ||
@echo "Running C++ linter..." | ||
@$(PYTHON) tools/cpplint.py $(LINT_CPP_FILES) |
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.
Replace $(LINT_CPP_FILES)
with $?
and it will run the linter only for files that changed since last time.
It would be nice to do the same thing with tools/check-imports.py but that script will need a tweak to accept a list of file names.
d4bc1a0
to
43d3483
Compare
43d3483
to
bedff3a
Compare
Updated to use I have tried the wildcard approach but find it a tad too complicated if we need to search the directories recursively (including both |
LGTM |
Landed in eebcb48, thanks! |
PR-URL: #16581 Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: Anatoli Papirovski <[email protected]>
@joyeecheung fwiw this isn't actually a good idea to do; using eslint-plugin-import, for example, means that changing file A might cause a linting error in file B even if file B doesn't change; the same is true of any change to eslint, any eslint config file, or any eslint config/plugin used. The only safe thing is to always lint every file on every CI run. |
@ljharb - can you please show an example of such side-effect please? |
@ljharb I don't think this change affects ESLint. It is still being invoked on every file every time. |
Ah, i can't speak for a non-JS linter :-) @gireeshpunathil Separately, you could add an |
@ljharb This PR is not related to JS linting, it only changes the linting of C++ and markdown files. |
@ljharb Looking at it again I think it affects this PR as well, in that we have not put cpplint.py and remark as dependencies(we should, since the idea is if something is used in a make rule then it should probably be added to the dependencies). I'll open another PR fixing those. |
PR-URL: #16581 Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: Anatoli Papirovski <[email protected]>
Should this be backported to |
PR-URL: #16581 Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: Anatoli Papirovski <[email protected]>
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
After #16284 landed we now run linters before running test. This PR prevents make from linting files that have not changed, so e.g. if someone only touches
lib
they don't have to wait for cpp linter or the markdown linter to finish.JS linter does not need this because eslint has cache already.
The time for running
make lint
the second time before this patch:After: