forked from pytorch/audio
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Setup Travis CI so that unit tests are run automatically (pytorch#117)
- Loading branch information
Showing
12 changed files
with
185 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,30 @@ | ||
language: python | ||
# note dist: 'trusty' does not work here | ||
dist: xenial | ||
|
||
language: python | ||
|
||
# cache miniconda installer and similar files | ||
cache: | ||
directories: | ||
- /home/travis/download | ||
|
||
# This matrix tests that the code works on Python 3.5, 3.6, and passes lint. | ||
matrix: | ||
fast_finish: true | ||
include: | ||
- python: "3.5" | ||
- env: PYTHON_VERSION="3.5" | ||
- env: PYTHON_VERSION="3.6" | ||
- env: PYTHON_VERSION="3.5" RUN_FLAKE8="true" SKIP_TESTS="true" | ||
|
||
addons: | ||
apt: | ||
packages: | ||
sox | ||
libsox-dev | ||
libsox-fmt-all | ||
libpython3.5-dev | ||
install: | ||
- pip install torch | ||
- python setup.py install | ||
script: | ||
- python -m unittest | ||
apt: | ||
packages: | ||
sox | ||
libsox-dev | ||
libsox-fmt-all | ||
|
||
notifications: | ||
email: false | ||
|
||
install: source build_tools/travis/install.sh | ||
script: bash build_tools/travis/test_script.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/bin/bash | ||
# This script is meant to be called by the "install" step defined in | ||
# .travis.yml. See http://docs.travis-ci.com/ for more details. | ||
# The behavior of the script is controlled by environment variabled defined | ||
# in the .travis.yml in the top level folder of the project. | ||
|
||
set -e | ||
|
||
echo 'List files from cached directories' | ||
if [ -d $HOME/download ]; then | ||
echo 'download:' | ||
ls $HOME/download | ||
fi | ||
if [ -d $HOME/.cache/pip ]; then | ||
echo 'pip:' | ||
ls $HOME/.cache/pip | ||
fi | ||
|
||
# Deactivate the travis-provided virtual environment and setup a | ||
# conda-based environment instead | ||
deactivate | ||
|
||
# Add the miniconda bin directory to $PATH | ||
export PATH=/home/travis/miniconda3/bin:$PATH | ||
echo $PATH | ||
|
||
# Use the miniconda installer for setup of conda itself | ||
pushd . | ||
cd | ||
mkdir -p download | ||
cd download | ||
if [[ ! -f /home/travis/miniconda3/bin/activate ]] | ||
then | ||
if [[ ! -f miniconda.sh ]] | ||
then | ||
wget http://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh \ | ||
-O miniconda.sh | ||
fi | ||
chmod +x miniconda.sh && ./miniconda.sh -b -f | ||
conda update --yes conda | ||
echo "Creating environment to run tests in." | ||
conda create -n testenv --yes python="$PYTHON_VERSION" | ||
fi | ||
cd .. | ||
popd | ||
|
||
# Activate the python environment we created. | ||
source activate testenv | ||
|
||
# Install requirements via pip in our conda environment | ||
pip install -r requirements.txt | ||
|
||
# Install the following only if running tests | ||
if [[ "$SKIP_TESTS" != "true" ]]; then | ||
# PyTorch | ||
conda install --yes pytorch -c pytorch | ||
|
||
# TorchAudio CPP Extensions | ||
pip install . | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/bin/bash | ||
# This script is meant to be called by the "script" step defined in | ||
# .travis.yml. See http://docs.travis-ci.com/ for more details. | ||
# The behavior of the script is controlled by environment variabled defined | ||
# in the .travis.yml in the top level folder of the project. | ||
set -e | ||
|
||
python --version | ||
|
||
run_tests() { | ||
# find all the test files that match "test*.py" | ||
TEST_FILES="$(find test/ -type f -name "test*.py" | sort)" | ||
echo "Test files are:" | ||
echo $TEST_FILES | ||
|
||
echo "Executing tests:" | ||
EXIT_STATUS=0 | ||
for FILE in $TEST_FILES; do | ||
# run each file on a separate process. if one fails, just keep going and | ||
# return the final exit status. | ||
python -m unittest -v $FILE | ||
STATUS=$? | ||
EXIT_STATUS="$(($EXIT_STATUS+STATUS))" | ||
done | ||
|
||
echo "Done, exit status: $EXIT_STATUS" | ||
exit $EXIT_STATUS | ||
} | ||
|
||
if [[ "$RUN_FLAKE8" == "true" ]]; then | ||
flake8 | ||
fi | ||
|
||
if [[ "$SKIP_TESTS" != "true" ]]; then | ||
run_tests | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Optional for torchaudio.kaldi_io | ||
numpy | ||
kaldi_io | ||
|
||
# Required for tests only: | ||
|
||
# Style-checking for PEP8 | ||
flake8 | ||
|
||
# Used for comparison of outputs in tests | ||
librosa | ||
scipy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import os | ||
from shutil import copytree | ||
import tempfile | ||
|
||
|
||
TEST_DIR_PATH = os.path.dirname(os.path.realpath(__file__)) | ||
|
||
|
||
def create_temp_assets_dir(): | ||
""" | ||
Creates a temporary directory and moves all files from test/assets there. | ||
Returns a Tuple[string, TemporaryDirectory] which is the folder path | ||
and object. | ||
""" | ||
tmp_dir = tempfile.TemporaryDirectory() | ||
copytree(os.path.join(TEST_DIR_PATH, "assets"), | ||
os.path.join(tmp_dir.name, "assets")) | ||
return tmp_dir.name, tmp_dir |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters