11name : Tests
22
33on :
4- push :
5- branches :
6- - master
7- paths :
8- - ' tests/**'
9- - ' src/**'
10- - ' .github/workflows/tests.yml'
11- pull_request :
12- branches :
13- - master
14- paths :
15- - ' tests/**'
16- - ' src/**'
17- - ' .github/workflows/tests.yml'
4+ push :
5+ branches :
6+ - master
7+ pull_request :
8+ types :
9+ - " opened"
10+ - " reopened"
11+ - " synchronize"
1812
1913concurrency :
20- group : test-${{ github.head_ref }}
21- cancel-in-progress : true
14+ group : test-${{ github.head_ref }}
15+ cancel-in-progress : true
2216
2317env :
24- PYTHONUNBUFFERED : " 1"
25- FORCE_COLOR : " 1"
26- PYTHONIOENCODING : " utf8"
27- PYAWAITABLE_OPTIMIZED : 1
18+ PYTHONUNBUFFERED : " 1"
19+ FORCE_COLOR : " 1"
20+ PYTHONIOENCODING : " utf8"
21+ PYAWAITABLE_OPTIMIZED : 1
2822
2923jobs :
30- run-tests :
31- name : Python ${{ matrix.python-version }} on ${{ startsWith(matrix.os, 'macos-') && 'macOS' || startsWith(matrix.os, 'windows-') && 'Windows' || 'Linux' }}
32- runs-on : ${{ matrix.os }}
33- strategy :
34- fail-fast : false
35- matrix :
36- os : [ubuntu-latest, windows-latest, macos-latest]
37- python-version : ["3.9", "3.10", "3.11", "3.12", "3.13"]
38-
39- steps :
40- - uses : actions/checkout@v2
41-
42- - name : Set up Python ${{ matrix.python-version }}
43- uses : actions/setup-python@v2
44- with :
45- python-version : ${{ matrix.python-version }}
46-
47- - name : Install Pytest
48- run : pip install pytest pytest-asyncio typing_extensions
49-
50- - name : Build PyAwaitable
51- run : pip install .
52-
53- - name : Build PyAwaitable Test Package
54- run : pip install setuptools wheel && pip install ./tests/extension/ --no-build-isolation
55-
56- - name : Run tests
57- run : pytest -W error
24+ changes :
25+ name : Check for changed files
26+ runs-on : ubuntu-latest
27+ outputs :
28+ source : ${{ steps.filter.outputs.source }}
29+ csource : ${{ steps.filter.outputs.csource }}
30+ steps :
31+ - uses : actions/checkout@v2
32+ - uses : dorny/paths-filter@v3
33+ id : filter
34+ with :
35+ filters : |
36+ source:
37+ - 'src/**'
38+ csource:
39+ - 'src/_pyawaitable/**'
40+
41+ run-tests :
42+ needs : changes
43+ if : ${{ needs.changes.outputs.source == 'true' }}
44+ name : Python ${{ matrix.python-version }} on ${{ startsWith(matrix.os, 'macos-') && 'macOS' || startsWith(matrix.os, 'windows-') && 'Windows' || 'Linux' }}
45+ runs-on : ${{ matrix.os }}
46+ strategy :
47+ fail-fast : true
48+ matrix :
49+ os : [ubuntu-latest, windows-latest, macos-latest]
50+ python-version : ["3.9", "3.10", "3.11", "3.12", "3.13"]
51+ steps :
52+ - uses : actions/checkout@v2
53+
54+ - name : Set up Python ${{ matrix.python-version }}
55+ uses : actions/setup-python@v2
56+ with :
57+ python-version : ${{ matrix.python-version }}
58+
59+ - name : Install Pytest
60+ run : pip install pytest pytest-asyncio typing_extensions
61+
62+ - name : Build PyAwaitable
63+ run : pip install .
64+
65+ - name : Build PyAwaitable Test Package
66+ run : pip install setuptools wheel && pip install ./tests/extension/ --no-build-isolation
67+
68+ - name : Run tests
69+ run : pytest -W error
70+
71+ memory-errors :
72+ needs :
73+ - changes
74+ - run-tests
75+ if : ${{ needs.changes.outputs.csource == 'true' }}
76+ name : Check for memory errors
77+ runs-on : ubuntu-latest
78+ env :
79+ PYTHONMALLOC : malloc
80+ steps :
81+ - uses : actions/checkout@v2
82+
83+ - name : Set up Python 3.12
84+ uses : actions/setup-python@v2
85+ with :
86+ python-version : 3.12
87+
88+ - name : Install Pytest
89+ run : |
90+ pip install pytest pytest-asyncio pytest-memray typing_extensions
91+ shell : bash
92+
93+ - name : Build PyAwaitable
94+ run : pip install .
95+
96+ - name : Build PyAwaitable Test Package
97+ run : pip install setuptools wheel && pip install tests/extension/ --no-build-isolation
98+
99+ - name : Install Valgrind
100+ run : sudo apt-get update && sudo apt-get -y install valgrind
101+
102+ - name : Run tests with Valgrind
103+ run : valgrind --suppressions=valgrind-python.supp --error-exitcode=1 pytest -x
104+
105+ memory-leaks :
106+ needs :
107+ - changes
108+ - memory-errors
109+ if : ${{ needs.changes.outputs.csource == 'true' }}
110+ name : Check for memory leaks
111+ runs-on : ubuntu-latest
112+ env :
113+ PYTHONMALLOC : malloc
114+ steps :
115+ - uses : actions/checkout@v2
116+
117+ - name : Set up Python 3.12
118+ uses : actions/setup-python@v2
119+ with :
120+ python-version : 3.12
121+
122+ - name : Install Pytest
123+ run : |
124+ pip install pytest pytest-asyncio pytest-memray typing_extensions
125+ shell : bash
126+
127+ - name : Build PyAwaitable
128+ run : pip install .
129+
130+ - name : Build PyAwaitable Test Package
131+ run : pip install setuptools wheel && pip install tests/extension/ --no-build-isolation
132+
133+ - name : Run tests with Memray tracking
134+ run : pytest --enable-leak-tracking -W error --stacks=50 --native
135+
136+ tests-pass :
137+ runs-on : ubuntu-latest
138+ name : All tests passed
139+ if : always()
140+
141+ needs :
142+ - run-tests
143+ - memory-errors
144+ - memory-leaks
145+
146+ steps :
147+ - name : Check whether all tests passed
148+ uses : re-actors/alls-green@release/v1
149+ with :
150+ jobs : ${{ toJSON(needs) }}
151+ allowed-skips : ${{ toJSON(needs) }}
0 commit comments