• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1name: Test
2
3on:
4  push:
5    branches: [main]
6  pull_request:
7    branches: [main]
8
9permissions:
10  contents: read
11
12env:
13  # turns off tox's output redirection so we can debug package installation
14  TOX_OPTIONS: -vv
15
16jobs:
17  lint:
18    runs-on: ubuntu-latest
19    # https://github.community/t/github-actions-does-not-respect-skip-ci/17325/8
20    if: "! contains(toJSON(github.event.commits.*.message), '[skip ci]')"
21    steps:
22    - uses: actions/checkout@v4
23    - name: Set up Python 3.x
24      uses: actions/setup-python@v5
25      with:
26        python-version: "3.x"
27    - name: Install packages
28      run: pip install tox
29    - name: Run Tox
30      run: tox $TOX_OPTIONS -e lint,package_readme
31
32  test:
33    runs-on: ${{ matrix.platform }}
34    if: "! contains(toJSON(github.event.commits.*.message), '[skip ci]')"
35    strategy:
36      fail-fast: false
37      matrix:
38        python-version: ["3.8", "3.11", "3.12"]
39        platform: [ubuntu-latest]
40        include: # Only test on the latest supported stable Python on macOS and Windows.
41          - platform: macos-latest
42            python-version: 3.11
43          - platform: windows-latest
44            python-version: 3.11
45    steps:
46    - uses: actions/checkout@v4
47    - name: Set up Python ${{ matrix.python-version }}
48      uses: actions/setup-python@v5
49      with:
50        python-version: ${{ matrix.python-version }}
51        allow-prereleases: true
52    - name: Install packages
53      run: pip install tox coverage
54    - name: Run Tox
55      run: tox $TOX_OPTIONS -e py-cov
56    - name: Run Tox without extra dependencies
57      run: tox $TOX_OPTIONS -e py-cov-noextra
58    - name: Produce coverage files
59      run: |
60        coverage combine
61        coverage xml
62    - name: Upload coverage to Codecov
63      uses: codecov/codecov-action@v4
64      with:
65        file: coverage.xml
66        flags: unittests
67        name: codecov-umbrella
68        # TODO(anthrotype): Set fail_ci_if_error: true if/when Codecov becomes less flaky
69        fail_ci_if_error: false
70        # see https://github.com/codecov/codecov-action/issues/557
71        token: ${{ secrets.CODECOV_TOKEN }}
72
73  test-cython:
74    runs-on: ubuntu-latest
75    if: "! contains(toJSON(github.event.commits.*.message), '[skip ci]')"
76    steps:
77    - uses: actions/checkout@v4
78    - name: Set up Python 3.x
79      uses: actions/setup-python@v5
80      with:
81        python-version: "3.11"
82    - name: Install packages
83      run: pip install tox
84    - name: Run Tox
85      run: tox $TOX_OPTIONS -e py-cy
86
87  test-pypy3:
88    runs-on: ubuntu-latest
89    if: "! contains(toJSON(github.event.commits.*.message), '[skip ci]')"
90    steps:
91    - uses: actions/checkout@v4
92    - name: Set up Python pypy3
93      uses: actions/setup-python@v5
94      with:
95        python-version: "pypy-3.9"
96    - name: Install packages
97      run: pip install tox
98    - name: Run Tox
99      run: tox $TOX_OPTIONS -e pypy3
100