|
| 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: Get latest Qiskit commit |
| 38 | + id: qiskit-commit |
| 39 | + run: | |
| 40 | + QISKIT_COMMIT=$(curl -s https://api.github.com/repos/Qiskit/qiskit/commits/main | jq -r '.sha') |
| 41 | + QISKIT_COMMIT_URL="https://github.com/Qiskit/qiskit/commit/${QISKIT_COMMIT}" |
| 42 | + QISKIT_COMMIT_DATE=$(curl -s https://api.github.com/repos/Qiskit/qiskit/commits/${QISKIT_COMMIT} | jq -r '.commit.author.date') |
| 43 | + echo "url=${QISKIT_COMMIT_URL}" >> $GITHUB_OUTPUT |
| 44 | + echo "date=${QISKIT_COMMIT_DATE}" >> $GITHUB_OUTPUT |
| 45 | +
|
| 46 | + - name: Create or update issue |
| 47 | + if: ${{ needs.qiskit-upstream-tests.result != 'success' }} |
| 48 | + uses: actions/github-script@v6 |
| 49 | + with: |
| 50 | + github-token: ${{ github.token }} |
| 51 | + script: | |
| 52 | + const runId = context.runId; |
| 53 | + const workflowRunUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${runId}`; |
| 54 | + const testResult = '${{ needs.qiskit-upstream-tests.result }}'; |
| 55 | + const qiskitCommitUrl = '${{ steps.qiskit-commit.outputs.url }}'; |
| 56 | + const qiskitCommitDate = '${{ steps.qiskit-commit.outputs.date }}'; |
| 57 | +
|
| 58 | + // Search for existing open issues with a specific title pattern |
| 59 | + const issueTitle = "❌ Qiskit Upstream Tests Failure"; |
| 60 | +
|
| 61 | + const issues = await github.rest.issues.listForRepo({ |
| 62 | + owner: context.repo.owner, |
| 63 | + repo: context.repo.repo, |
| 64 | + state: 'open', |
| 65 | + }); |
| 66 | +
|
| 67 | + // Find matching issues |
| 68 | + const matchingIssue = issues.data.find(issue => issue.title === issueTitle); |
| 69 | +
|
| 70 | + const today = new Date().toISOString().split('T')[0]; |
| 71 | + const body = `## Qiskit Upstream Tests Failed on ${today} |
| 72 | +
|
| 73 | + The weekly Qiskit upstream test has failed. |
| 74 | +
|
| 75 | + ### Workflow Details |
| 76 | +
|
| 77 | + - **Workflow Run**: [View Logs and Details](${workflowRunUrl}) |
| 78 | + - **Result**: \`${testResult}\` |
| 79 | + - **Triggered by**: ${context.eventName} |
| 80 | + - **Qiskit Commit Tested**: ${qiskitCommitUrl} (${qiskitCommitDate}) |
| 81 | +
|
| 82 | + Please investigate and fix this issue to ensure compatibility with the latest version of Qiskit. |
| 83 | +
|
| 84 | + > This issue was automatically generated by a GitHub Action. |
| 85 | + `; |
| 86 | +
|
| 87 | + // If we found an existing issue, update it, otherwise create a new one |
| 88 | + if (matchingIssue) { |
| 89 | + // Add a comment with the new failure |
| 90 | + await github.rest.issues.createComment({ |
| 91 | + owner: context.repo.owner, |
| 92 | + repo: context.repo.repo, |
| 93 | + issue_number: matchingIssue.number, |
| 94 | + body: `New failure detected on ${today}. |
| 95 | + - [View workflow run](${workflowRunUrl}) |
| 96 | + - **Qiskit Commit Tested**: ${qiskitCommitUrl} (${qiskitCommitDate})` |
| 97 | + }); |
| 98 | +
|
| 99 | + console.log(`Updated existing issue #${matchingIssue.number}`); |
| 100 | + } else { |
| 101 | + // Create a new issue |
| 102 | + const newIssue = await github.rest.issues.create({ |
| 103 | + owner: context.repo.owner, |
| 104 | + repo: context.repo.repo, |
| 105 | + title: issueTitle, |
| 106 | + body: body, |
| 107 | + labels: ['bug', 'python', 'dependencies'] |
| 108 | + }); |
| 109 | +
|
| 110 | + console.log(`Created new issue #${newIssue.data.number}`); |
| 111 | + } |
0 commit comments