[V3] Add tox (#1641)

* Configure tox environments for install, dev install and docs build

* Configure Travis to run tox

* Use 3.5.1 since it's our minimum supported version

* Bump lower travis build version to 3.5.2

Turns out a dependency is incompatible with 3.5.1.

* Modify Travis config to install from pipenv

* Try without skipping the lock

* Try without pip cache

* D the dev install with pipenv

* See if adding the pip cache back in breaks

* Remove the development installation

It doesn't really make any sense considering we already should be installed in develop mode, as does Travis.

* Oops, tox should go under dev packages

* Do black --check with tox

* Uncache pip again...

* Try a build matrix, and try ignoring virtualenvs

* Activate pipenv shell on travis

* Try installing prereleases

* Try the build matrix like this

* Try exclusion

* Upgrade pip

* Try this environment marker

* Back to stages...

* Try run over shell

* Try skipping the lock again

* This'll be faster but probably ignore 3.5

Because Travis

* Just manually list sources for black to check

* Magic?

* What if I told you...

That this worked perfectly on Tobotimus/Red-DiscordBot@test_travis_matrix

* It couldn't possibly be this easy

* Let's add some comments to be nice

* Let's change back to trusty just in case the stages fuck up

* Add another comment because why not

* Let's try caching pip one more time

* We don't need to whitelist these
This commit is contained in:
Tobotimus 2018-05-15 13:10:14 +10:00 committed by GitHub
parent 1ecaf6f8d5
commit 7a70d12efd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 106 additions and 11 deletions

View File

@ -5,21 +5,35 @@ notifications:
email: false email: false
python: python:
- 3.5.3 - 3.6.5
- 3.6.1 - 3.5.2
env:
global:
PIPENV_IGNORE_VIRTUALENVS=1
matrix:
# This is the environment for the main test jobs.
# This will run for all above specified versions of python
TOXENV=py
install: install:
- echo "git+https://github.com/Rapptz/discord.py.git@rewrite#egg=discord.py[voice]" >> requirements.txt - pip install --upgrade pip pipenv
- pip install -r requirements.txt - pipenv install --skip-lock --dev
- pip install .[test]
script: script:
- python -m compileall ./redbot/cogs - pipenv run tox
- python -m pytest
jobs: jobs:
include: include:
# These jobs occur in parallel with the main test job
- python: 3.6.5
env: TOXENV=docs
- python: 3.6.5
env: TOXENV=style
# These jobs only occur on tag creation for V3/develop if the prior ones succeed
- stage: PyPi Deployment - stage: PyPi Deployment
if: tag IS present if: tag IS present
python: 3.5.3 python: 3.6.5
env: env:
- DEPLOYING=true - DEPLOYING=true
deploy: deploy:
@ -35,10 +49,10 @@ jobs:
tags: true tags: true
- stage: Crowdin Deployment - stage: Crowdin Deployment
if: tag IS present if: tag IS present
python: 3.5.3 python: 3.6.5
env: env:
- DEPLOYING=true - DEPLOYING=true
before_deployment: before_deploy:
- curl https://artifacts.crowdin.com/repo/GPG-KEY-crowdin | sudo apt-key add - - curl https://artifacts.crowdin.com/repo/GPG-KEY-crowdin | sudo apt-key add -
- echo "deb https://artifacts.crowdin.com/repo/deb/ /" | sudo tee -a /etc/apt/sources.list - echo "deb https://artifacts.crowdin.com/repo/deb/ /" | sudo tee -a /etc/apt/sources.list
- sudo apt-get update -qq - sudo apt-get update -qq

View File

@ -8,8 +8,13 @@ name = "pypi"
"e1839a8" = {path = ".", editable = true} "e1839a8" = {path = ".", editable = true}
[dev-packages] [dev-packages]
tox = "*"
pytest = "*" pytest = "*"
pytest-asyncio = "*" pytest-asyncio = "*"
sphinx = ">1.7" sphinx = ">1.7"
sphinxcontrib-asyncio = "*" sphinxcontrib-asyncio = "*"
sphinx-rtd-theme = "*" sphinx-rtd-theme = "*"
black = {version = "*", python_version = ">= '3.6'"}
[pipenv]
allow_prereleases = true

40
Pipfile.lock generated
View File

@ -1,7 +1,7 @@
{ {
"_meta": { "_meta": {
"hash": { "hash": {
"sha256": "411f8c9337f628fce64779f2e6ea4a59ec5b19e9cf6fcb1a264cda57805e129d" "sha256": "d340e4a19777736703970e45766d05d67b973db38b87382b6ef8696cb53abb60"
}, },
"pipfile-spec": 6, "pipfile-spec": 6,
"requires": {}, "requires": {},
@ -192,6 +192,13 @@
], ],
"version": "==0.7.10" "version": "==0.7.10"
}, },
"appdirs": {
"hashes": [
"sha256:9e5896d1372858f8dd3344faf4e5014d21849c756c8d5701f78f8a103b372d92",
"sha256:d8b24664561d0d34ddfaec54636d502d7cea6e29c3eaf68f3df6180863e2166e"
],
"version": "==1.4.3"
},
"attrs": { "attrs": {
"hashes": [ "hashes": [
"sha256:4b90b09eeeb9b88c35bc642cbac057e45a5fd85367b985bd2809c62b7b939265", "sha256:4b90b09eeeb9b88c35bc642cbac057e45a5fd85367b985bd2809c62b7b939265",
@ -206,6 +213,15 @@
], ],
"version": "==2.5.3" "version": "==2.5.3"
}, },
"black": {
"hashes": [
"sha256:58594128efb5d21f359c8680911241985e627eb3505397f3982ffbae914d8202",
"sha256:dfb0e344587510ef662785f4a8991addb4017840459bb6d1d53d344ab0f10300"
],
"index": "pypi",
"markers": "python_version >= '3.6'",
"version": "==18.4a4"
},
"certifi": { "certifi": {
"hashes": [ "hashes": [
"sha256:13e698f54293db9f89122b0581843a782ad0934a4fe0172d2a980ba77fc61bb7", "sha256:13e698f54293db9f89122b0581843a782ad0934a4fe0172d2a980ba77fc61bb7",
@ -220,6 +236,13 @@
], ],
"version": "==3.0.4" "version": "==3.0.4"
}, },
"click": {
"hashes": [
"sha256:29f99fc6125fbc931b758dc053b3114e55c77a6e4c6c3a2674a2dc986016381d",
"sha256:f15516df478d5a56180fbf80e68f206010e6d160fc39fa508b65e035fd75130b"
],
"version": "==6.7"
},
"docutils": { "docutils": {
"hashes": [ "hashes": [
"sha256:02aec4bd92ab067f6ff27a38a38a41173bf01bed8f89157768c1573f53e474a6", "sha256:02aec4bd92ab067f6ff27a38a38a41173bf01bed8f89157768c1573f53e474a6",
@ -378,12 +401,27 @@
], ],
"version": "==1.0.1" "version": "==1.0.1"
}, },
"tox": {
"hashes": [
"sha256:96efa09710a3daeeb845561ebbe1497641d9cef2ee0aea30db6969058b2bda2f",
"sha256:9ee7de958a43806402a38c0d2aa07fa8553f4d2c20a15b140e9f771c2afeade0"
],
"index": "pypi",
"version": "==3.0.0"
},
"urllib3": { "urllib3": {
"hashes": [ "hashes": [
"sha256:06330f386d6e4b195fbfc736b297f58c5a892e4440e54d294d7004e3a9bbea1b", "sha256:06330f386d6e4b195fbfc736b297f58c5a892e4440e54d294d7004e3a9bbea1b",
"sha256:cc44da8e1145637334317feebd728bd869a35285b93cbb4cca2577da7e62db4f" "sha256:cc44da8e1145637334317feebd728bd869a35285b93cbb4cca2577da7e62db4f"
], ],
"version": "==1.22" "version": "==1.22"
},
"virtualenv": {
"hashes": [
"sha256:1d7e241b431e7afce47e77f8843a276f652699d1fa4f93b9d8ce0076fd7b0b54",
"sha256:e8e05d4714a1c51a2f5921e62f547fcb0f713ebbe959e0a7f585cc8bef71d11f"
],
"version": "==15.2.0"
} }
} }
} }

View File

@ -115,5 +115,6 @@ setup(
"mongo": ["motor"], "mongo": ["motor"],
"docs": ["sphinx>=1.7", "sphinxcontrib-asyncio", "sphinx_rtd_theme"], "docs": ["sphinx>=1.7", "sphinxcontrib-asyncio", "sphinx_rtd_theme"],
"voice": ["red-lavalink>=0.0.4"], "voice": ["red-lavalink>=0.0.4"],
"style": ["black"],
}, },
) )

37
tox.ini Normal file
View File

@ -0,0 +1,37 @@
# tox (https://tox.readthedocs.io/) is a tool for running tests
# in multiple virtualenvs. This configuration file will run the
# test suite on all supported python versions. To use it, "pip install tox"
# and then run "tox" from this directory.
[tox]
envlist =
py35
py36
docs
dev
[testenv]
description = Run unit tests with pytest
extras = voice, test, mongo
deps =
https://github.com/Rapptz/discord.py/archive/rewrite.zip#egg=discord.py[voice]
-rrequirements.txt
commands =
python -m compileall ./redbot/cogs
pytest
[testenv:docs]
description = Attempt to build docs with sphinx-build
whitelist_externals = sphinx-build
basepython = python3.6
extras = voice, docs, mongo
commands =
sphinx-build -d "{toxworkdir}/docs_doctree" docs "{toxworkdir}/docs_out" -W -bhtml
sphinx-build -d "{toxworkdir}/docs_doctree" docs "{toxworkdir}/docs_out" -W -blinkcheck
[testenv:style]
description = Stylecheck the code with black to see if anything needs changes.
basepython = python3.6
extras = style
commands =
black -l 99 --check generate_strings.py setup.py tests redbot