deeplime-io/onecode

View on GitHub
.github/workflows/validation.yml

Summary

Maintainability
Test Coverage
name: Validation

on:
  push:
    branches:
      - '*.x'
      - patch/**
    path:
      - onecode/**
      - tests/**

  pull_request:
    branches:
      - main

jobs:
  formatting:
    name: Check Formatting
    runs-on: ubuntu-latest
    timeout-minutes: 5
    steps:
      - uses: actions/checkout@v4
      - name: Set up Python
        uses: actions/setup-python@v5
        with:
          python-version: '3.10'

      - name: Install Formatting
        run: |
          python -m pip install --upgrade pip
          pip install flake8
          pip install isort

      - name: Check Formatting
        run: |
          flake8 onecode tests/unit/ --exclude=__init__.py,tests/data --max-line-length=100
          isort . -m3 --thirdparty . --check-only --skip tests/data

  testing:
    name: Check Testing
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, windows-latest, macos-latest]
        python: ["3.10", "3.11", "3.12"]
    runs-on: ${{ matrix.os }}
    timeout-minutes: 30
    steps:
      - uses: actions/checkout@v4
      - name: Set up Python
        uses: actions/setup-python@v5
        with:
          python-version: ${{ matrix.python }}

      - name: Install Python libraries
        run: |
          python -m pip install --upgrade pip
          pip install .[developer]

      - name: Check Testing Linux/MacOS
        if: ${{ matrix.os != 'windows-latest' }}
        run: |
          ONECODE_DO_TYPECHECK=1 python -m pytest tests -n auto

      - name: Check Testing Windows
        if: ${{ matrix.os == 'windows-latest' }}
        run: |
          set ONECODE_DO_TYPECHECK=1
          python -m pytest tests

  coverage:
    name: Run coverage report
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, windows-latest]
        python: ["3.10"]
    runs-on: ${{ matrix.os }}
    timeout-minutes: 30
    steps:
      - uses: actions/checkout@v4
      - name: Set up Python
        uses: actions/setup-python@v5
        with:
          python-version: ${{ matrix.python }}

      - name: Install Python libraries
        run: |
          python -m pip install --upgrade pip
          pip install .[developer]

      - name: Test coverage Linux
        if: ${{ matrix.os == 'ubuntu-latest' }}
        run: |
          ONECODE_DO_TYPECHECK=1 coverage run -m pytest tests --cov=./ --cov-report=xml

      - name: Test coverage Windows
        if: ${{ matrix.os == 'windows-latest' }}
        run: |
          set ONECODE_DO_TYPECHECK=1
          coverage run -m pytest tests --cov=./ --cov-report=xml

      - name: Upload coverage reports to Codecov
        uses: codecov/codecov-action@v3
        with:
          token: ${{ secrets.CODECOV_TOKEN }}
          files: ./coverage.xml
          fail_ci_if_error: false
          name: codecov-umbrella
          verbose: true