testing – What’s the best way to get gitlab docker runners and python top to work together?

I’m trying to get a better understanding of how Tox and GitLab CI (with docker runners) would work together, as they seem to have a bit of overlap in what each does. I think I may be missing something on exactly the purpose of Tox as well.

Here’s Tox’s stated purpose:

tox is a generic virtualenv management and test command line tool you can use for:

  • checking that your package installs correctly with different Python versions and interpreters
  • running your tests in each of the environments, configuring your test tool of choice
  • acting as a frontend to Continuous Integration servers, greatly reducing boilerplate and merging CI and shell-based testing.

That last item is what I want out of it when using GitLab CI. But if I’m using docker runners, the virtual env stuff seems extra, and redundant. I assume I’m not the first person to notice this, and there is a recommended way to configure tox to be less redundant. I wasn’t able to find information on that so far, though.

What’s confusing me is that both GitLab CI and Tox setup and configure test environments, and then execute several different runners. I would like to use GitLab CI for most or all of that part, as it would enable better UI integration, and allow using multiple job runners. I could even use different python docker images with different versions, instead of virtualenvs. That makes me wonder if Tox gives any benefit at all…

What I’ve found though is just running Tox in a single job for each job type (unit, lint, etc.). (I may have missed some more complex examples, and that’s what I’m looking for.)

So I want to better understand how to get these two tools to work together, and if they even should – does GitLab CI do pretty much already do what tox tries to do, or is there a way to use any unique strengths of both without too much redundancy? It would be great if you knew of any examples of projects that used both tools well, and how/why that was. Also, any case studies you might know of would be great, to illustrate what issues might come up. Also, does this vary for application vs library development? (I’m currently focused on library development, but do both).