Skip to content

Qiskit Upstream Tests #24

Qiskit Upstream Tests

Qiskit Upstream Tests #24

Workflow file for this run

name: Qiskit Upstream Tests
on:
schedule:
# Run every Monday at 00:00 UTC
- cron: "0 0 * * 1"
pull_request:
paths:
- ".github/workflows/upstream.yml"
workflow_dispatch: # Allow manual triggering
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
permissions:
contents: read
issues: write # Needed to create/update issues
jobs:
qiskit-upstream-tests:
name: 🐍⚛️
strategy:
fail-fast: false
matrix:
os: [ubuntu-24.04, macos-15, windows-2025]
uses: munich-quantum-toolkit/workflows/.github/workflows/[email protected]
with:
runs-on: ${{ matrix.os }}
setup-z3: true
create-issue-on-failure:
name: Create issue on failure
if: ${{ always() }}
needs: qiskit-upstream-tests
runs-on: ubuntu-latest
steps:
- name: Get latest Qiskit commit
id: qiskit-commit
run: |
QISKIT_COMMIT=$(curl -s https://api.github.com/repos/Qiskit/qiskit/commits/main | jq -r '.sha')
QISKIT_COMMIT_URL="https://github.com/Qiskit/qiskit/commit/${QISKIT_COMMIT}"
QISKIT_COMMIT_DATE=$(curl -s https://api.github.com/repos/Qiskit/qiskit/commits/${QISKIT_COMMIT} | jq -r '.commit.author.date')
echo "url=${QISKIT_COMMIT_URL}" >> $GITHUB_OUTPUT
echo "date=${QISKIT_COMMIT_DATE}" >> $GITHUB_OUTPUT
- name: Create or update issue
if: ${{ needs.qiskit-upstream-tests.result != 'success' }}
uses: actions/github-script@v7
with:
github-token: ${{ github.token }}
script: |
const runId = context.runId;
const workflowRunUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${runId}`;
const testResult = '${{ needs.qiskit-upstream-tests.result }}';
const qiskitCommitUrl = '${{ steps.qiskit-commit.outputs.url }}';
const qiskitCommitDate = '${{ steps.qiskit-commit.outputs.date }}';
// Search for existing open issues with a specific title pattern
const issueTitle = "❌ Qiskit Upstream Tests Failure";
const issues = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
});
// Find matching issues
const matchingIssue = issues.data.find(issue => issue.title === issueTitle);
const today = new Date().toISOString().split('T')[0];
const body = `## Qiskit Upstream Tests Failed on ${today}
The weekly Qiskit upstream test has failed.
### Workflow Details
- **Workflow Run**: [View Logs and Details](${workflowRunUrl})
- **Result**: \`${testResult}\`
- **Triggered by**: ${context.eventName}
- **Qiskit Commit Tested**: ${qiskitCommitUrl} (${qiskitCommitDate})
Please investigate and fix this issue to ensure compatibility with the latest version of Qiskit.
> This issue was automatically generated by a GitHub Action.
`;
// If we found an existing issue, update it, otherwise create a new one
if (matchingIssue) {
// Add a comment with the new failure
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: matchingIssue.number,
body: `New failure detected on ${today}.
- [View workflow run](${workflowRunUrl})
- **Qiskit Commit Tested**: ${qiskitCommitUrl} (${qiskitCommitDate})`
});
console.log(`Updated existing issue #${matchingIssue.number}`);
} else {
// Create a new issue
const newIssue = await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: issueTitle,
body: body,
labels: ['bug', 'python', 'dependencies']
});
console.log(`Created new issue #${newIssue.data.number}`);
}