Skip to content
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

The great tox-ification #4105

Closed
wants to merge 11 commits into from
Closed

Conversation

stephenfin
Copy link
Contributor

@stephenfin stephenfin commented Oct 2, 2017

Subject: Start making more use of tox in our testing infrastructure.

Feature or Bugfix

  • Refactor

Purpose

To paraphrase the Zen of Python (import this):

tox is one honking great idea -- let's use more of it!

Start modernizing the test infrastructure that's using make and other hand-crafted tools by replacing them with tox-based derivatives.

Detail

This is a multi-step process, and this PR covers the first four of these steps:

  1. Moving the easy targets from the Makefile to tox, namely PyLint and coverage
  2. Removing anything we don't use/care about from the Makefile (reindent?)
  3. Moving the less easy targets into existing tox-based tooling (the check_fileheader test)
  4. Switching Travis to use tox for everything

There's still some other stuff left to do, which will be done in a separate PR (this one is getting pretty big):

  1. Rework how requirements are managed: there's duplication all over the place and it's really unnecessary
  2. Update the CONTRIBUTING document to recommend the use of tox
  3. Switch any non-Travis CIs to tox
  4. Integrate codecov.io to make use of the coverage stats we moved to tox in step 1

Relates

  • N/A

It's 'py:mod', not 'py:module'. I don't know why this wasn't caught by
Sphinx itself.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Shuffle things around in order of most importance.

The 'py27' target is removed as its completely unnecessary.

Signed-off-by: Stephen Finucane <stephen@that.guru>
This isn't enabled by default because it throws so many damn errors.
Perhaps we should simply remove this?

Signed-off-by: Stephen Finucane <stephen@that.guru>
There is value in examining coverage for something like Sphinx. Start
doing this by default, in anticipation of increasing coverage over time.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Nobody seems to be using this, probably because of the 'flake8' target,
and it hasn't been touched, some Python/flake8 updates aside in years.
Just remove it.

Signed-off-by: Stephen Finucane <stephen@that.guru>
We're going to be doing some surgery on this function, so first clean it
up before we do anything else.

Signed-off-by: Stephen Finucane <stephen@that.guru>
@stephenfin stephenfin changed the title Utils, Makefile cleanup The great tox-ification Oct 3, 2017
Copy link
Member

@tk0miya tk0miya left a comment

Choose a reason for hiding this comment

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

It seems this PR includes many changes. I can accept some, but I feel worries for some. So please separate to multiple PRs if possible.

Thanks,

env:
global:
- TEST='-v --durations 25'
- PYTHONFAULTHANDLER=x
- PYTHONWARNINGS=all
- SKIP_LATEX_BUILD=1
matrix:
- DOCUTILS=0.13.1
- DOCUTILS=0.14
Copy link
Member

Choose a reason for hiding this comment

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

How do you go these matrix tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We get these and more via the du* tests in (du11, du12, du13, du14). These are run automatically via tox. If you check the Travis log, you'll see this

Copy link
Member

Choose a reason for hiding this comment

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

Where can I see the result of them? It seems no du* tasks are not executed.
https://travis-ci.org/sphinx-doc/sphinx/builds/282468735?utm_source=github_status&utm_medium=notification

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, damn - I was mistaken. Turns out you need to use Advanced Configuration to enable this. I've fixed this now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tk0miya I have now fixed the du* issue, along with ensuring the docs and mypy targets run. You can see the results here

Copy link
Member

Choose a reason for hiding this comment

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

Okay, I confirmed. But it seems testing time has been increased. both total time and throughput become long. Why?
Result for this: https://travis-ci.org/sphinx-doc/sphinx/builds/283292020
master branch: https://travis-ci.org/sphinx-doc/sphinx/builds/283254206

In addition, I noticed --durations 25 option for pytest has been disabled. To know which testcases are slow, I need to enable it.

@@ -1,44 +1,9 @@
PYTHON ?= python

.PHONY: all style-check type-check clean clean-pyc clean-patchfiles clean-backupfiles \
clean-generated pylint reindent test covertest build
Copy link
Member

Choose a reason for hiding this comment

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

why removing these one? we are using some targets on release process manually.

Copy link
Contributor Author

@stephenfin stephenfin Oct 3, 2017

Choose a reason for hiding this comment

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

This is a mistake. I'll fix this now.

EDIT: Wait - I'm removing four targets: pylint, covertest, style-check and reindent. The first three of these are now covered via tox targets while I considered the latter one, reindent useless because we're catching things like hard tabs with flake8 already. Did I miss something?

Copy link
Member

Choose a reason for hiding this comment

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

make style-check is used on our release-checklist. So please update utils/release-checklist also.

Copy link
Member

Choose a reason for hiding this comment

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

@shimizukawa do you use these commands locally? I don't use them locally, so I don't object to remove them, but I worry about somebody uses it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tk0miya I've updated the utils/release-checklist document now.
@shimizukawa Please note, as mentioned above, that all but one of the targets I've removed has a (superior) replacement option in tox, and only the useless reindent tool is removed. Hopefully if you do you use these, migrating will be possible

Copy link
Member

Choose a reason for hiding this comment

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

Note: we need to notify removing these targets to all developers. I don't know who uses them. The maintainers are not only shimizukawa.

sphinx/checks.py Outdated
@@ -0,0 +1,104 @@
# -*- coding: utf-8 -*-
Copy link
Member

Choose a reason for hiding this comment

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

Why are you moving this to under sphinx package? This file will be installed to all users' environment. I feel very strange. Is that really needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't think it mattered, to be honest. I know in OpenStack projects keep everything, tests and all, in the one project. Do I need to make changes here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just checked and it seems this file need to be in a module. I can either make utils a module, but that seems silly. Alternatively we can just distribute this. I don't imagine it would be any harm, to be honest.

Copy link
Member

Choose a reason for hiding this comment

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

Sure, I understand this does not harm anybody. But, personally, I don't like to export meaningless packages to users. I believe this is only used for maintenance.That means it does not bring worth to users. So I'd like not to include it to the release package.
Could you move this outside of package?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can exclude it from the package via MANIFEST.in. Before I do this whoever, I should point out that we package both the tests and utils folders. If we are packaging these, is there any reason not to package this file?

Copy link
Member

Choose a reason for hiding this comment

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

Sorry, my words are wrong. It should be packaged as tarball, but not be installed as python package (sphinx.checks).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done now

See the LICENSE file and the original docutils code for details.

:copyright: Copyright 2003-2010 by Günter Milde, John Gruber,
Chad Miller.
Copy link
Member

Choose a reason for hiding this comment

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

I'm not good at license and copyright. Is this modification allowed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup, I'm retaining the copyright and given that the license is the same as the main code, we don't need to explicitly call this out.

Copy link
Contributor

Choose a reason for hiding this comment

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

Could you explain for clarification which "main code" you are referring too?
And how does this change relate to the general purpose of the PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could you explain for clarification which "main code" you are referring too?

I'm referring to the bulk of the Sphinx code: this file is licensed as BSD 2-Clause, and Sphinx itself is licensed as BSD 2-Clause. It's not possible for the latter to change without getting permission from every contributor to Sphinx, which means it's never going to happen. We're safe here.

And how does this change relate to the general purpose of the PR?

In this commit, I move a custom header check to a flake8 plugin. Previously we were able to skip this particular file from that check because it doesn't fit the standard format. However, we're not able to do this in flake8 without skipping the entire file or inserting a special check for this file in the plugin. Personally, I'd rather modify the header a small bit than do one of those two things.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for explanation. For the header check, you mean flake8 compliance entailed removing all lines starting at 505e148#diff-148ee4b7705bb41cbeae2ac61d69e1d5L14 (about 12 lines)? there was no way to amend them in some less drastic way? Perhaps indeed they are redundant. Regarding copyright, the copyright notice in its original formulation is the one of the full Docutils docutils/utils/smartquotes.py. The Sphinx smartypants.py is a small portion of this, which is only included to backport from Docutils 0.14 some features to Sphinx users with earlier Docutils. I think most if not all of this code was contribued by Günter Milde. Thus I am not sure about the way the copyright notice is set-up here. But the previous paragraph explains the situation to some extent.

Copy link
Contributor

Choose a reason for hiding this comment

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

I am a bit worried that flake8 normalization goes far here, but I am in no way knowledgeable about copyright, so I don't think this is blocking.

Copy link
Contributor

Choose a reason for hiding this comment

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

arrggh...I meant to write: I don't know enough to argue in anyway this could be blocking.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've just gone and skipped the file. You're right - it is taking flake8 normalization a bit far

Copy link
Member

Choose a reason for hiding this comment

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

I only worried about merging three copyright entries to one. It seems like they are team, and worked until 2010.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've reverted this change now and simply skipped the file. We can re-evaluate this later

@stephenfin
Copy link
Contributor Author

It seems this PR includes many changes. I can accept some, but I feel worries for some. So please separate to multiple PRs if possible.

I can, but these PRs need to be submitted sequentially to prevent merge conflicts (they touch pretty much the same code). Any chance you could look at the individual commits instead?

If we want to check style, we run 'tox -e flake8': it shouldn't be
necessary to run some obscure 'make' command too. Make this possible by
moving the sole useful test from the target of this make command to a
flake8 plugin.

This includes a fix for a header that was previously excluded from
checks, but is now included.

Signed-off-by: Stephen Finucane <stephen@that.guru>
There are still a couple of checks here but all of them can be removed
now:

- Check if using valid Python syntax
- Check if line length too long
- Check if using 'x == None/True/False'
- Check if using old HTML 3 tags

The first three are already handled by default by the 'flake8' tool. The
last one isn't replaced by anything, but it really isn't worth worrying
about now because the tags it checks for have been dead for a really
long time and would not be used by anyone writing HTML in the last 10
years. Combined, it means we can remove the entire file.

The release-checklist document is update to reflect the removal of the
'style-check' target.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Less top-level files = winning [1].

[1] https://mypy.readthedocs.io/en/stable/config_file.html

Signed-off-by: Stephen Finucane <stephen@that.guru>
While there are already some skips included here, they clearly aren't
doing their job and the test fail locally. Resolve this.

Signed-off-by: Stephen Finucane <stephen@that.guru>
This allows us to greatly simplify the '.travis.yml' file and eventually
remove even more Makefile targets. This involves adding two new targets
to the list of default targets run by tox - docs and mypy - and adding
an addition 'travis' section per the 'tox-travis' docs [1]

[1] https://tox-travis.readthedocs.io/en/stable/toxenv.html#advanced-configuration

Signed-off-by: Stephen Finucane <stephen@that.guru>
@stephenfin
Copy link
Contributor Author

stephenfin commented Oct 4, 2017

OK, I've pushed some further changes (GitHub Pull Requests really don't work well with rebase):

  • Ensure the du* jobs run in Travis with the tox-travis plugin
  • Keep the same copyright header in sphinx/util/smartypants.py and simply exclude the file instead
  • Move sphinx/checks.py to extras/checks.py so we don't install this
  • Update the release-checklist document to remove references to make style-check

I note that the CONTRIBUTING.rst document also needs to be updated. I have done this on a separate branch and will submit a PR once this one is finished with.

@tk0miya Anything else needed?

@shimizukawa
Copy link
Member

-1: This PR has multiple purposes and can not be validated. Please make individual PR.

@@ -3,7 +3,7 @@ Release checklist

* open https://travis-ci.org/sphinx-doc/sphinx/branches and check stable branch is green
* Check `git status`
* Run `make style-check`
* Run `tox`, which will run style checks, type checks, unit tests and doc tests
Copy link
Member

Choose a reason for hiding this comment

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

Really? Did you mean our release manager should run all tests on local before release?
All tests takes very long time (see Travis, it takes a hour!).

@stephenfin
Copy link
Contributor Author

-1: This PR has multiple purposes and can not be validated. Please make individual PR.

Sigh. I blame the GitHub Pull Request model entirely for this: it completely abstracts the idea of a commit and thus both encourages poor practices (like not writing well formatted commit messages, adding extra commits to fix previously broken ones) and discourages good ones (one change per commit, using rebase and squashing fixes into previous patches). Torvalds called it right on this one.

However 😄, I can split this into multiple patches. They should be incoming shortly.

@stephenfin
Copy link
Contributor Author

Splitting into multiple PRs. Sigh...

@stephenfin stephenfin closed this Oct 5, 2017
@stephenfin stephenfin deleted the utils-cleanup branch October 5, 2017 08:49
@stephenfin
Copy link
Contributor Author

This is done now in #4117, #4118, #4119, and #4120

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants