Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 36 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,45 @@ name: Build, test and upload to PyPI

on:
push:
branches: [ master ]
branches: [ master, free-threaded ]
pull_request:
branches: [ master ]
branches: [ master, free-threaded ]

jobs:
free-threaded-tests:
name: Tests on the free-threaded interpreter
runs-on: ubuntu-latest

strategy:
matrix:
python-version: ['3.14t']

steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

# Without this the job can pass while proving nothing: if the runner ever
# falls back to a GIL-enabled interpreter, every test below still passes and
# the green tick means "the GIL build works", which is already covered above.
- name: Confirm the interpreter really is free-threaded
run: |
python -c "import sys; assert hasattr(sys, '_is_gil_enabled'), sys.version; assert not sys._is_gil_enabled(), 'GIL is enabled: ' + sys.version; print(sys.version)"

- name: Install dependencies
run: |
pip install -r requirements-test.txt
pip install .

- name: Tests
run: |
pytest tests

tests:
name: All tests, on current Python
runs-on: ubuntu-latest
Expand Down
3 changes: 2 additions & 1 deletion tests/test_circular.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ def test_max_recursion_depth(dumps):


@pytest.mark.skipif(
not sys._is_gil_enabled(),
# sys._is_gil_enabled() exists only on 3.13+; everywhere else the GIL is on.
not getattr(sys, "_is_gil_enabled", lambda: True)(),
reason="Crashes under free-threaded variant, perhaps getrecursionlimit() works differently there?"
)
def test_parse_respects_recursion_limit(loads):
Expand Down
3 changes: 2 additions & 1 deletion tests/test_memory_leaks.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
import rapidjson as rj

pytestmark = pytest.mark.skipif(
not sys._is_gil_enabled(),
# sys._is_gil_enabled() exists only on 3.13+; everywhere else the GIL is on.
not getattr(sys, "_is_gil_enabled", lambda: True)(),
reason="Crashes under free-threaded variant, perhaps tracemalloc does not work there?"
)
tracemalloc = pytest.importorskip("tracemalloc")
Expand Down
Loading