8000 Improve test CI using pytest · Issue #51 · scholi/pySPM · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Improve test CI using pytest #51
Open
@ns-rse

Description

@ns-rse

I noticed that the popular pytest package is not a dependency. Not clear how tests are run, and there is no Continuous Integration that run tests on pulls.

If an optional dependency on pytest were included a workflow similar to the following could be included (.github/workflows/tests.yaml)

.github/workflows/tests.yaml

name: Tests (pytest)

on:
  pull_request:
    types:
      - opened
      - ready_for_review
      - reopened
      - synchronize
    paths:
      - "**.csv"
      - "**.npy"
      - "**.out"
      - "**.pkl"
      - "**.png"
      - "**.py"
      - "**.toml"
      - "**.yaml"

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  build:
    name: Ex1 (${{ matrix.python-version }}, ${{ matrix.os }})
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: ["ubuntu-latest", "macos-latest", "windows-latest"]
        python-version: ["3.10", "3.11", "3.12"]
    steps:
      - uses: actions/checkout@v4
      - name: Set up Python
        uses: actions/setup-python@v5
        with:
          python-version: ${{ matrix.python-version }}
      - name: Upgrade pip and install test dependencies
        run: |
          pip install --upgrade virtualenv
          pip install --upgrade pip setuptools
          pip show pip setuptools
          virtualenv --upgrade-embed-wheels
          pip install -e .[tests]
      - name: Test with pytest
        run: |
          pytest --cov=pySPM --mpl -x
      - name: Determine coverage
        run: |
          coverage xml
      - name: Upload coverage to Codecov
        uses: codecov/codecov-action@v5

      - name: Setup tmate session
        if: ${{ failure() }}
        uses: mxschmitt/action-tmate@v3
        timeout-minutes: 5

pyproject.toml

Addition to pyproject.toml would be something like...

[project.optional-dependencies]
tests = [
  "pytest",
  "pytest-cov",
  "pytest-github-actions-annotate-failures",
]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0