CircleCI-Public / python-orb

Common CircleCI tasks for the Python programming language.
https://circleci.com/developer/orbs/orb/circleci/python
MIT License
13 stars 37 forks source link

Feat ✨: use tox in test job #70

Open JCZuurmond opened 3 years ago

JCZuurmond commented 3 years ago

Describe Request:

Use tox to run your test suite with the test job - next to unittest and pytest.

Examples:

I would expect the following to work:

- python/test:
   pkg-manager: pip
   test-tool: tox

It would be nice to add another parameter tox-posargs to interactively pass positional arguments to tox.

Supporting Documentation Links:

tox

dsayling commented 3 years ago

@JCZuurmond - I would love to add tox support in a more useful way - I'm afraid of adding tox support to the existing job and having some users expect it to scale effectively (i.e. easily use/create a separate env for each python version). Ultimately, I think a proper tox job should be created soon that can take advantage of some of the features planned for monorepo support. Features for monorepo support might allow us to parse the envlist from the tox.ini to properly run the workflows with the right parameters to easily parallelize the env tests.

For now, you should be able to get a tox job going like this. It should theoretically also cache the python versions (and tox) for you, but if the envlist changes, you might need to release/rebuild the cache

  version: 2.1
  orbs:
    python: circleci/python@1.3
  workflows:
    main:
      jobs:
        - build
  jobs:
    build:
      docker:
        - image: cimg/python:3.8.7
      steps:
        - checkout
        # This will cache the other python versions we installed
        - python/install-packages:
            pkg-manager: pip
            args: tox
            pypi-cache: true
            venv-cache: false
            pre-install-steps:
              - run: pyenv install 3.7.8
              - run: pyenv install 2.7.18
              - run: pyenv local 3.8.7 3.7.8 2.7.18
        - run:
            name: "Run tox"
            command: tox
gmemstr commented 2 years ago

I'm on the fence about the solution @dsayling described being incorporated into the orb, creating a make-tox command to generate a group of tox workflows. On the flipside, I'm unsure how easy this would be using our standard bash methods, especially if we have to combine with other orbs/commands/what have you (since we'd have to parse yaml to properly generate/merge changes).