Skip to content

Commit 23dac9e

Browse files
authored
GitHub actions, pre-commit hooks, pyproject.toml and more (#395)
* Adding support for GitHub actions * Add workflow to upload to PyPi on GitHub releases submission * Add dependabot configuration file * Clang-Tidy and generation of requirement file for setup.py * Add support for pre-commit hooks and formatting workflow * Remove .pylintrc, .coveragerc and pytest.ini in favour of setup.cfg * Fix Clang-Tidy warnings * Fix flake8 warnings * Modify MANIFEST.in * Fix some issues with the documentation generation * Fix awsbraket tests to avoid running if boto3 is not installed * Remove Python2 compatibility code * Apply changes from pre-commit-hooks * Run Black on whole project * Run remove-tabs on whole project * Fix flake8 issues * Fix some warnings occurring while running the test suite * Add pyproject.toml * Adapt GitHub Action to use pyproject.toml * Add .editorconfig * Use setuptools-scm * Add GitHub Actions for creating new releases * Add CHANGELOG.md * Update pre-commit hooks * Update license headers of files with non-trivial changes * Add setup.cfg and pyproject.toml to MANIFEST.in * Change output name of version file * Move parameters for check-manifest into pyproject.toml * Address most comments (mostly merging strings) * Effects of running black and flake8 with new settings * Remove __div__ and __idiv__ usage in tests for QubitOperator * Fix typo * Fix build issues on Clang docker images * Make installation verbose on CI * Fix bug with classical simulator and negative bit shifts * Update flaky for GCC CI builds * Remove unneeded qubit allocation in meta.Loop tests
1 parent fb548ef commit 23dac9e

File tree

251 files changed

+7582
-5938
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

251 files changed

+7582
-5938
lines changed

.coveragerc

-4
This file was deleted.

.editorconfig

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
root = true
2+
3+
[*]
4+
end_of_line = lf
5+
trim_trailing_whitespace = true
6+
insert_final_newline = false
7+
indent_style = space
8+
indent_size = 4
9+
10+
[*.{yml,yaml}]
11+
indent_style = space
12+
indent_size = 2

.github/dependabot.yml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
ignore:
8+
# Optional: Official actions have moving tags like v1;
9+
# if you use those, you don't need updates.
10+
- dependency-name: "actions/*"

.github/workflows/ci.yml

+347
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,347 @@
1+
name: CI
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
push:
7+
branches:
8+
- master
9+
- develop
10+
- v*
11+
12+
jobs:
13+
standard:
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
runs-on: [ubuntu-latest, windows-latest, macos-latest]
18+
python:
19+
- 3.6
20+
- 3.7
21+
- 3.8
22+
- 3.9
23+
24+
name: "🐍 ${{ matrix.python }} • ${{ matrix.runs-on }} • x64 ${{ matrix.args }}"
25+
runs-on: ${{ matrix.runs-on }}
26+
27+
steps:
28+
- uses: actions/checkout@v2
29+
30+
- name: Get history and tags for SCM versioning to work
31+
run: |
32+
git fetch --prune --unshallow
33+
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
34+
35+
- name: Setup Python ${{ matrix.python }}
36+
uses: actions/setup-python@v2
37+
with:
38+
python-version: ${{ matrix.python }}
39+
architecture: 'x64'
40+
41+
- name: Get pip cache dir
42+
id: pip-cache
43+
run: |
44+
echo "::set-output name=dir::$(python -m pip cache dir)"
45+
46+
- name: Cache wheels
47+
uses: actions/cache@v2
48+
with:
49+
path: ${{ steps.pip-cache.outputs.dir }}
50+
key: ${{ runner.os }}-${{ matrix.python }}-pip-${{ hashFiles('**/setup.cfg') }}
51+
restore-keys: ${{ runner.os }}-${{ matrix.python }}-pip-
52+
53+
- name: Prepare env
54+
run: |
55+
python setup.py gen_reqfile --include-extras
56+
python -m pip install -r requirements.txt --prefer-binary
57+
python -m pip install -r requirements_tests.txt --prefer-binary
58+
python -m pip install coveralls
59+
60+
- name: Setup annotations on Linux
61+
if: runner.os == 'Linux'
62+
run: python -m pip install pytest-github-actions-annotate-failures
63+
64+
- name: Build and install package
65+
run: python -m pip install -ve .[braket]
66+
67+
- name: Pytest
68+
run: |
69+
echo 'backend: Agg' > matplotlibrc
70+
python -m pytest -p no:warnings --cov=projectq
71+
72+
- name: Coveralls.io
73+
run: coveralls --service=github
74+
env:
75+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
76+
COVERALLS_FLAG_NAME: python-${{ matrix.python }}-${{ matrix.runs-on }}-x64
77+
COVERALLS_PARALLEL: true
78+
79+
80+
finish:
81+
needs: standard
82+
runs-on: ubuntu-latest
83+
container: python:3-slim
84+
steps:
85+
- name: Coveralls Finished
86+
run: |
87+
pip3 install --upgrade coveralls
88+
coveralls --finish
89+
env:
90+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
91+
92+
93+
clang:
94+
runs-on: ubuntu-latest
95+
strategy:
96+
fail-fast: false
97+
matrix:
98+
clang:
99+
- 3.5 # version for full C++14 support (3.4 fails because of -fstack-protector-strong)
100+
- 5 # earliest version for reasonable C++17 support
101+
- 10 # version for full C++17 support (with patches)
102+
- latest
103+
env:
104+
CC: clang
105+
CXX: clang++
106+
PROJECTQ_CLEANUP_COMPILER_FLAGS: ${{ (matrix.clang < 10) && 1 || 0 }}
107+
108+
name: "🐍 3 • Clang ${{ matrix.clang }} • x64"
109+
container: "silkeh/clang:${{ matrix.clang }}"
110+
111+
steps:
112+
- uses: actions/checkout@v2
113+
114+
- name: Get history and tags for SCM versioning to work
115+
run: |
116+
git fetch --prune --unshallow
117+
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
118+
119+
- name: Prepare env
120+
run: >
121+
apt-get update && apt-get install -y python3-dev python3-pip python3-setuptools python3-wheel
122+
python3-numpy python3-scipy python3-matplotlib python3-requests python3-networkx
123+
python3-pytest python3-pytest-cov python3-flaky
124+
--no-install-recommends
125+
126+
- name: Prepare Python env
127+
run: |
128+
python3 setup.py gen_reqfile --include-extras
129+
python3 -m pip install -r requirements.txt --prefer-binary
130+
python3 -m pip install -r requirements_tests.txt --prefer-binary
131+
132+
- name: Upgrade pybind11 and flaky
133+
run: python3 -m pip install --upgrade pybind11 flaky --prefer-binary
134+
135+
- name: Build and install package
136+
run: python3 -m pip install -ve .[braket]
137+
138+
- name: Pytest
139+
run: |
140+
echo 'backend: Agg' > matplotlibrc
141+
python3 -m pytest -p no:warnings
142+
143+
144+
gcc:
145+
runs-on: ubuntu-latest
146+
strategy:
147+
fail-fast: false
148+
matrix:
149+
gcc:
150+
- 7 # C++17 earliest version
151+
- latest
152+
153+
name: "🐍 3 • GCC ${{ matrix.gcc }} • x64"
154+
container: "gcc:${{ matrix.gcc }}"
155+
156+
steps:
157+
- uses: actions/checkout@v2
158+
159+
- name: Get history and tags for SCM versioning to work
160+
run: |
161+
git fetch --prune --unshallow
162+
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
163+
164+
- name: Prepare env
165+
run: >
166+
apt-get update && apt-get install -y python3-dev python3-pip python3-setuptools python3-wheel
167+
python3-numpy python3-scipy python3-matplotlib python3-requests python3-networkx
168+
python3-pytest python3-pytest-cov python3-flaky
169+
--no-install-recommends
170+
171+
- name: Prepare Python env
172+
run: |
173+
python3 setup.py gen_reqfile --include-extras
174+
python3 -m pip install -r requirements.txt --prefer-binary
175+
python3 -m pip install -r requirements_tests.txt --prefer-binary
176+
177+
- name: Upgrade pybind11 and flaky
178+
run: python3 -m pip install --upgrade pybind11 flaky --prefer-binary
179+
180+
- name: Build and install package
181+
run: python3 -m pip install -ve .[braket]
182+
183+
- name: Pytest
184+
run: |
185+
echo 'backend: Agg' > matplotlibrc
186+
python3 -m pytest -p no:warnings
187+
188+
189+
# Testing on CentOS (manylinux uses a centos base, and this is an easy way
190+
# to get GCC 4.8, which is the manylinux1 compiler).
191+
centos:
192+
runs-on: ubuntu-latest
193+
strategy:
194+
fail-fast: false
195+
matrix:
196+
centos:
197+
- 7 # GCC 4.8
198+
- 8
199+
200+
name: "🐍 3 • CentOS ${{ matrix.centos }} • x64"
201+
container: "centos:${{ matrix.centos }}"
202+
203+
steps:
204+
- name: Enable cache for yum
205+
run: echo 'keepcache=1' >> /etc/yum.conf
206+
207+
- name: Setup yum cache
208+
uses: actions/cache@v2
209+
with:
210+
path: |
211+
/var/cache/yum/
212+
/var/cache/dnf/
213+
key: ${{ runner.os }}-centos${{ matrix.centos }}-yum-${{ secrets.yum_cache }}
214+
215+
- name: Add Python 3 and other dependencies
216+
run: yum update -y && yum install -y python3-devel gcc-c++ make
217+
218+
- name: Setup Endpoint repository (CentOS 7 only)
219+
if: matrix.centos == 7
220+
run: yum -y install https://packages.endpoint.com/rhel/7/os/x86_64/endpoint-repo-1.7-1.x86_64.rpm
221+
222+
- name: Install Git > 2.18
223+
run: yum install -y git
224+
225+
- uses: actions/checkout@v2
226+
227+
- name: Get history and tags for SCM versioning to work
228+
run: |
229+
git fetch --prune --unshallow
230+
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
231+
232+
- name: Create pip cache dir
233+
run: mkdir -p ~/.cache/pip
234+
235+
- name: Cache wheels
236+
uses: actions/cache@v2
237+
with:
238+
path: ~/.cache/pip
239+
key: ${{ runner.os }}-centos${{ matrix.centos }}-pip-${{ hashFiles('**/setup.cfg') }}
240+
restore-keys: ${{ runner.os }}-centos-pip-
241+
242+
- name: Update pip
243+
run: python3 -m pip install --upgrade pip
244+
245+
- name: Install dependencies
246+
run: |
247+
python3 setup.py gen_reqfile --include-extras
248+
python3 -m pip install -r requirements.txt --prefer-binary
249+
python3 -m pip install -r requirements_tests.txt --prefer-binary
250+
251+
- name: Build and install package
252+
run: python3 -m pip install -ve .[braket]
253+
254+
- name: Pytest
255+
run: |
256+
echo 'backend: Agg' > matplotlibrc
257+
python3 -m pytest -p no:warnings
258+
259+
260+
documentation:
261+
name: "Documentation build test"
262+
runs-on: ubuntu-latest
263+
264+
steps:
265+
- uses: actions/checkout@v2
266+
267+
- name: Create pip cache dir
268+
run: mkdir -p ~/.cache/pip
269+
270+
- name: Cache wheels
271+
uses: actions/cache@v2
272+
with:
273+
path: ~/.cache/pip
274+
key: ${{ runner.os }}-doc-pip-${{ hashFiles('**/setup.cfg') }}
275+
restore-keys: ${{ runner.os }}-doc-pip-
276+
277+
- name: Get history and tags for SCM versioning to work
278+
run: |
279+
git fetch --prune --unshallow
280+
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
281+
282+
- uses: actions/setup-python@v2
283+
284+
- name: Install docs & setup requirements
285+
run: |
286+
python3 setup.py gen_reqfile --include-extras
287+
python3 -m pip install -r requirements.txt --prefer-binary
288+
python3 -m pip install -r docs/requirements.txt --prefer-binary
289+
python3 -m pip install .
290+
291+
- name: Build docs
292+
run: python3 -m sphinx -b html docs docs/.build
293+
294+
- name: Make SDist
295+
run: python3 setup.py sdist
296+
297+
298+
win32-msvc2017:
299+
name: "🐍 ${{ matrix.python }} • MSVC 2017 • x64"
300+
runs-on: windows-2016
301+
strategy:
302+
fail-fast: false
303+
matrix:
304+
python:
305+
- 3.6
306+
- 3.7
307+
- 3.8
308+
- 3.9
309+
310+
steps:
311+
- uses: actions/checkout@v2
312+
313+
- name: Get history and tags for SCM versioning to work
314+
run: |
315+
git fetch --prune --unshallow
316+
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
317+
318+
- name: Get pip cache dir
319+
id: pip-cache
320+
run: |
321+
echo "::set-output name=dir::$(python -m pip cache dir)"
322+
323+
- name: Cache wheels
324+
uses: actions/cache@v2
325+
with:
326+
path: ${{ steps.pip-cache.outputs.dir }}
327+
key: ${{ runner.os }}-${{ matrix.python }}-pip-${{ hashFiles('**/setup.cfg') }}
328+
restore-keys: ${{ runner.os }}-${{ matrix.python }}-pip-
329+
330+
- name: Setup 🐍 ${{ matrix.python }}
331+
uses: actions/setup-python@v2
332+
with:
333+
python-version: ${{ matrix.python }}
334+
335+
- name: Prepare env
336+
run: |
337+
python setup.py gen_reqfile --include-extras
338+
python -m pip install -r requirements.txt --prefer-binary
339+
python -m pip install -r requirements_tests.txt --prefer-binary
340+
341+
- name: Build and install package
342+
run: python -m pip install -ve .[braket]
343+
344+
- name: Run all checks
345+
run: |
346+
echo 'backend: Agg' > matplotlibrc
347+
python3 -m pytest -p no:warnings

0 commit comments

Comments
 (0)