thesadru/apimodel

View on GitHub
.github/workflows/checks.yml

Summary

Maintainability
Test Coverage
name: Run checks

on: [push, pull_request]

jobs:
  lint:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v3

      - name: Setup Python 3.10
        uses: actions/setup-python@v3
        with:
          python-version: "3.10"

      - name: install nox
        run: |
          python -m pip install nox
      - name: lint
        run: |
          python -m nox -s lint
  test:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        python-version: ["3.8", "3.9", "3.10", "3.11.0-beta.3"]
      fail-fast: false

    steps:
      - uses: actions/checkout@v3

      - name: Setup Python ${{ matrix.python-version }}
        uses: actions/setup-python@v3
        with:
          python-version: ${{ matrix.python-version }}

      - name: install nox
        run: |
          python -m pip install nox
      - run: |
          echo "pyversion=$(echo ${{ matrix.python-version }} | cut -d "." -f 1,2)" >> $GITHUB_ENV
      - name: Run tests
        run: |
          python -m nox -s test --python ${{ env.pyversion }} --verbose -- --cov-append
          mv .coverage .coverage.${{ env.pyversion }}
      - name: Upload coverage
        uses: actions/upload-artifact@v3
        with:
          name: coverage
          path: .coverage.${{ env.pyversion }}
          retention-days: 1
          if-no-files-found: error
  upload-coverage:
    needs: [test]
    runs-on: ubuntu-latest

    steps:
      - name: Checkout repo
        uses: actions/checkout@v3

      - name: Setup python 3.10
        uses: actions/setup-python@v3
        with:
          python-version: "3.10"

      - name: Download coverage
        uses: actions/download-artifact@v3
        with:
          name: coverage

      - name: Combine coverage
        run: |
          pip install -r ./dev-requirements/pytest-requirements.txt
          coverage combine
          coverage xml -i
      - name: Upload coverage to codeclimate
        uses: paambaati/codeclimate-action@v3.0.0
        env:
          CC_TEST_REPORTER_ID: 138a94f60b31ec374b5db1db011805a16ead822e87051d0358acae0cc6457295
        with:
          coverageLocations: .coverage.xml:coverage.py
  type-check:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2

      - name: Setup Python 3.10
        uses: actions/setup-python@v2
        with:
          python-version: "3.10"

      - name: install nox
        run: |
          python -m pip install nox
      - name: Run pyright
        run: |
          python -m nox -s type-check

      - name: Show fail comments
        if: always()
        uses: jakebailey/pyright-action@v1.0.3
        with:
          warnings: true
  verify-types:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2

      - name: Setup Python 3.10
        uses: actions/setup-python@v2
        with:
          python-version: "3.10"

      - name: install nox
        run: |
          python -m pip install nox
      - name: Run type checker
        run: |
          python -m nox -s verify-types

  prettier:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2

      - name: Run prettier
        run: |
          npx prettier --check *.md