-
Notifications
You must be signed in to change notification settings - Fork 9
116 lines (99 loc) · 3.51 KB
/
validate-downstream.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
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);