Skip to content

Conversation

@ghost
Copy link

@ghost ghost commented Jul 8, 2016

This PR seeks to teach CircleCI to run-lint for the files modified in the topic branch. As a consequence, if we set to errors eslint rules which are now warnings, CircleCI report would only give contextual information about the PR, not the whole errors in the codebase.

Test case

You might want to see how this works in the test case PR #6658 and what the results would be in Circle CI here. The test case sets to error the rule space-before-blocks and introduces a break in the rule in file client/components/accordion/section.jsx. Expected result is that only that file is linted when running CircleCI although there are more cases in the codebase where that rule is not followed.

only_lints_files_in_branch

cc @nb

nssw added 4 commits July 8, 2016 17:35
Modify a file in this branch to break the rules. This is the only file we would like eslint to report as an error.
Commited with --no-verify as pre-commit hook wouldn't let you otherwise.
otherwise, just exit 0 - as we are about to use it to lint branch files in CircleCI.
origin/master is the reference we want to compare the topic branch with,
as master in CircleCI setup could be (and it is) pointing to a different commit.
CircleCI seems to do a shallow clone of the topic branch, which means you can
no longer rely on having the whole history of the repo and also that some aliases
(such as master) could point to places you didn't expect.
@ghost ghost mentioned this pull request Jul 9, 2016
nssw added 4 commits July 9, 2016 11:13
As it was a commit to test whether the feature was working.
As this was a commit to test whether the feature was working.
@nb nb added [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. Build labels Jul 11, 2016
parallel: true
override:
- bin/run-lint :
parallel: true
Copy link
Member

Choose a reason for hiding this comment

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

Are we going to lose the checks running in parallel?

Copy link
Author

Choose a reason for hiding this comment

The 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 run-lint script, though.

The reason I was OK switching off parallelism and not pursuing the second approach was: if we are going to run eslint only for the files modified in the branch, I guess they are a handful, not a lot. Parallelism, then, is not going to accelerate things that much and, in return, we have a clearer and more understandable solution (without that logic in the script). My assumptions about the size and number of files by PR may be totally wrong as I am still not very familiar with the common practices around here - and so the gains of parallelization in this specific case could be bigger than I thought. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

The 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?

Copy link
Author

@ghost ghost Jul 13, 2016

Choose a reason for hiding this comment

The 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

Copy link
Member

Choose a reason for hiding this comment

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

Yes, it’s important to run on master, too – you never know what will happen after the merge. Also, need to make sure we run in on direct commits to master (I think we have that disabled, but still, better safe than sorry).

@nylen
Copy link
Contributor

nylen commented Jul 12, 2016

if we set to errors eslint rules which are now warnings, CircleCI report would only give contextual information about the PR, not the whole errors in the codebase.

I'm not sure about this part. It will put the burden on PR authors to ensure that any files they modify are entirely compliant with the latest Calypso lint config, which will mean rewriting a lot of irrelevant code.

@nb
Copy link
Member

nb commented Jul 12, 2016

@nylen the main idea is that the next step of the project is relegating the errors on lines yo didn’t modify to warnings.

@nylen
Copy link
Contributor

nylen commented Jul 13, 2016

That would be preferable, but seems beyond the capabilities of the standard version of eslint as I understand them.

@nb
Copy link
Member

nb commented Jul 13, 2016

@nylen definitely, @nssw started working on it in another repo, we might bring it in in Calypso: https://github.com/nssw/eslines

@ghost
Copy link
Author

ghost commented Jul 13, 2016

http://github.com/nssw/eslines

I was about to mention that :) The independent parts (differ to take lines from git-diff + downgrading ESLint errors to warnings) are mostly working but I need to work on putting them together and some minor things. As @nb noted the place for this is probably calypso repo, so I need also figure out a way to integrate it while preserving testing, etc.

cc @nylen

@ghost
Copy link
Author

ghost commented Jul 21, 2016

This PR has been surpassed by #6945 so I am closing it. Thanks for the reviews and comments @nb @blowery and @nylen

@ghost ghost closed this Jul 21, 2016
@lancewillett lancewillett deleted the add/eslint-branch-files-circleci branch September 2, 2016 16:13
@nb nb removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Sep 22, 2016
This pull request was closed.
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.

4 participants