Skip to content

Commit

Permalink
Merge pull request #76 from USEPA/develop
Browse files Browse the repository at this point in the history
adding install testing via github actions for v1.0.1 release
  • Loading branch information
bl-young authored Oct 7, 2021
2 parents 64a3179 + 97452b8 commit f2a899f
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 3 deletions.
69 changes: 69 additions & 0 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
@@ -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
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
```
Expand Down
9 changes: 9 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions requirements_test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pytest
pytest-cov
flake8
Empty file added tests/__init__.py
Empty file.
25 changes: 25 additions & 0 deletions tests/test_pyodbc.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit f2a899f

Please sign in to comment.