Skip to content

Commit 05101f5

Browse files
CI: Make test workflows more robust (#54)
- Merge all test workflows into one. - Use an action for path filtering instead of GitHub's. - Use a cleaner `All checks passed` workflow.
1 parent 9b9b006 commit 05101f5

File tree

4 files changed

+135
-116
lines changed

4 files changed

+135
-116
lines changed

.github/workflows/all_checks_pass.yml

Lines changed: 0 additions & 13 deletions
This file was deleted.

.github/workflows/memory_leak.yml

Lines changed: 0 additions & 54 deletions
This file was deleted.

.github/workflows/tests.yml

Lines changed: 135 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,144 @@
11
name: Tests
22

33
on:
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

1913
concurrency:
20-
group: test-${{ github.head_ref }}
21-
cancel-in-progress: true
14+
group: test-${{ github.head_ref }}
15+
cancel-in-progress: true
2216

2317
env:
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

2923
jobs:
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+
runs-on: ubuntu-latest
26+
outputs:
27+
source: ${{ steps.filter.outputs.source }}
28+
csource: ${{ steps.filter.outputs.csource }}
29+
steps:
30+
- uses: actions/checkout@v2
31+
- uses: dorny/paths-filter@v3
32+
id: filter
33+
with:
34+
filters: |
35+
source:
36+
- 'src/**'
37+
csource:
38+
- 'src/_pyawaitable/**'
39+
40+
run-tests:
41+
needs: changes
42+
if: ${{ needs.changes.outputs.source == 'true' }}
43+
name: Python ${{ matrix.python-version }} on ${{ startsWith(matrix.os, 'macos-') && 'macOS' || startsWith(matrix.os, 'windows-') && 'Windows' || 'Linux' }}
44+
runs-on: ${{ matrix.os }}
45+
strategy:
46+
fail-fast: true
47+
matrix:
48+
os: [ubuntu-latest, windows-latest, macos-latest]
49+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
50+
steps:
51+
- uses: actions/checkout@v2
52+
53+
- name: Set up Python ${{ matrix.python-version }}
54+
uses: actions/setup-python@v2
55+
with:
56+
python-version: ${{ matrix.python-version }}
57+
58+
- name: Install Pytest
59+
run: pip install pytest pytest-asyncio typing_extensions
60+
61+
- name: Build PyAwaitable
62+
run: pip install .
63+
64+
- name: Build PyAwaitable Test Package
65+
run: pip install setuptools wheel && pip install ./tests/extension/ --no-build-isolation
66+
67+
- name: Run tests
68+
run: pytest -W error
69+
70+
memory-errors:
71+
needs:
72+
- changes
73+
- run-tests
74+
if: ${{ needs.changes.outputs.csource == 'true' }}
75+
name: Check for memory errors
76+
runs-on: ubuntu-latest
77+
env:
78+
PYTHONMALLOC: malloc
79+
steps:
80+
- uses: actions/checkout@v2
81+
82+
- name: Set up Python 3.12
83+
uses: actions/setup-python@v2
84+
with:
85+
python-version: 3.12
86+
- name: Build PyAwaitable
87+
run: pip install .
88+
89+
- name: Build PyAwaitable Test Package
90+
run: pip install setuptools wheel && pip install tests/extension/ --no-build-isolation
91+
92+
- name: Install Valgrind
93+
run: sudo apt-get update && sudo apt-get -y install valgrind
94+
95+
- name: Run tests with Valgrind
96+
run: valgrind --suppressions=valgrind-python.supp --error-exitcode=1 pytest -x
97+
98+
memory-leaks:
99+
needs:
100+
- changes
101+
- memory-errors
102+
if: ${{ needs.changes.outputs.csource == 'true' }}
103+
name: Check for memory leaks
104+
runs-on: ubuntu-latest
105+
env:
106+
PYTHONMALLOC: malloc
107+
steps:
108+
- uses: actions/checkout@v2
109+
110+
- name: Set up Python 3.12
111+
uses: actions/setup-python@v2
112+
with:
113+
python-version: 3.12
114+
115+
- name: Install Pytest
116+
run: |
117+
pip install pytest pytest-asyncio pytest-memray typing_extensions
118+
shell: bash
119+
120+
- name: Build PyAwaitable
121+
run: pip install .
122+
123+
- name: Build PyAwaitable Test Package
124+
run: pip install setuptools wheel && pip install tests/extension/ --no-build-isolation
125+
126+
- name: Run tests with Memray tracking
127+
run: pytest --enable-leak-tracking -W error --stacks=50 --native
128+
129+
tests-pass:
130+
runs-on: ubuntu-latest
131+
name: All tests passed
132+
if: always()
133+
134+
needs:
135+
- run-tests
136+
- memory-errors
137+
- memory-leaks
138+
139+
steps:
140+
- name: Check whether all tests passed
141+
uses: re-actors/alls-green@release/v1
142+
with:
143+
jobs: ${{ toJSON(needs) }}
144+
allowed-skips: ${{ toJSON(needs) }}

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
[![Build Wheels](https://github.com/ZeroIntensity/pyawaitable/actions/workflows/build.yml/badge.svg)](https://github.com/ZeroIntensity/pyawaitable/actions/workflows/build.yml)
66
![Tests](https://github.com/ZeroIntensity/pyawaitable/actions/workflows/tests.yml/badge.svg)
7-
![Memory Leak](https://github.com/ZeroIntensity/pyawaitable/actions/workflows/memory_leak.yml/badge.svg)
87

98
- [Docs](https://awaitable.zintensity.dev)
109
- [Source](https://github.com/ZeroIntensity/pyawaitable)

0 commit comments

Comments
 (0)