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
85 changes: 85 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: CI

on:
push:
branches: [main]
pull_request:
branches: [main]

permissions:
contents: read

jobs:
test:
name: Tests (Python 3.13)
runs-on: ubuntu-latest
timeout-minutes: 20

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Python 3.13
uses: actions/setup-python@v5
with:
python-version: "3.13"
cache: pip
cache-dependency-path: |
requirements.txt
pyproject.toml

- name: Upgrade pip and install dependencies
run: |
python -m pip install --upgrade pip
# Install runtime deps (skip iqm-client which is hardware-only and not needed for tests)
pip install -r requirements.txt
# Install test dependencies
pip install pytest>=8.0 pytest-cov>=5.0

- name: Run tests with coverage
run: |
pytest \
--cov=. \
--cov-report=term-missing \
--cov-report=xml \
--cov-report=html \
--cov-fail-under=85 \
-v \
tests/

- name: Upload coverage to Codecov (optional)
if: success()
uses: codecov/codecov-action@v4
with:
files: ./coverage.xml
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}
continue-on-error: true

smoke:
name: DiffQEC smoke test
runs-on: ubuntu-latest
timeout-minutes: 10
needs: test

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Python 3.13
uses: actions/setup-python@v5
with:
python-version: "3.13"
cache: pip
cache-dependency-path: |
requirements.txt
pyproject.toml

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt

- name: Run DiffQEC smoke test
run: |
python -m diffqec.smoke_test
13 changes: 13 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"""Pytest configuration: add the project root to sys.path.

This lets test files import from the project modules (surface_code,
extract_syndromes, internal_helpers, etc.) without requiring the project
to be installed as a package.
"""
import sys
from pathlib import Path

# Add the project root to sys.path so tests can import project modules
_PROJECT_ROOT = Path(__file__).resolve().parent
if str(_PROJECT_ROOT) not in sys.path:
sys.path.insert(0, str(_PROJECT_ROOT))
44 changes: 44 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
[pytest]
testpaths = tests
python_files = test_*.py
python_classes = Test*
python_functions = test_*
pythonpath = .
addopts =
-ra
--strict-markers
--tb=short
--disable-warnings
markers =
slow: marks tests as slow (deselect with -m 'not slow')
hardware: marks tests that require real quantum hardware (skipped in CI)
filterwarnings =
ignore::DeprecationWarning:qiskit.*
ignore::DeprecationWarning:stim.*
ignore::DeprecationWarning:pymatching.*

[coverage:run]
source =
surface_code
extract_syndromes
internal_helpers
run_on_hardware
diffqec
omit =
tests/*
iqm_utils/*
benchmarks/*
lumi/*
main.py
build_emerald_qubit_rotated.py

[coverage:report]
exclude_lines =
pragma: no cover
raise NotImplementedError
if __name__ == .__main__.:
def __repr__
\.\.\.
precision = 1
show_missing = true
skip_covered = false
5 changes: 4 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@ iqm-client==34.0.3

# --- DiffQEC decoder (discrete diffusion model) ---
torch>=2.0


# --- Test dependencies (CI) ---
pytest>=8.0
pytest-cov>=5.0
Empty file added tests/__init__.py
Empty file.
Loading
Loading