Repository: castorini/howl (language: python)

Issue:
Setting up CI and implement testing



Discussion / hints:

Fix patch:
diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml
index 1a03a7b6..b1bffa4f 100644
--- a/.github/workflows/python-publish.yml
+++ b/.github/workflows/python-publish.yml
@@ -1,14 +1,12 @@
 # This workflow will upload a Python Package using Twine when a release is created
 # For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
 
-name: Upload Python Package
+name: Python Package
 
-on:
-  release:
-    types: [created]
+on: [push]
 
 jobs:
-  deploy:
+  test:
 
     runs-on: ubuntu-latest
 
@@ -17,15 +15,22 @@ jobs:
     - name: Set up Python
       uses: actions/setup-python@v2
       with:
-        python-version: '3.x'
+        python-version: '3.7.7'
     - name: Install dependencies
       run: |
         python -m pip install --upgrade pip
-        pip install setuptools wheel twine
-    - name: Build and publish
-      env:
-        TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
-        TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
+        pip install setuptools wheel
+        sudo apt-get install libasound-dev portaudio19-dev libportaudio2 libportaudiocpp0 libpulse-dev
+        pip install -r requirements.txt
+        pip install -r requirements_training.txt
+    - name: Lint with flake8
       run: |
-        python setup.py sdist bdist_wheel
-        twine upload dist/*
+        pip install flake8
+        # stop the build if there are Python syntax errors or undefined names
+        flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
+        # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
+        flake8 . --count --exit-zero --max-complexity=10 --max-line-length=120 --statistics
+    - name: Test with pytest
+      run: |
+        pip install --quiet --editable .
+        pytest --verbose
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
new file mode 100644
index 00000000..289589b6
--- /dev/null
+++ b/.pre-commit-config.yaml
@@ -0,0 +1,34 @@
+exclude: |
+    (?x)(
+        ^data/ |
+        ^howl-models
+    )
+
+repos:
+-   repo: https://github.com/pre-commit/pre-commit-hooks
+    rev: v3.3.0
+    hooks:
+    -   id: check-yaml
+    -   id: requirements-txt-fixer
+    -   id: end-of-file-fixer
+    -   id: trailing-whitespace
+    -   id: check-json
+    -   id: name-tests-test
+-   repo: https://github.com/timothycrosley/isort
+    rev: 5.2.0
+    hooks:
+    -   id: isort
+-   repo: https://github.com/psf/black
+    rev: 19.10b0
+    hooks:
+    -   id: black
+        args: [--line-length=120]
+-   repo: https://gitlab.com/pycqa/flake8
+    rev: 3.8.3
+    hooks:
+    -   id: flake8
+-   repo: https://github.com/pre-commit/mirrors-pylint
+    rev: v2.6.0
+    hooks:
+    -   id: pylint
+        files: src
diff --git a/requirements_training.txt b/requirements_training.txt
index 5e814b84..b79ce2e3 100644
--- a/requirements_training.txt
+++ b/requirements_training.txt
@@ -1,3 +1,5 @@
 openpyxl
 praat-textgrids==1.3.1
 webrtcvad==2.0.10
+pytest
+pre-commit


Test patch:
diff --git a/test/data/dataset.py b/test/data/dataset_test.py
similarity index 99%
rename from test/data/dataset.py
rename to test/data/dataset_test.py
index 2c496582..5ef54061 100644
--- a/test/data/dataset.py
+++ b/test/data/dataset_test.py
@@ -10,6 +10,7 @@
 
 class TestDataset(AudioDataset[AudioClipMetadata]):
     """Sample dataset for testing"""
+    __test__ = False
 
     def __init__(self,
                  **kwargs):
diff --git a/test/data/stitcher.py b/test/data/stitcher_test.py
similarity index 100%
rename from test/data/stitcher.py
rename to test/data/stitcher_test.py
diff --git a/test/data/tokenize.py b/test/data/tokenize_test.py
similarity index 100%
rename from test/data/tokenize.py
rename to test/data/tokenize_test.py
diff --git a/test/model/inference.py b/test/model/inference_test.py
similarity index 97%
rename from test/model/inference.py
rename to test/model/inference_test.py
index 531b7859..c513eb22 100644
--- a/test/model/inference.py
+++ b/test/model/inference_test.py
@@ -1,7 +1,7 @@
 import unittest
 
 from howl.data.tokenize import Vocab
-from howl.model.inference import WordTranscriptSearcher
+from howl.data.searcher import WordTranscriptSearcher
 from howl.settings import SETTINGS
 
 
diff --git a/test/test_data/.gitignore b/test/test_data/.gitignore
new file mode 100644
index 00000000..d40b5a73
--- /dev/null
+++ b/test/test_data/.gitignore
@@ -0,0 +1,1 @@
+stitched_dataset