Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Tox for tests #94

Merged
merged 4 commits into from
Dec 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
name: Publish
name: Upload Python Package

on:
release:
types: [created]
types: [published]

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Check out repository
uses: actions/checkout@v3.2.0

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Test with pytest
run: |
pip install pytest
python setup.py test

- name: Build and publish
env:
TWINE_USERNAME: __token__
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ jobs:
pull-requests: write

steps:
- uses: actions/stale@v6
- name: Stale
uses: actions/stale@v6
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: 'Stale issue message'
stale-pr-message: 'Stale pull request message'
stale-issue-label: 'no-issue-activity'
stale-pr-label: 'no-pr-activity'
stale-pr-label: 'no-pr-activity'
45 changes: 18 additions & 27 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,45 +1,36 @@
name: Python package
name: Test

on:
push:
branches:
- master
pull_request: ~
branches: [master]
pull_request:
branches: [master]

jobs:
build:

runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
python-version: ["3.9", "3.10", "3.11"]
python-version:
- "3.9"
- "3.10"
- "3.11"

steps:
- uses: actions/checkout@v3
- name: Check out repository
uses: actions/checkout@v3.2.0
with:
fetch-depth: 2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt -r requirements-test.txt
- name: Check with isort
run: |
pre-commit run --hook-stage manual isort --all-files --show-diff-on-failure
- name: Check with Black Code Formatter
run: |
black gios tests --check
- name: Lint with flake8
run: |
flake8 gios tests
- name: Lint with pylint
run: |
pylint gios tests
- name: Test with mypy
run: |
mypy gios
- name: Test with pytest
run: |
python setup.py test
pip install tox tox-gh-actions

- name: Test with tox
run: tox
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright 2021 Maciej Bieniek
Copyright 2022 Maciej Bieniek

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
6 changes: 6 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-r requirements.txt
-r requirements-test.txt
pre-commit==2.20.0
setuptools>=65.5.1 # not directly required, pinned by Snyk to avoid a vulnerability

-e .
7 changes: 4 additions & 3 deletions requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
aioresponses==0.7.4
black==22.12.0
coverage==7.0.0
flake8==6.0.0
isort==5.11.3
mypy==0.991
pre-commit==2.20.0
pylint==2.15.9
pydocstyle==6.1.1
pylint_strict_informational==0.1
pylint==2.15.9
pytest-asyncio==0.20.3
pytest-cov==4.0.0
pytest-error-for-skips==2.0.2
pytest-timeout==2.1.0
pytest==7.2.0
setuptools>=65.5.1 # not directly required, pinned by Snyk to avoid a vulnerability
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
aiohttp>=3.7.0
dacite==1.6.0
dacite
9 changes: 3 additions & 6 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
[aliases]
test=pytest

[tool:pytest]
addopts = --cov --cov-report term-missing --strict-markers --error-for-skips

[flake8]
# To work with Black
max-line-length = 88
Expand Down Expand Up @@ -41,3 +35,6 @@ strict_equality = true
warn_return_any = true
warn_unused_ignores = true
warn_unreachable = true

[tool:pytest]
asyncio_mode = strict
26 changes: 11 additions & 15 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,41 +1,37 @@
#!/usr/bin/env python3
"""Setup module for gios."""
from pathlib import Path
from setuptools import setup

with open("README.md", encoding="utf-8") as file:
long_description = file.read()

with open("requirements.txt", encoding="utf-8") as file:
install_requires = list(val.strip() for val in file.readlines())

with open("requirements-test.txt", encoding="utf-8") as file:
tests_require = list(val.strip() for val in file.readlines())
PROJECT_DIR = Path(__file__).parent.resolve()
README_FILE = PROJECT_DIR / "README.md"
VERSION = "2.3.0"

setup(
name="gios",
version="2.2.0",
version=VERSION,
author="Maciej Bieniek",
description="Python wrapper for getting air quality data from GIOŚ servers.",
long_description=long_description,
long_description=README_FILE.read_text(encoding="utf-8"),
long_description_content_type="text/markdown",
include_package_data=True,
url="https://github.com/bieniu/gios",
license="Apache-2.0 License",
packages=["gios"],
package_data={"gios": ["py.typed"]},
python_requires=">=3.9",
install_requires=install_requires,
install_requires=list(
val.strip() for val in open("requirements.txt", encoding="utf-8")
),
classifiers=[
"Development Status :: 5 - Production/Stable",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3 :: Only",
"Typing :: Typed",
],
setup_requires=("pytest-runner"),
tests_require=tests_require,
)
45 changes: 45 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
[tox]
envlist = py39, py310, py311, lint, typing, coverage
skip_missing_interpreters = True

[gh-actions]
python =
3.9: py39, lint, typing, coverage
3.10: py310
3.11: py311

[testenv]
commands =
pytest --timeout=30 --cov=gios --cov-report=xml {posargs} --error-for-skips
deps =
-rrequirements.txt
-rrequirements-test.txt

[testenv:lint]
basepython = python3
ignore_errors = True
commands =
black --check ./
flake8 gios tests
isort gios tests
pylint gios tests
pydocstyle gios tests
deps =
-rrequirements.txt
-rrequirements-test.txt

[testenv:typing]
basepython = python3
ignore_errors = True
commands =
mypy gios
deps =
-rrequirements.txt
-rrequirements-test.txt

[testenv:coverage]
deps =
-rrequirements.txt
-rrequirements-test.txt
commands =
coverage report --fail-under=79