-
Notifications
You must be signed in to change notification settings - Fork 153
239 lines (238 loc) · 8.79 KB
/
main.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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
---
name: CI Jobs
on:
push:
branches: [ main, 'stable/*' ]
pull_request:
branches: [ main, 'stable/*' ]
concurrency:
group: ${{ github.repository }}-${{ github.ref }}-${{ github.head_ref }}
cancel-in-progress: true
jobs:
build_lint:
if: github.repository_owner == 'Qiskit'
name: Build, rustfmt, and python lint
runs-on: ubuntu-latest
steps:
- name: Print Concurrency Group
env:
CONCURRENCY_GROUP: ${{ github.repository }}-${{ github.ref }}-${{ github.head_ref }}
run: |
echo -e "\033[31;1;4mConcurrency Group\033[0m"
echo -e "$CONCURRENCY_GROUP\n"
shell: bash
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: 3.8
- run: pip install -U flake8 black~=22.0
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- name: Test Build
run: cargo build
- name: Rust Format
run: cargo fmt --all -- --check
- name: Clippy
run: cargo clippy -- -D warnings
- name: Black Codestyle Format
run: black --check --diff retworkx rustworkx retworkx tests
- name: Python Lint
run: flake8 --per-file-ignores='retworkx/__init__.py:F405,F403' setup.py retworkx tests rustworkx
- name: Check stray release notes
run: python tools/find_stray_release_notes.py
- name: rustworkx-core Rust Tests
run: pushd rustworkx-core && cargo test && popd
- name: rustworkx-core Docs
run: pushd rustworkx-core && cargo doc && popd
- uses: actions/upload-artifact@v3
with:
name: rustworkx_core_docs
path: target/doc/rustworkx_core
tests:
if: github.repository_owner == 'Qiskit'
needs: [build_lint]
name: python${{ matrix.python-version }}-${{ matrix.platform.python-architecture }} ${{ matrix.platform.os }} ${{ matrix.msrv }}
runs-on: ${{ matrix.platform.os }}
strategy:
matrix:
rust: [stable]
python-version: ['3.7.16', 3.8, 3.9, "3.10", "3.11"]
platform: [
{ os: "macOS-latest", python-architecture: "x64", rust-target: "x86_64-apple-darwin" },
{ os: "ubuntu-latest", python-architecture: "x64", rust-target: "x86_64-unknown-linux-gnu" },
{ os: "windows-latest", python-architecture: "x64", rust-target: "x86_64-pc-windows-msvc" },
]
include:
# Test minimal supported Rust version
- rust: 1.56.1
python-version: 3.8
platform: { os: "ubuntu-latest", python-architecture: "x64", rust-target: "x86_64-unknown-linux-gnu" }
msrv: "MSRV"
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
architecture: ${{ matrix.platform.python-architecture }}
if: runner.os != 'Windows'
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: 3.7
architecture: ${{ matrix.platform.python-architecture }}
if: ${{ runner.os == 'Windows' && matrix.python-version == '3.7.16' }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
architecture: ${{ matrix.platform.python-architecture }}
if: ${{ runner.os == 'Windows' && matrix.python-version != '3.7.16' }}
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
targets: ${{ matrix.platform.rust-target }}
- name: 'Set msrv min versions'
run: |
cargo update -p hashbrown:0.12.3 --precise 0.12.3 --workspace
cargo update -p indexmap:1.9.3 --precise 1.9.3 --workspace
if: ${{ matrix.msrv == 'MSRV' }}
- name: 'Install dependencies'
run: python -m pip install --upgrade tox
- name: 'Install binary dependencies'
run: sudo apt-get install -y graphviz
if: runner.os == 'Linux'
- name: 'Run tests'
run: tox -epy
tests_stubs:
if: github.repository_owner == 'Qiskit'
needs: [tests]
name: python-stubs-${{ matrix.python-version }}
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8, 3.9, "3.10", "3.11"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
architecture: x64
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: 'Install dependencies'
run: python -m pip install --upgrade tox
- name: 'Run rustworkx stub tests'
run: tox -estubs
tests_retworkx_compat:
if: github.repository_owner == 'Qiskit'
needs: [build_lint]
name: python${{ matrix.python-version }}-${{ matrix.platform.python-architecture }} ${{ matrix.platform.os }} ${{ matrix.msrv }}
runs-on: ${{ matrix.platform.os }}
strategy:
matrix:
rust: [stable]
python-version: ["3.10"]
platform: [
{ os: "macOS-latest", python-architecture: "x64", rust-target: "x86_64-apple-darwin" },
{ os: "ubuntu-latest", python-architecture: "x64", rust-target: "x86_64-unknown-linux-gnu" },
{ os: "windows-latest", python-architecture: "x64", rust-target: "x86_64-pc-windows-msvc" },
]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
architecture: ${{ matrix.platform.python-architecture }}
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
targets: ${{ matrix.platform.rust-target }}
- name: 'Install binary dependencies'
run: sudo apt-get install -y graphviz
if: runner.os == 'Linux'
- name: 'Build rustworkx and test dependencies'
run: |
pip install -c constraints.txt -U '.[mpl,graphviz]' fixtures testtools>=2.5.0 networkx>=2.5 stestr
- name: 'Build retworkx'
env:
RUSTWORKX_PKG_NAME: "retworkx"
run: |
pip install -c constraints.txt -U .
- name: 'Run retworkx tests'
run: |
cd tests
stestr run -t ./retworkx_backwards_compat
coverage:
if: github.repository_owner == 'Qiskit'
needs: [tests]
name: Coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools-preview
- name: Download grcov
run: curl -L https://github.com/mozilla/grcov/releases/download/v0.8.7/grcov-x86_64-unknown-linux-gnu.tar.bz2 | tar jxf -
- name: Install deps
run: pip install -U setuptools-rust networkx scipy testtools fixtures
- name: Build retworkx
run: python setup.py develop
env:
CARGO_INCREMENTAL: 0
RUSTFLAGS: "-Cinstrument-coverage"
LLVM_PROFILE_FILE: "retworkx-%p-%m.profraw"
- name: Run tests
run: cd tests && python -m unittest discover . && cd ..
env:
LLVM_PROFILE_FILE: "retworkx-%p-%m.profraw"
- name: Run grcov
run: |
set -e
mv tests/retworkx*profraw .
./grcov . --binary-path ./target/debug/ -s . -t lcov --branch --ignore-not-existing --ignore "/*" -o ./coveralls.info
- uses: actions/upload-artifact@v3
with:
name: coverage
path: coveralls.info
- name: Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: coveralls.info
docs:
if: github.repository_owner == 'Qiskit'
needs: [tests]
name: Build Docs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Install binary deps
run: sudo apt-get install -y graphviz
- name: Install deps
run: pip install -U tox
- name: Build Docs
run: tox -edocs
- uses: actions/upload-artifact@v3
with:
name: html_docs
path: docs/build/html