diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..3d1d83f2b --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,83 @@ +name: CI + +on: + push: + branches: ["master"] + pull_request: + branches: ["master"] + workflow_dispatch: # to allow manual re-runs + + +jobs: + linting: + name: "Perform linting checks" + runs-on: ubuntu-latest + + strategy: + matrix: + python-version: ["3.9"] + + steps: + - uses: "actions/checkout@v2" + - uses: "actions/setup-python@v2" + with: + python-version: "${{ matrix.python-version }}" + - name: "Install dependencies" + run: | + python -m pip install --upgrade pip poetry + poetry install --extras docs + - name: "Code formating (black)" + run: | + poetry run pre-commit run black --all-files + - name: "Code formating (flake8)" + run: | + poetry run pre-commit run flake8 --all-files + - name: "Order of imports (isort)" + run: | + poetry run pre-commit run isort --all-files + - name: "Docstring formating (docformatter)" + run: | + poetry run pre-commit run docformatter --all-files + - name: "Potential security issues (bandit)" + run: | + poetry run pre-commit run bandit --all-files + - name: "Documentation build (sphinx)" + run: | + poetry run sphinx-build docs/ generated_docs + # - name: "Typing checks (mypy)" + # run: | + # poetry run pre-commit run mypy --all-files + + tests: + name: "Python ${{ matrix.python-version}} on ${{ matrix.os }}" + needs: linting + runs-on: ${{ matrix.os }} + + strategy: + matrix: + python-version: ["3.6", "3.7", "3.8", "3.9", "pypy3"] + os: [ubuntu-latest, macos-latest, windows-latest] + # test pypy3 only on ubuntu as cryptography requires rust compilation + # which slows the pipeline and was not currently working on macos + exclude: + - python-version: pypy3 + os: macos-latest + - python-version: pypy3 + os: windows-latest + + steps: + - uses: "actions/checkout@v2" + - uses: "actions/setup-python@v2" + with: + python-version: "${{ matrix.python-version }}" + - name: "Install dependencies" + run: | + python -m pip install --upgrade pip poetry + poetry install --extras docs + - name: "Run tests" + run: | + poetry run pytest --cov miio --cov-report xml + - name: "Upload coverage to Codecov" + uses: "codecov/codecov-action@v1" + with: + fail_ci_if_error: true diff --git a/README.rst b/README.rst index 6a49820b3..169ff721f 100644 --- a/README.rst +++ b/README.rst @@ -180,10 +180,10 @@ Other projects :target: https://badge.fury.io/py/python-miio .. |PyPI downloads| image:: https://img.shields.io/pypi/dw/python-miio :target: https://pypi.org/project/python-miio/ -.. |Build Status| image:: https://img.shields.io/azure-devops/build/python-miio/608e6099-f1ed-403c-9158-8fdcb2a0e477/1 - :target: https://dev.azure.com/python-miio/python-miio/ -.. |Coverage Status| image:: https://coveralls.io/repos/github/rytilahti/python-miio/badge.svg?branch=master - :target: https://coveralls.io/github/rytilahti/python-miio?branch=master +.. |Build Status| image:: https://github.com/rytilahti/python-miio/actions/workflows/ci.yml/badge.svg + :target: https://github.com/rytilahti/python-miio/actions/workflows/ci.yml +.. |Coverage Status| image:: https://codecov.io/gh/rytilahti/python-miio/branch/master/graph/badge.svg?token=lYKWubxkLU + :target: https://codecov.io/gh/rytilahti/python-miio .. |Docs| image:: https://readthedocs.org/projects/python-miio/badge/?version=latest :alt: Documentation status :target: https://python-miio.readthedocs.io/en/latest/?badge=latest diff --git a/azure-pipelines.yml b/azure-pipelines.yml deleted file mode 100644 index e4eb0d8f3..000000000 --- a/azure-pipelines.yml +++ /dev/null @@ -1,130 +0,0 @@ -trigger: -- master -pr: -- master - - -stages: -- stage: "Linting" - jobs: - - job: "LintChecks" - pool: - vmImage: "ubuntu-latest" - strategy: - matrix: - Python 3.8: - python.version: '3.8' - steps: - - task: UsePythonVersion@0 - inputs: - versionSpec: '$(python.version)' - displayName: 'Use Python $(python.version)' - - - script: | - python -m pip install --upgrade pip poetry - poetry install --extras docs - displayName: 'Install dependencies' - - - script: | - poetry run pre-commit run black --all-files - displayName: 'Code formating (black)' - - - script: | - poetry run pre-commit run flake8 --all-files - displayName: 'Code formating (flake8)' - - #- script: | - # pre-commit run mypy --all-files - # displayName: 'Typing checks (mypy)' - - - script: | - poetry run pre-commit run isort --all-files - displayName: 'Order of imports (isort)' - - - script: | - poetry run pre-commit run docformatter --all-files - displayName: 'Docstring formating (docformatter)' - - - script: | - poetry run pre-commit run bandit --all-files - displayName: 'Potential security issues (bandit)' - - - script: | - poetry run sphinx-build docs/ generated_docs - displayName: 'Documentation build (sphinx)' - - -- stage: "Tests" - jobs: - - job: "Tests" - strategy: - matrix: - Python 3.6 Ubuntu: - python.version: '3.6' - vmImage: 'ubuntu-latest' - - Python 3.7 Ubuntu: - python.version: '3.7' - vmImage: 'ubuntu-latest' - - Python 3.8 Ubuntu: - python.version: '3.8' - vmImage: 'ubuntu-latest' - - Python 3.9 Ubuntu: - python.version: '3.9' - vmImage: 'ubuntu-latest' - - PyPy Ubuntu: - python.version: pypy3 - vmImage: 'ubuntu-latest' - - Python 3.6 Windows: - python.version: '3.6' - vmImage: 'windows-latest' - - Python 3.7 Windows: - python.version: '3.7' - vmImage: 'windows-latest' - - Python 3.8 Windows: - python.version: '3.8' - vmImage: 'windows-latest' - - Python 3.9 Windows: - python.version: '3.9' - vmImage: 'windows-latest' - - Python 3.6 OSX: - python.version: '3.6' - vmImage: 'macOS-latest' - - Python 3.7 OSX: - python.version: '3.7' - vmImage: 'macOS-latest' - - Python 3.8 OSX: - python.version: '3.8' - vmImage: 'macOS-latest' - - Python 3.9 OSX: - python.version: '3.9' - vmImage: 'macOS-latest' - - pool: - vmImage: $(vmImage) - - steps: - - task: UsePythonVersion@0 - inputs: - versionSpec: '$(python.version)' - displayName: 'Use Python $(python.version)' - - - script: | - python -m pip install --upgrade pip poetry - poetry install - displayName: 'Install dependencies' - - - script: | - poetry run pytest --cov miio --cov-report html - displayName: 'Tests'