diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml new file mode 100644 index 0000000..d81f85c --- /dev/null +++ b/.github/workflows/python-package.yml @@ -0,0 +1,69 @@ +# This workflow will install Python dependencies, run tests and lint +# across operating systems, select versions of Python, and user + dev environments +# For more info see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions + +name: Python install test + +on: + push: + branches: [master, develop] + pull_request: + branches: [master, develop] + workflow_dispatch: # also allow manual trigger, for testing purposes + +jobs: + test_install: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: # max 256 jobs per workflow + os: [ubuntu-latest, windows-latest, macos-latest] + py-version: [3.8, 3.9] + build-type: [user, dev] + + steps: + - uses: actions/checkout@v2 + # general Python setup + - name: Set up Python ${{ matrix.py-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.py-version }} + - name: Update pip & install testing pkgs + run: | + python -VV + python -m pip install --upgrade pip setuptools wheel + pip install pytest pytest-cov flake8 + # developer environment, install specific packages from requirements.txt + - name: Install dev dependencies (non-Windows) + if: matrix.build-type == 'dev' && matrix.os != 'windows-latest' + run: | + pip install -r requirements.txt + pip install . + - name: Install dev dependencies (Windows) + if: matrix.build-type == 'dev' && matrix.os == 'windows-latest' + run: | + pip install -r requirements.txt -r impactworld_requirements.txt + pip install . + # user environment install latest from setup.py + - name: Install user dependencies (non-Windows) + if: matrix.build-type == 'user' && matrix.os != 'windows-latest' + run: pip install . + - name: Install user dependencies (Windows) + if: matrix.build-type == 'user' && matrix.os == 'windows-latest' + run: pip install .[ImpactWorld] + # MS Access install (for Windows) needed for IW+ + - name: Choco install msaccess2010 + if: matrix.os == 'windows-latest' + uses: crazy-max/ghaction-chocolatey@v1 + with: + args: install msaccess2010-redist + # linting with flake8 + - name: Lint with flake8 + run: | + # 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=127 --statistics + # initiate tests with pytest + - name: Test with pytest + run: pytest diff --git a/README.md b/README.md index 96df2d9..c2f3d5d 100644 --- a/README.md +++ b/README.md @@ -12,14 +12,15 @@ source, cleans the data, shapes them into a standard format using the [LCIAmetho |ImpactWorld+ Midpoint*|International Reference Center for Life Cycle of Products, Services and Systems (CIRAIG)|[ImpactWorld+](http://www.impactworldplus.org/en/team.php)| |ImpactWorld+ Endpoint*|International Reference Center for Life Cycle of Products, Services and Systems (CIRAIG)|[ImpactWorld+](http://www.impactworldplus.org/en/team.php)| |FEDEFL Inventory Methods|US Environmental Protection Agency|[FEDEFL Inventory Methods](https://github.com/USEPA/LCIAformatter/wiki/Inventory-Methods)| -* only works on Windows installations + +\* only works on Windows installations ## Installation Instructions Install a release directly from github using pip. From a command line interface, run: -> pip install git+https://github.com/USEPA/LCIAformatter.git@v1.0.0#egg=lciafmt +> pip install git+https://github.com/USEPA/LCIAformatter.git@v1.0.1#egg=lciafmt -where you can replace 'v1.0.0' with the version you wish to use under [Releases](https://github.com/USEPA/LCIAformatter/releases). +where you can replace 'v1.0.1' with the version you wish to use under [Releases](https://github.com/USEPA/LCIAformatter/releases). Alternatively, to install from the most current point on the repository: ``` diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..1dfb8c3 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,9 @@ +[pytest] +log_cli = True +log_cli_level = DEBUG +log_file = tests.log +log_file_level = DEBUG +norecursedirs=dist build +addopts = --cov=lciafmt --cov-report=term-missing +testpaths = + tests diff --git a/requirements_test.txt b/requirements_test.txt new file mode 100644 index 0000000..f604537 --- /dev/null +++ b/requirements_test.txt @@ -0,0 +1,3 @@ +pytest +pytest-cov +flake8 diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_pyodbc.py b/tests/test_pyodbc.py new file mode 100644 index 0000000..d766b48 --- /dev/null +++ b/tests/test_pyodbc.py @@ -0,0 +1,25 @@ +"""Test for the presence of pyodbc + MS Access driver.""" + +import logging +import sys + +import pytest + +logger = logging.getLogger(__name__) + + +@pytest.mark.skipif(sys.platform != "win32", reason="PYDOBC only on windows") +def test_find_pyodbc_driver(): + """In wind32 platform, pyodbc must be installed, with MS Access drivers.""" + try: + import pyodbc # pylint: disable=C0415 + except ImportError: + logger.error( + """Must install pyodbc for ImpactWorld.""" + """See install instructions for optional package""" + """installation or install it indepedently and retry.""" + ) + driver_check = list(pyodbc.drivers()) + driver_found = any("Microsoft Access Driver" in word for word in driver_check) + logger.debug("Found pyodbc drivers: %s", driver_check) + assert driver_found is True