timofurrer/w1thermsensor

View on GitHub
.github/workflows/ci.yml

Summary

Maintainability
Test Coverage
name: CI

on: [push, pull_request]

jobs:
  ci:
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      max-parallel: 4
      matrix:
        python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
        os: [ubuntu-latest]

    steps:
      - uses: actions/checkout@v1
      - name: Set up Python ${{ matrix.python-version }}
        uses: actions/setup-python@v2
        with:
          python-version: ${{ matrix.python-version }}
      - name: Setup build and test environment
        run: |
          python -m pip install --upgrade pip setuptools wheel
      - name: Check Manifest
        run: |
          pip install check-manifest
          check-manifest
      - name: Lint with flake8
        run: |
          python -m pip install flake8
          python -m flake8 --show-source src/ tests/
      - name: Static Code Analysis with mypy
        run: |
          python -m pip install mypy types-aiofiles
          python -m mypy --ignore-missing-imports src/ tests/
      - name: Build Python Package
        run: |
          python -m pip install '.[tests]'
      - name: Unit Test with pytest
        run: |
          python -m coverage run -p -m pytest
        env:
          W1THERMSENSOR_NO_KERNEL_MODULE: 1
      - name: Report code coverage
        if: always()
        run: |
          python -m coverage combine
          python -m coverage report
          python -m coverage xml
      - name: "Upload coverage to Codecov"
        if: always()
        uses: "codecov/codecov-action@v1"
        with:
          fail_ci_if_error: true

  debian-bullseye-config:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        python-version: [3.8]
        os: [ubuntu-20.04]

    steps:
      - uses: actions/checkout@v1
      - name: Set up Python ${{ matrix.python-version }}
        uses: actions/setup-python@v2
        with:
          python-version: ${{ matrix.python-version }}
      - name: Setup build and test environment
        run: |
          python -m pip install --upgrade pip setuptools wheel
      - name: Build Python Package
        run: |
          python -m pip install '.[tests]'
      - name: Manually install dependencies matching the distribution
        run: |
          python -m pip install -U click==7.0
      - name: Unit Test with pytest
        run: |
          python -m pip install .
          python -m coverage run -p -m pytest
        env:
          W1THERMSENSOR_NO_KERNEL_MODULE: 1

  #docs:
  #runs-on: ubuntu-latest

  #steps:
  #- uses: actions/checkout@v1
  #- name: Set up Python 3.7
  #uses: actions/setup-python@v1
  #with:
  #python-version: 3.7
  #- name: Setup docs environment
  #run: |
  #python -m pip install ".[docs]"
  #- name: Build documentation with sphinx
  #run: |
  #sphinx-build -W -b html -d doctrees docs/source docs/build/html
  #sphinx-build -W -b doctest -d doctrees docs/source docs/build/html
  #- name: Generate CHANGELOG
  #run: |
  #towncrier --draft

  publish:
    #needs: [build, docs]
    needs: [ci, debian-bullseye-config]
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v1
      - name: Set up Python
        if: startsWith(github.event.ref, 'refs/tags')
        uses: actions/setup-python@v2
        with:
          python-version: "3.11"
      - name: Build Package
        if: startsWith(github.event.ref, 'refs/tags')
        run: |
          python -m pip install --upgrade pip setuptools wheel
          python setup.py sdist bdist_wheel --universal
      - name: Publish Package on PyPI
        if: startsWith(github.event.ref, 'refs/tags')
        uses: pypa/gh-action-pypi-publish@release/v1
        with:
          user: __token__
          password: ${{ secrets.pypi_token }}
      - name: Create Release on GitHub
        if: startsWith(github.event.ref, 'refs/tags')
        uses: actions/create-release@master
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          tag_name: ${{ github.ref }}
          release_name: Release ${{ github.ref }}
          draft: false
          prerelease: true