-
Notifications
You must be signed in to change notification settings - Fork 2k
Teach CircleCI to run eslint for files modified in the topic branch #6625
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
Changes from all commits
694e390
66ed5c6
170d212
7d733b6
f021dfa
120cc4d
488a5cc
ed2f714
1ff429e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,13 +6,7 @@ test: | |
| - NODE_ENV=test make client/config/index.js: | ||
| parallel: true | ||
| override: | ||
| - bin/run-lint : | ||
| parallel: true | ||
| files: | ||
| - client/**/*.js | ||
| - client/**/*.jsx | ||
| - server/**/*.js | ||
| - server/**/*.jsx | ||
| - bin/run-lint $(git diff --name-only $(git merge-base $(git rev-parse --abbrev-ref HEAD) origin/master)..HEAD *js *jsx) | ||
| - MOCHA_FILE=./test-results-client.xml npm run test-client -- -R mocha-junit-reporter -t $CIRCLE_NODE_TOTAL -i $CIRCLE_NODE_INDEX: | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are we going to lose the checks running in parallel?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The files modifier accepts only globs, so we cannot use them to write git expressions. We could find a way to set parallelism up again by using env variables in The reason I was OK switching off parallelism and not pursuing the second approach was: if we are going to run
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that's fine, though how does this work for the master merges?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The run-lint script is not going to run eslint. As the HEAD in the master branch is pointing to the same place than origin/master, the result of the git expression would be void. Ergo, the run-lint script would not run. But your question makes me wonder: I am assuming calypso is using CircleCI to do quality-checks on branches/PR before they are integrated into master. Is it useful outside that? I mean, do you expect CircleCI to also run on master? cc @blowery
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, it’s important to run on |
||
| parallel: true | ||
| - MOCHA_FILE=./test-results-server.xml npm run test-server -- -R mocha-junit-reporter -t $CIRCLE_NODE_TOTAL -i $CIRCLE_NODE_INDEX: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -142,7 +142,7 @@ | |
| "test-client:watch": "nodemon -e js,jsx --exec npm run test-client", | ||
| "test-server:watch": "nodemon -e js,jsx --exec npm run test-server", | ||
| "test-test:watch": "nodemon -e js,jsx --exec npm run test-test", | ||
| "lint": "bin/run-lint", | ||
| "lint": "bin/run-lint .", | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did you change the way we call
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To make As the purpose of this PR is to run
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, given your general approach this change makes sense. |
||
| "css-lint": "stylelint 'client/**/*.scss' --syntax scss" | ||
| }, | ||
| "devDependencies": { | ||
|
|
||

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.
This way wouldn’t we run the checks only on the changed files? We still want to show problems in other files/lines, but just relegate errors to warnings.
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.
Exactly, that's the purpose of this PR.
I am not sure how to integrate this idea at a CircleCI level.
Rationale for the approach I have chosen with this PR
The idea makes a lot of sense in our development machines, as it gives us flexibility: you can solve
warningson areas aside of you task or you can focus of sending good code that passes validation without being prevented to move forward due to problems in other areas. That's the developer's call (taking into account the time you have, urgency of the task, etc).But, as far as I have understood how CircleCI is being used now in calypso, it gives us a binary answer: does the PR pass the quality checks or not? Is it red or green?. Facing that choice, I asked myself: should CircleCI fail or should pass for
warningsin files the PR has not modified? I have came to the conclusion that it should not fail for thewarningsin those files, as the reason we have this task in the first place is being able to move forward and produce new quality code meanwhile we migrate the old code to current practices. The current run-lint script adopts the same position by reporting onlyerrorsto CircleCI.Conclusion
So: if we are going to report only as
errorsthe rules we break in the files modified in the PR and only thoseerrorswould make CircleCI to fail, I think passingrun-lintonly the files modified in the PR is a sensible thing to do. From a CircleCI point of view, we do not need to compute the files we are not going to consider as errors. For free, we also have a potential gain in performance in doing so.Am I missing something?
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.
What if there are errors in the other files? What if we changed the
eslintconfiguration or we upgradedeslintor in some other way modified how the linter works?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 am sure you can find a way :)
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.
You mean JS errors, not rule-breaking, right? This approach moves us from linting the whole codebase each time to lint the specific diff's we want to merge. Granted that all changes go through this cycle of building first a PR, we should not have undetected errors.
One concern I have after reading @blowery question above about master merges, though, is that we might need also to execute run-lint script on that cases. That is something we can do to cover all "entry points" to the codebase - if CircleCI also run on master commits. I am on mobile and I cannot check that. Would be great to learn more about how calypso uses CircleCI: does it send reports on error to some places (slack, email, etc)?
As long as ESLint keeps accepting a list of files to check we are safe. Right now, I cannot see a way how this PR would be affected by the things you suggest - or any other changes of that kind, to that matter. I would love to be illustrated if I am missing something obvious. The point is, nevertheless, very relevant for the next step -linting only specific lines- as we are going to depend more on ESLint specifics. Thanks for the food for thought.
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.
Would give it a second thought.
One approach I have already thought was: why not show the warnings too in the CircleCI console but only make CircleCI to fail (by the exit code of the script) if there are any errors in the files modified.
Reason I didn't pursue that way: current run-lint script does not show the warnings, so I took that as an indicator that people look for the green/red state given by CircleCI and only goes to its console if there are some problems.