From d4b227dfad818079675f2eaf12d00531fdc236aa Mon Sep 17 00:00:00 2001 From: Teemu Rytilahti Date: Thu, 23 Sep 2021 17:48:42 +0200 Subject: [PATCH 1/2] Use github actions instead of azure pipelines --- .github/workflows/ci.yml | 84 ++++++++++++++++++++++++++++ README.md | 2 +- azure-pipelines.yml | 118 --------------------------------------- 3 files changed, 85 insertions(+), 119 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 azure-pipelines.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..0452fc340 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,84 @@ +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 + - 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: "Typing checks (mypy)" + run: | + poetry run pre-commit run mypy --all-files + - name: "Run trailing-whitespace" + run: | + poetry run pre-commit run trailing-whitespace --all-files + - name: "Run end-of-file-fixer" + run: | + poetry run pre-commit run end-of-file-fixer --all-files + - name: "Run check-docstring-first" + run: | + poetry run pre-commit run check-docstring-first --all-files + - name: "Run debug-statements" + run: | + poetry run pre-commit run debug-statements --all-files + - name: "Run check-ast" + run: | + poetry run pre-commit run check-ast --all-files + - name: "Potential security issues (bandit)" + run: | + poetry run pre-commit run bandit --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] + + 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 + - name: "Run tests" + run: | + poetry run pytest --cov kasa --cov-report xml + - name: "Upload coverage to Codecov" + uses: "codecov/codecov-action@v1" + with: + fail_ci_if_error: true diff --git a/README.md b/README.md index f8aa82507..1241719bd 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # python-kasa [![PyPI version](https://badge.fury.io/py/python-kasa.svg)](https://badge.fury.io/py/python-kasa) -[![Build Status](https://dev.azure.com/python-kasa/python-kasa/_apis/build/status/python-kasa.python-kasa?branchName=master)](https://dev.azure.com/python-kasa/python-kasa/_build/latest?definitionId=2&branchName=master) +[![Build Status](https://github.com/python-kasa/python-kasa/actions/workflows/ci.yml/badge.svg)](https://github.com/python-kasa/python-kasa/actions/workflows/ci.yml) [![Coverage Status](https://coveralls.io/repos/github/python-kasa/python-kasa/badge.svg?branch=master)](https://coveralls.io/github/python-kasa/python-kasa?branch=master) [![Documentation Status](https://readthedocs.org/projects/python-kasa/badge/?version=latest)](https://python-kasa.readthedocs.io/en/latest/?badge=latest) diff --git a/azure-pipelines.yml b/azure-pipelines.yml deleted file mode 100644 index 2b201ae08..000000000 --- a/azure-pipelines.yml +++ /dev/null @@ -1,118 +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 - 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: | - poetry run 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 trailing-whitespace --all-files - displayName: 'Run trailing-whitespace' - - - script: | - poetry run pre-commit run end-of-file-fixer --all-files - displayName: 'Run end-of-file-fixer' - - - script: | - poetry run pre-commit run check-docstring-first --all-files - displayName: 'Run check-docstring-first' - - - script: | - poetry run pre-commit run check-yaml --all-files - displayName: 'Run check-yaml' - - - script: | - poetry run pre-commit run debug-statements --all-files - displayName: 'Run debug-statements' - - - script: | - poetry run pre-commit run check-ast --all-files - displayName: 'Run check-ast' - - -- stage: "Tests" - jobs: - - job: "Tests" - strategy: - matrix: - Python 3.7 Ubuntu: - python.version: '3.7' - vmImage: 'ubuntu-latest' - - Python 3.8 Ubuntu: - python.version: '3.8' - vmImage: 'ubuntu-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.7 OSX: - python.version: '3.7' - vmImage: 'macOS-latest' - - Python 3.8 OSX: - python.version: '3.8' - 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 kasa --cov-report=xml --cov-report=html - displayName: 'Run tests' - - - script: | - poetry run codecov -t $(codecov.token) - displayName: 'Report code coverage' From 40df50bf48c405bbbd93a1cfda925b10a9ba548e Mon Sep 17 00:00:00 2001 From: Teemu Rytilahti Date: Thu, 23 Sep 2021 18:24:41 +0200 Subject: [PATCH 2/2] add codecov badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1241719bd..e5b00b7ee 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![PyPI version](https://badge.fury.io/py/python-kasa.svg)](https://badge.fury.io/py/python-kasa) [![Build Status](https://github.com/python-kasa/python-kasa/actions/workflows/ci.yml/badge.svg)](https://github.com/python-kasa/python-kasa/actions/workflows/ci.yml) -[![Coverage Status](https://coveralls.io/repos/github/python-kasa/python-kasa/badge.svg?branch=master)](https://coveralls.io/github/python-kasa/python-kasa?branch=master) +[![codecov](https://codecov.io/gh/python-kasa/python-kasa/branch/master/graph/badge.svg?token=5K7rtN5OmS)](https://codecov.io/gh/python-kasa/python-kasa) [![Documentation Status](https://readthedocs.org/projects/python-kasa/badge/?version=latest)](https://python-kasa.readthedocs.io/en/latest/?badge=latest) python-kasa is a Python library to control TPLink smart home devices (plugs, wall switches, power strips, and bulbs) using asyncio.