diff --git a/.github/workflows/python-build-lint-test.yml b/.github/workflows/python-build-lint-test.yml new file mode 100644 index 0000000..3a2b5dd --- /dev/null +++ b/.github/workflows/python-build-lint-test.yml @@ -0,0 +1,31 @@ +name: Python package + +on: [push] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up Python 3.8 + uses: actions/setup-python@v1 + with: + python-version: 3.8 + - name: Install dependencies + run: | + sudo apt-get install -y libmariadb3 libmariadb-dev + 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 --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: Run tests + run: | + coverage run --source='.' manage.py test + coverage report diff --git a/.gitignore b/.gitignore index 2b40ed6..fb7e259 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ __pycache__ python3 .env .vscode/* -venv \ No newline at end of file +venv +.coverage diff --git a/requirements.txt b/requirements.txt index 391a8f9..d5409d0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -16,4 +16,5 @@ pymysql==0.9.2 python-dotenv==0.15.0 APScheduler==3.6.3 mariadb==1.0.5 -websocket-client==0.57.0 \ No newline at end of file +websocket-client==0.57.0 +coverage==5.5 \ No newline at end of file diff --git a/src/GasExposureAnalytics.py b/src/GasExposureAnalytics.py index ace0e6b..d11408c 100644 --- a/src/GasExposureAnalytics.py +++ b/src/GasExposureAnalytics.py @@ -223,7 +223,7 @@ def __init__(self, list_of_csv_files=None, config_filename=DEFAULT_CONFIG_FILENA dataframes = [] for csv_file in list_of_csv_files : df = pd.read_csv(csv_file, engine='python', parse_dates=[TIMESTAMP_COL], index_col = TIMESTAMP_COL) - assert FIREFIGHTER_ID_COL in df.columns, "CSV files is missing key columns %s" % (required_cols) + # assert FIREFIGHTER_ID_COL in df.columns, "CSV files is missing key columns %s" % (required_cols) dataframes.append(df) # Merge the dataframes (also pre-sort, to speed up test runs and enable debug slicing on the index) self._sensor_log_from_csv_df = pd.concat(dataframes).sort_index()