boromir674/pytest-subprocess

View on GitHub
.github/workflows/test.yaml

Summary

Maintainability
Test Coverage
name: Test Python Package
# Stress Test against different platforms and python versions

on:
  push:
    branches:
      - master
      - dev
      - ci
  pull_request:
    branches:
      - master
      - dev
    tags:
      - v*


jobs:
  test_suite:
    runs-on: ${{ matrix.platform }}
    strategy:
      matrix:
        platform: [ubuntu-latest, macos-latest]
        python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]
    steps:
    - uses: actions/checkout@v3
    - name: Set up Python ${{ matrix.python-version }}
      uses: actions/setup-python@v2
      with:
        python-version: ${{ matrix.python-version }}
    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip
        python -m pip install tox tox-gh-actions

    - name: Do Lint Checking
      run: tox -e lint -vv -s false

    - name: Do Type Checking
      run: tox -e type -vv -s false

    - name: Specify current package version to assist build tool
      run: echo "PKG_VERSION=$(python scripts/parse_version.py)" >> $GITHUB_ENV

    - name: Run Test Suite
      run: tox -vv -s false
      env:
        PLATFORM: ${{ matrix.platform }}

    - name: Aggregate Test Coverage Data
      run: tox -e coverage --sitepackages -vv -s false

    - run: pip install coverage[toml]>=5.1

    - name: Send Coverage Data to Codecov
      uses: codecov/codecov-action@v2
      with:
        directory: ./.tox
        env_vars: OS,PYTHON
        fail_ci_if_error: true
        files: ./.tox/coverage.xml
        flags: unittests
        name: codecov-umbrella
        verbose: true

    - name: Check and move the tar.gz and wheel Distributions
      shell: bash
      run: |
        DIST_DIR=dist
        echo "DIST_DIR=dist" >> $GITHUB_ENV
        mkdir ${DIST_DIR}
        mv ".tox/${DIST_DIR}/pytest_run_subprocess-${PKG_VERSION}.tar.gz" "${DIST_DIR}"
        mv ".tox/${DIST_DIR}/pytest_run_subprocess-${PKG_VERSION}-py3-none-any.whl" "${DIST_DIR}"
        tox -e check -vv -s false

    - name: Upload Source & Wheel distributions as Artefacts
      uses: actions/upload-artifact@v2
      with:
        # name: dist-${{ env.OS }}-${{ env.PYTHON }}  # TODO enable this
        name: dist-${{ matrix.platform }}-${{ matrix.python-version }}
        path: ${{ env.DIST_DIR }}
        if-no-files-found: error

    - name: Upload Coverage Data as Artefacts
      uses: actions/upload-artifact@v2
      with:
        name: coverage-xml-data
        path: ./.tox/coverage.xml
        if-no-files-found: error

    - name: Install documentation test dependencies
      if: ${{ matrix.platform == 'macos-latest' && matrix.python-version != '3.6' }}
      run: brew install enchant

    - name: Run Documentation Tests
      if: ${{ matrix.platform == 'ubuntu-latest' || matrix.python-version  != '3.6' }}
      run: |
        python -c 'import os; from pathlib import Path; f = Path("setup.py"); exec("if not os.path.exists(f):\n    f.write_text(\"from setuptools import setup\\nsetup()\")")'
        tox -e docs --sitepackages -vv -s false
        python -c 'from pathlib import Path; f = Path("setup.py"); f.unlink();'