Fix policy enforcement, audit integrity and quantum result validation… #16
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| pull_request: | |
| jobs: | |
| unit: | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest] | |
| python-version: ["3.11", "3.12", "3.13", "3.14"] | |
| include: | |
| - os: macos-latest | |
| python-version: "3.12" | |
| - os: windows-latest | |
| python-version: "3.12" | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| cache: pip | |
| - name: Install | |
| run: | | |
| python -m pip install --upgrade pip | |
| python -m pip install -e ".[dev]" | |
| - name: Compile | |
| run: python -m compileall -q src tests examples | |
| - name: Test | |
| run: python -m pytest | |
| package: | |
| name: Build and verify package | |
| needs: unit | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Install packaging tools | |
| run: python -m pip install --upgrade build twine | |
| - name: Build distributions | |
| run: python -m build | |
| - name: Validate distributions | |
| run: python -m twine check dist/* | |
| - name: Install built wheel in clean environment | |
| run: | | |
| python -m venv /tmp/cudaq-guard-wheel | |
| /tmp/cudaq-guard-wheel/bin/python -m pip install --upgrade pip | |
| /tmp/cudaq-guard-wheel/bin/python -m pip install dist/*.whl | |
| /tmp/cudaq-guard-wheel/bin/python -m pip check | |
| - name: Installed-wheel CLI smoke test | |
| run: | | |
| cd /tmp | |
| /tmp/cudaq-guard-wheel/bin/python - <<'PY' | |
| import json | |
| import subprocess | |
| from importlib.metadata import version | |
| from pathlib import Path | |
| import cudaq_guard | |
| package_version = version("nvidia-cudaq-quantum-guard") | |
| executable = "/tmp/cudaq-guard-wheel/bin/cudaq-guard" | |
| assert Path(cudaq_guard.__file__).is_relative_to(Path("/tmp/cudaq-guard-wheel")) | |
| actual = subprocess.check_output([executable, "--version"], text=True).strip() | |
| assert actual == f"cudaq-guard {package_version}" | |
| subprocess.run([executable, "--help"], check=True, stdout=subprocess.DEVNULL) | |
| doctor = subprocess.run([executable, "doctor", "--json"], capture_output=True, text=True) | |
| assert doctor.returncode == 2 | |
| report = json.loads(doctor.stdout) | |
| assert report["cudaq_installed"] is False | |
| PY | |
| cudaq-smoke: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 25 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| cache: pip | |
| - name: Install CUDA-Q | |
| run: | | |
| python -m pip install --upgrade pip | |
| python -m pip install -e ".[cudaq,dev]" | |
| - name: Diagnose | |
| run: cudaq-guard doctor --json | |
| - name: Verify CPU workload mathematics | |
| run: python -m pytest tests/test_workloads.py | |
| - name: CPU simulator smoke test | |
| run: | | |
| cudaq-guard run ghz --policy policies/local-safe.toml --target qpp-cpu --qubits 3 --shots 256 --seed 7 --audit /tmp/cudaq-guard-audit.jsonl > /tmp/ghz.json | |
| cat /tmp/ghz.json | |
| python - <<'PY' | |
| import json | |
| data = json.load(open('/tmp/ghz.json')) | |
| assert data['kind'] == 'sample' | |
| assert data['shots'] == 256 | |
| assert set(data['counts']).issubset({'000', '111'}) | |
| PY | |
| cudaq-guard audit verify /tmp/cudaq-guard-audit.jsonl | |
| - name: VQE smoke test | |
| run: cudaq-guard run vqe --policy policies/local-safe.toml --target qpp-cpu --steps 7 --seed 7 --audit /tmp/cudaq-guard-audit.jsonl |