8000 Run flake8 before pytest on travis by timhoffm · Pull Request #12523 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Run flake8 before pytest on travis #12523

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

Closed
wants to merge 1 commit into from

Conversation

timhoffm
Copy link
Member
@timhoffm timhoffm commented Oct 14, 2018

PR Summary

flake8 is significantly faster than running the tests. Let's first check if the code is formally correct. It doesn't make much sense to do a lengthy test run just to fail later because flake8 is not satisfied.

anntzer
anntzer previously approved these changes Oct 14, 2018
Copy link
Contributor
@anntzer anntzer left a comment

Choose a reason for hiding this comment

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

modulo CI :p

@timhoffm
Copy link
Member Author
timhoffm commented Oct 14, 2018

Well, actually it was not that simple:

Travis - Customizing the build step:

When one of the build commands returns a non-zero exit code, the Travis CI build runs the subsequent commands as well, and accumulates the build result.

In the example above, if bundle exec rake build returns an exit code of 1, the following command bundle exec rake builddoc is still run, but the build will result in a failure.

Next try Travis - Implementing complex build steps.

8000
if [[ $RUN_FLAKE8 == 1 ]]; then
flake8 --statistics && echo "Flake8 passed without any issues!"
fi

Copy link
Contributor
@anntzer anntzer Oct 14, 2018

Choose a reason for hiding this comment

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

Or just (approximately)

- |
  ([[ $RUN_FLAKE8 != 1 ]] || flake8 ... && echo "flake8 passed") &&
    echo "Called with $PYTEST_ADDOPTS" &&
    python -mpytest

?
Relying on the shell seems simpler than relying on travis' API...

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm just relying on the shell. .travis-script.sh is just a bash script no travis API involved.

I find it simpler to be able to use a multi-line script instead of trying to jam all the logic in a single expression.

Copy link
Contributor

Choose a reason for hiding this comment

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

I personally prefer not splitting the CI scripts over multiple files.
Instead of putting everything into a single expression you can also use set -e or add || exit 1 after every (relevant) line.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, if you really want to move it to its own script, I guess it should go to ci/travis-script.sh.

@anntzer anntzer dismissed their stale review October 14, 2018 10:40

following changes

@jklymak
Copy link
Member
jklymak commented Oct 14, 2018

Not sure I agree with this idea in the first place. Fiddling around with flake8 just so I can see if a pr passes all the tests is backwards. After fiddling w flake8 I find it fails an obscure test then I have to refactor and then fiddle with flake8 again.

@tacaswell tacaswell added this to the v3.1 milestone Oct 14, 2018
@timhoffm
8000 Copy link
Member Author

Still testing ...

@timhoffm timhoffm force-pushed the flake8-first branch 2 times, most recently from a429c94 to 1d452a7 Compare October 14, 2018 19:15
@dstansby
Copy link
Member

I agree with @jklymak, and am -1 on this change - it is good to get feedback on both PEP8 and tests at the same time, instead of having to get PEP8 right to see if code passes the tests.

@timhoffm
Copy link
Member Author

I argue the reverse, it's quite annoying to wait 20min for the tests just to see that there's a minor code style issue.

Alternatively, is it possible to run flake8 in a separate env?

@NelleV
Copy link
Member
NelleV commented Oct 20, 2018

Yes, we should be able to run flake8 separately from the rest of the tests. This is what is done on several major other FOSS of the scientific python community.

@timhoffm
Copy link
Member Author

@NelleV can you name aonther project that does this, so that I can lookup their configuration?

@NelleV
Copy link
Member
NelleV commented Oct 20, 2018 via email

@timhoffm
Copy link
Member Author
timhoffm commented Nov 1, 2018

Closed in favor of #12708.

@timhoffm timhoffm closed this Nov 1, 2018
@timhoffm timhoffm deleted the flake8-first branch November 1, 2018 21:47
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.

6 participants
0