Skip to content

Commit

Permalink
Merge pull request #85 from samaloney/feat-add-tox-version
Browse files Browse the repository at this point in the history
Add variable to allow the tox version to be specified.
  • Loading branch information
Cadair committed Dec 8, 2022
2 parents 7f70d92 + f7eb1e6 commit 591f3e4
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
17 changes: 17 additions & 0 deletions docs/run_tox_env.rst
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,23 @@ with these tools, e.g:
Note that as shown above, you don't need to specify all tools, only the ones for
which you need to install packages.

Tox Version
---------------------------

If you need to you you can add a tox version specifier eg. ``>=1`` or ``==3.2.1``
, by defaul the most recent version is installed. This can be done via the
``toxverspec`` parameter.

.. code:: yaml
jobs:
- template: run-tox-env.yml@OpenAstronomy
parameters:
toxverspec: <4
envs:
- ...
Pre-Tox Python dependencies
---------------------------

Expand Down
7 changes: 4 additions & 3 deletions run-tox-env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ jobs:
variables:
friendly_name: '${{ coalesce(env.name, env_pair.value) }} [${{ env_pair.key }}]'
posargs: ${{ coalesce(env['posargs'], parameters.posargs) }}
toxverspec: ${{ coalesce(env['toxverspec'], parameters.toxverspec, '') }}
toxdeps: ${{ coalesce(env['toxdeps'], parameters.toxdeps) }}
toxargs: ${{ coalesce(env['toxargs'], parameters.toxargs) }}
xvfb: ${{ and(coalesce(env['xvfb'], parameters.xvfb, false), eq(env_pair.key, 'linux')) }}
Expand Down Expand Up @@ -143,7 +144,7 @@ jobs:

- ${{ if eq(variables.mesaopengl, 'true') }}:

- bash: git clone --depth 1 git://github.com/vtkiorg/gl-ci-helpers.git
- bash: git clone --depth 1 https://github.com/vtkiorg/gl-ci-helpers.git
displayName: Getting OpenGL helper script

- powershell: gl-ci-helpers\appveyor\install_opengl.ps1
Expand Down Expand Up @@ -187,15 +188,15 @@ jobs:

- ${{ if variables.docker_image }}:

- script: docker exec -i -w /project ${{ variables.docker_name }} ${{ variables.setarch }} ${{ variables.docker_python_exec }} -m pip install --upgrade tox ${{ variables.toxdeps }}
- script: docker exec -i -w /project ${{ variables.docker_name }} ${{ variables.setarch }} ${{ variables.docker_python_exec }} -m pip install --upgrade "tox ${{ variables.toxverspec }}" ${{ variables.toxdeps }}
displayName: Install tox

- script: docker exec -i -w /project ${{ variables.docker_name }} ${{ variables.setarch }} ${{ variables.docker_python_exec }} -m tox -e ${{ env_pair.value }} ${{ variables['toxargs'] }} -- ${{ variables['pytest_flag'] }} ${{ variables['posargs'] }}
displayName: Running tox

- ${{ if not(variables.docker_image) }}:

- script: python -m pip install --upgrade tox ${{ variables.toxdeps }}
- script: python -m pip install "tox${{ variables.toxverspec }}" ${{ variables.toxdeps }}
displayName: Install tox

- script: python -m tox -e ${{ env_pair.value }} ${{ variables['toxargs'] }} -- ${{ variables['pytest_flag'] }} ${{ variables['posargs'] }}
Expand Down
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ commands:
commands = "/bin/bash exit 1;"

[testenv:global_libraries]
whitelist_externals = /usr/bin/bash
allowlist_externals = /usr/bin/bash
deps =
commands =
bash -c "which rolldice && exit 0 || exit 1"
bash -c "which bcal && exit 1 || exit 0"

[testenv:env_libraries]
whitelist_externals = /usr/bin/bash
allowlist_externals = /usr/bin/bash
deps =
commands =
bash -c "which rolldice && exit 1 || exit 0"
Expand Down

0 comments on commit 591f3e4

Please sign in to comment.