File: reusable-pytest.yml

package info (click to toggle)
python-build 1.2.2-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 508 kB
  • sloc: python: 2,622; makefile: 16
file content (101 lines) | stat: -rw-r--r-- 2,613 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
name: pytest
on:
  workflow_call:

jobs:
  pytest:
    runs-on: ${{ matrix.os }}-latest
    env:
      PYTEST_ADDOPTS: "--run-integration --showlocals -vv --durations=10 --reruns 5 --only-rerun subprocess.CalledProcessError"
    strategy:
      fail-fast: false
      matrix:
        os:
          - ubuntu
          - macos
          - windows
        py:
          - "pypy3.8"
          - "pypy3.9-v7.3.14"
          - "pypy3.10-v7.3.17"
          - "3.12"
          - "3.11"
          - "3.10"
          - "3.9"
          - "3.8"
        tox-target:
          - "tox"
          - "min"

    continue-on-error: >- # jobs not required in branch protection
      ${{
        (
          startsWith(matrix.py, 'pypy')
          && matrix.os == 'windows'
        )
        && true
        || false
      }}

    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - name: Setup python for test ${{ matrix.py }}
        uses: actions/setup-python@v5
        with:
          python-version: ${{ matrix.py }}
          allow-prereleases: true

      - name: Pick environment to run
        run: |
          import platform
          import os
          import sys

          if platform.python_implementation() == "PyPy":
              base = f"pypy{sys.version_info.major}{sys.version_info.minor}"
          else:
              base = f"py{sys.version_info.major}{sys.version_info.minor}"
          env = f"BASE={base}\n"
          print(f"Picked:\n{env}for {sys.version}")
          with open(os.environ["GITHUB_ENV"], "a", encoding="utf-8") as file:
              file.write(env)
        shell: python

      - name: Setup python for tox
        uses: actions/setup-python@v5
        with:
          python-version: 3.9

      - name: Install tox
        run: python -m pip install tox

      - name: Run test suite via tox
        if: matrix.tox-target == 'tox'
        run: |
          tox -vv --notest -e ${{env.BASE}}
          tox -e ${{env.BASE}} --skip-pkg-install

      - name: Run minimum version test
        if: matrix.tox-target == 'min'
        run: tox -e ${{env.BASE}}-${{ matrix.tox-target }}

      - name: Run path test
        if: matrix.tox-target == 'tox' && matrix.py == '3.10'
        run: tox -e path

      - name: Combine coverage files
        if: always()
        run: tox -e coverage

      - uses: codecov/codecov-action@v4
        if: always()
        env:
          PYTHON: ${{ matrix.python }}
        with:
          file: ./.tox/coverage.xml
          flags: tests
          env_vars: PYTHON
          name: ${{ matrix.py }} - ${{ matrix.os }}