diff --git a/.github/workflows/publish-package.yml b/.github/workflows/publish-package.yml index 4045163..ab83a6a 100644 --- a/.github/workflows/publish-package.yml +++ b/.github/workflows/publish-package.yml @@ -8,35 +8,39 @@ on: jobs: - # tests: - # runs-on: ubuntu-latest - # strategy: - # matrix: - # python-version: [3.6, 3.7, 3.8] - # steps: - # - uses: actions/checkout@v2 - # - name: Set up Python ${{ matrix.python-version }} - # uses: actions/setup-python@v2 - # with: - # python-version: ${{ matrix.python-version }} - # - name: Install dependencies - # run: | - # python -m pip install --upgrade pip - # pip install flake8 pytest - # if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - # - name: Lint with flake8 - # run: | - # # stop the build if there are Python syntax errors or undefined names - # flake8 . --count --exit-zero --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=127 --statistics - # - name: Test with pytest - # run: | - # python setup.py pytest + tests: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.6, 3.7, 3.8] + + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + - name: Check code style with flake8 (lint) + run: | + # warnings if there are Python syntax errors or undefined names + # (remove --exit-zero to fail when syntax error) + flake8 . --count --exit-zero --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=127 --statistics + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install pytest + pip install . + + - name: Test with pytest + run: pytest publish: - # needs: [ tests ] + needs: [ tests ] runs-on: ubuntu-latest steps: diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml new file mode 100644 index 0000000..de28ec5 --- /dev/null +++ b/.github/workflows/run-tests.yml @@ -0,0 +1,44 @@ +name: Run tests +# Run test at each push to main, if changes to package or tests files +on: + workflow_dispatch: + push: + branches: [ main ] + paths: + - 'requirements.txt' + - 'app/**' + - 'tests/**' + - '.github/workflows/run-tests.yml' + +jobs: + + tests: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.6, 3.7, 3.8] + + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + - name: Check code style with flake8 (lint) + run: | + # warnings if there are Python syntax errors or undefined names + # (remove --exit-zero to fail when syntax error) + flake8 . --count --exit-zero --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=127 --statistics + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install pytest + pip install . + + - name: Test with pytest + run: pytest + diff --git a/tests/test_init.py b/tests/test_init.py new file mode 100644 index 0000000..bb509f9 --- /dev/null +++ b/tests/test_init.py @@ -0,0 +1,13 @@ +import pytest +from app.init import boot +from argostranslate import package + +def test_boot_argos(): + """Test Argos translate models initialization""" + boot() + + print(package.get_installed_packages()) + assert len(package.get_installed_packages()) > 2 + # Check length models? + # assert 0.80 < scores['precision'] < 0.95 +