Skip to content

Commit

Permalink
Migration: use tox to run unit tests and linting (#650)
Browse files Browse the repository at this point in the history
  • Loading branch information
jayaddison committed Oct 20, 2022
1 parent 93de8af commit 9b50f53
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 24 deletions.
1 change: 1 addition & 0 deletions .flake8
Expand Up @@ -6,5 +6,6 @@ max-line-length = 88
max-complexity = 18
select = B,C,E,F,W,T4,B9
exclude =
./.tox/
./.venv/
./venv/
11 changes: 2 additions & 9 deletions .github/workflows/linters.yaml
Expand Up @@ -17,12 +17,5 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
- name: black and flake checks
run: |
black --check .
flake8 --count .
mypy recipe_scrapers tests
- run: pip install tox
- run: tox -e lint
19 changes: 6 additions & 13 deletions .github/workflows/unittests.yaml
Expand Up @@ -23,26 +23,19 @@ jobs:
python-version: "3.11.0-rc.1"
- os: windows-latest
python-version: "3.11.0-rc.1"
include:
- toxenv: py
- os: macos-latest
toxenv: py-darwin
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
# The system-provided libxml2 on MacOS is typically outdated and this can lead to lxml parsing issues
# Using PyPi-provided binary wheels instead resolves this
# We are affected by https://bugs.launchpad.net/lxml/+bug/1949271 in test_wild_mode when using system-provided libxml2 on MacOS
- name: Install lxml from wheel on MacOS
if: ${{ matrix.os == 'macos-latest' }}
run: pip install --only-binary=lxml lxml
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
- name: Unittest and Coverage Report
run: |
python run_tests.py
- run: pip install tox
- run: tox -e ${{ matrix.toxenv }}
# Provide code coverage reports on Linux
- if: ${{ matrix.os == 'ubuntu-latest' }}
name: coveralls.io
Expand Down
2 changes: 0 additions & 2 deletions setup.py
Expand Up @@ -29,8 +29,6 @@
"extruct>=0.8.0",
"isodate>=0.6.1",
"requests>=2.19.1",
"types-beautifulsoup4>=4.11.6",
"types-requests>=2.28.10",
],
packages=find_packages(),
package_data={"": ["LICENSE", "py.typed"]},
Expand Down
29 changes: 29 additions & 0 deletions tox.ini
@@ -0,0 +1,29 @@
[testenv]
deps =
coverage >= 4.5.1
responses >= 0.21.0
unittest-parallel >= 1.5.0
commands =
unittest-parallel -t . -s tests --coverage --coverage-rcfile .coveragerc

# The system-provided libxml2 on MacOS is typically outdated and this can lead to lxml parsing issues
# Using PyPi-provided binary wheels instead resolves this
# We are affected by https://bugs.launchpad.net/lxml/+bug/1949271 in test_wild_mode when using system-provided libxml2 on MacOS
platform =
py-darwin: darwin
install_command =
py-darwin: python -m pip install --only-binary=lxml {opts} {packages}

[testenv:lint]
skip_install = true
deps =
black >= 22.3.0
flake8 >= 3.8.3
flake8-printf-formatting >= 1.1.0
mypy >= 0.971
types-beautifulsoup4 >= 4.11.6
types-requests >= 2.28.10
commands =
black --check .
flake8 --count .
mypy recipe_scrapers tests

0 comments on commit 9b50f53

Please sign in to comment.