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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ns-rse opened this issue May 9, 2025 · 0 comments
Open

Improve test CI using pytest #51

ns-rse opened this issue May 9, 2025 · 0 comments

Comments

@ns-rse
Copy link
Contributor
ns-rse commented May 9, 2025

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",
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant
0