Skip to content

Commit e59efea

Browse files
committed
✨ add continuous testing workflow for running against the latest Qiskit main branch
Signed-off-by: burgholzer <burgholzer@me.com>
1 parent ae6f34f commit e59efea

File tree

2 files changed

+119
-6
lines changed

2 files changed

+119
-6
lines changed

.github/workflows/upstream.yml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: Qiskit Upstream Tests
2+
on:
3+
schedule:
4+
# Run every Monday at 00:00 UTC
5+
- cron: "0 0 * * 1"
6+
pull_request:
7+
paths:
8+
- ".github/workflows/upstream.yml"
9+
workflow_dispatch: # Allow manual triggering
10+
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
13+
cancel-in-progress: true
14+
15+
permissions:
16+
contents: read
17+
issues: write # Needed to create/update issues
18+
19+
jobs:
20+
qiskit-upstream-tests:
21+
name: 🐍⚛️
22+
strategy:
23+
fail-fast: false
24+
matrix:
25+
os: [ubuntu-24.04, macos-15, windows-2025]
26+
uses: cda-tum/mqt-workflows/.github/workflows/reusable-qiskit-upstream.yml@v1.7
27+
with:
28+
runs-on: ${{ matrix.os }}
29+
setup-z3: true
30+
31+
create-issue-on-failure:
32+
name: Create issue on failure
33+
if: ${{ always() }}
34+
needs: qiskit-upstream-tests
35+
runs-on: ubuntu-latest
36+
steps:
37+
- name: Create or update issue
38+
if: ${{ needs.qiskit-upstream-tests.result != 'success' }}
39+
uses: actions/github-script@v6
40+
with:
41+
github-token: ${{ github.token }}
42+
script: |
43+
const runId = context.runId;
44+
const workflowRunUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${runId}`;
45+
46+
// Search for existing open issues with a specific title pattern
47+
const issueTitle = "❌ Qiskit Upstream Tests Failure";
48+
const query = `repo:${context.repo.owner}/${context.repo.repo} is:issue is:open in:title "${issueTitle}"`;
49+
50+
const searchResult = await github.rest.search.issuesAndPullRequests({
51+
q: query
52+
});
53+
54+
const today = new Date().toISOString().split('T')[0];
55+
const body = `## Qiskit Upstream Tests Failed on ${today}
56+
57+
The weekly Qiskit upstream test has failed.
58+
59+
### Workflow Details
60+
61+
- **Workflow Run**: [View Logs and Details](${workflowRunUrl})
62+
- **Result**: \`${needs.qiskit-upstream-tests.result}\`
63+
- **Triggered by**: ${context.eventName}
64+
65+
Please investigate and fix this issue to ensure compatibility with the latest version of Qiskit.
66+
67+
> This issue was automatically generated by a GitHub Action.
68+
`;
69+
70+
// If we found an existing issue, update it, otherwise create a new one
71+
if (searchResult.data.items.length > 0) {
72+
const issue = searchResult.data.items[0];
73+
74+
// Add a comment with the new failure
75+
await github.rest.issues.createComment({
76+
owner: context.repo.owner,
77+
repo: context.repo.repo,
78+
issue_number: issue.number,
79+
body: `New failure detected on ${today}. [View workflow run](${workflowRunUrl})`
80+
});
81+
82+
console.log(`Updated existing issue #${issue.number}`);
83+
} else {
84+
// Create a new issue
85+
const newIssue = await github.rest.issues.create({
86+
owner: context.repo.owner,
87+
repo: context.repo.repo,
88+
title: issueTitle,
89+
body: body,
90+
labels: ['bug', 'python', 'dependencies']
91+
});
92+
93+
console.log(`Created new issue #${newIssue.data.number}`);
94+
}

noxfile.py

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ def _run_tests(
3737
session: nox.Session,
3838
*,
3939
install_args: Sequence[str] = (),
40-
run_args: Sequence[str] = (),
40+
extra_command: Sequence[str] = (),
41+
pytest_run_args: Sequence[str] = (),
4142
) -> None:
4243
env = {"UV_PROJECT_ENVIRONMENT": session.virtualenv.location}
4344
if os.environ.get("CI", None) and sys.platform == "win32":
@@ -57,7 +58,6 @@ def _run_tests(
5758
"build",
5859
"--only-group",
5960
"test",
60-
"--verbose",
6161
# Build mqt-core from source to work around pybind believing that two
6262
# compiled extensions might not be binary compatible.
6363
# This will be fixed in a new pybind11 release that includes https://github.com/pybind/pybind11/pull/5439.
@@ -73,14 +73,25 @@ def _run_tests(
7373
)
7474
session.run(
7575
"uv",
76-
"run",
76+
"sync",
77+
"--inexact",
7778
"--no-dev", # do not auto-install dev dependencies
7879
"--no-build-isolation-package",
7980
"mqt-qmap", # build the project without isolation
80-
"--verbose",
81+
*install_args,
82+
env=env,
83+
)
84+
session.run(
85+
*extra_command,
86+
env=env,
87+
)
88+
session.run(
89+
"uv",
90+
"run",
91+
"--no-sync", # do not sync as everything is already installed
8192
*install_args,
8293
"pytest",
83-
*run_args,
94+
*pytest_run_args,
8495
*session.posargs,
8596
"--cov-config=pyproject.toml",
8697
env=env,
@@ -99,13 +110,21 @@ def minimums(session: nox.Session) -> None:
99110
_run_tests(
100111
session,
101112
install_args=["--resolution=lowest-direct"],
102-
run_args=["-Wdefault"],
113+
pytest_run_args=["-Wdefault"],
103114
)
104115
env = {"UV_PROJECT_ENVIRONMENT": session.virtualenv.location}
105116
session.run("uv", "tree", "--frozen", env=env)
106117
session.run("uv", "lock", "--refresh", env=env)
107118

108119

120+
@nox.session(reuse_venv=True, venv_backend="uv", python=PYTHON_ALL_VERSIONS)
121+
def qiskit(session: nox.Session) -> None:
122+
"""Tests against the latest version of Qiskit."""
123+
_run_tests(session, extra_command=["uv", "pip", "install", "qiskit @ git+https://github.com/Qiskit/qiskit.git"])
124+
env = {"UV_PROJECT_ENVIRONMENT": session.virtualenv.location}
125+
session.run("uv", "pip", "show", "qiskit", env=env)
126+
127+
109128
@nox.session(reuse_venv=True)
110129
def docs(session: nox.Session) -> None:
111130
"""Build the docs. Use "--non-interactive" to avoid serving. Pass "-b linkcheck" to check links."""

0 commit comments

Comments
 (0)