-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(py): Type stubs for calibration types reflect breaking changes in…
… 0.13.0 (#421) * fix(py): Type stubs for calibration types have been updated to reflect breaking changes in 0.13.0 * update mypy * implement workflow for checking changes against pyQuil * fix run keyword * missing | * yamlyamlyaml * tweaks to pyquil job * maybe this is the magic spell? * maybe this? * install maturin * point maturin to Cargo.toml * install other deps * give mypy the config * maybe this? * use ::warning:: * is this loud enough? * maybe this? * simplify * yamldentation * cleanup * run all checks against pyquil, but still fail the job i * separate into different workflow * remove field * try this * conclusion? * fix yaml * missing jobs key * dont want matrix for this job * continue-on-error at workflow level * continue-on-error too high * fix * maybe this? * another try * dont need to manually call core * set working directory * improve summary * simplify and improve logic * fix log link * add ) * add async keyword * js function syntax * anotha one * anotha one * let * missing backtick * init missing vars * simplify log URL construction * fix f-string * fix f-string * fix syntax * found the braket * job id not available
- Loading branch information
Showing
4 changed files
with
160 additions
and
54 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
name: Check pyQuil Compatibility | ||
on: | ||
pull_request: | ||
|
||
jobs: | ||
check-pyquil: | ||
name: Check compatibility with pyQuil | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout quil-rs Repository | ||
uses: actions/checkout@v4 | ||
with: | ||
path: quil-rs | ||
|
||
- name: Checkout pyQuil Repository | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: "rigetti/pyquil" | ||
path: pyquil | ||
|
||
- name: Install Rust Toolchain | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: stable | ||
override: true | ||
|
||
- name: Restore Python Virtual Environment | ||
uses: syphar/restore-virtualenv@v1 | ||
|
||
- name: Setup pyQuil Repository | ||
run: | | ||
pip uninstall -y -r <(pip freeze) || true | ||
pip install "./pyquil[latex]" maturin mypy ruff pytest pytest-mock | ||
maturin develop -m quil-rs/quil-py/Cargo.toml | ||
- name: Run mypy | ||
id: mypy | ||
continue-on-error: true | ||
working-directory: ./pyquil | ||
run: | | ||
mypy pyquil | ||
- name: Run ruff | ||
id: ruff | ||
continue-on-error: true | ||
working-directory: ./pyquil | ||
run: | | ||
ruff check pyquil | ||
- name: Run pytest | ||
id: pytest | ||
continue-on-error: true | ||
working-directory: ./pyquil | ||
run: | | ||
pytest test/unit -x | ||
- name: Post PR Comment and Fail if Necessary | ||
uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
const mypyFailed = '${{ steps.mypy.outcome }}' === 'failure'; | ||
const ruffFailed = '${{ steps.ruff.outcome }}' === 'failure'; | ||
const pytestFailed = '${{ steps.pytest.outcome }}' === 'failure'; | ||
const owner = context.repo.owner; | ||
const repo = context.repo.repo; | ||
const issue_number = context.issue.number; | ||
// Fetch existing comment, if it exists | ||
const identifier = `pyQuil-checks-comment`; | ||
const comments = await github.rest.issues.listComments({ | ||
owner, | ||
repo, | ||
issue_number, | ||
}); | ||
const existingComment = comments.data.find(comment => comment.body.startsWith(`<!-- ${identifier} -->`)); | ||
async function postOrUpdateComment(body) { | ||
if (existingComment) { | ||
await github.rest.issues.updateComment({ | ||
owner, | ||
repo, | ||
comment_id: existingComment.id, | ||
body | ||
}); | ||
} else { | ||
await github.rest.issues.createComment({ | ||
owner, | ||
repo, | ||
issue_number, | ||
body | ||
}); | ||
} | ||
} | ||
var body = "" | ||
if (mypyFailed || ruffFailed || pytestFailed) { | ||
body += `⚠️ **pyQuil Compatibility Checks Failed**:\n\n| Tool | Status |\n-----|-----|\n`; | ||
if (mypyFailed) { | ||
body += `| mypy | ❌ Failed |\n`; | ||
} | ||
if (ruffFailed) { | ||
body += `| ruff | ❌ Failed |\n`; | ||
} | ||
if (pytestFailed) { | ||
body += `| pytest | ❌ Failed |\n`; | ||
} | ||
body += `\n**Note**: These failures don't necessarily block the PR but both authors and reviewers should check the results for unintentional breaking changes.`; | ||
} else { | ||
body += `✅ **pyQuil Compatibility Checks Passed**. Great job!`; | ||
} | ||
await postOrUpdateComment(body); |
This file contains 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
This file contains 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